Login  Register

Workaround for array of arrays in a macro

Posted by Pedro J CamelloDr Pedro J Camello on Jun 04, 2014; 9:43pm
URL: http://imagej.273.s1.nabble.com/Workaround-for-array-of-arrays-in-a-macro-tp5008016.html

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