Login  Register

Re: Workaround for array of arrays in a macro

Posted by Kota Miura on Jun 05, 2014; 1:33am
URL: http://imagej.273.s1.nabble.com/Workaround-for-array-of-arrays-in-a-macro-tp5008016p5008017.html

Hi Pedro,

You could accumulate all profiles in a single array.

here is a hint:

   x = newArray(0);
   a1 = newArray(1, 2, 3);
   a2 = newArray(10, 20, 30);

   //accumulate arrays in a single array
   x = Array.concat(x, a1);
   x = Array.concat(x, a2);
   Array.print(x);

   //slicing a range
   x2 = Array.slice(x, 3, 6);
   Array.print(x2);

cheers,
Kota


On Wed, Jun 4, 2014 at 11:43 PM, Pedro J Camello <[hidden email]> wrote:

> Hi all,
>
> I´m trying to write a simple macro to do a multiple plot from a stack with
> several ROIs already defined in the ROI Manager:
> 1) select the first ROI from the ROI Manager and make a Z Profile
> 2) I get the values and put them in a variable. Then I close the Z plot
> window.
> 3) After repeating the task for each ROI, I create a plot with the first
> variable and add the rest of them.
>
> For a known number of ROIS it is a trivial task, but the number of ROIs is
> very variable from stack to stack (from 1 to around 20), and I have tried
> to make a for (...) loop. I have tried to make an array of arrays but it
> gives me an error
>
> Any suggestions for an inexperienced "programmer"?
>
> I enclose the code:
>
> numROI = roiManager("count");
> Yseries = newArray(numROI);
>
> for (i=0; i < numROI; i++) {
>         roiManager("select", i);
>         run("Plot Z-axis Profile");
>         Plot.getValues(x1, valorY);
>         close();
>         selectWindow("Results");
>         run("Close");
>         Yseries[i] = valorY; //THIS LINE GIVES AN ERROR: ARRAY OF ARRAYS
> NOT SUPPORTED
> }
>
> Plot.create("Multiple Plot", "Time", "Ratio", x1, Yseries[0])
>
> for (i=0; i < numROI; i++) {
>         Plot.add("line", Yseries[i]);
> }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--

-------------------------------------------------------------*Dr. Kota Miura*

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404

Mobile +49 160 95001177

Fax +49 6221 387 512

http://cmci.embl.de
-------------------------------------------------------------

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html