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 |
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 |
In reply to this post by Pedro J CamelloDr Pedro J Camello
Hi Kota,
many thanks for your help. I can easily do all the work but, when slicing the final array, the problem persists: how can I assign a variable for each slice without using an array of names? (array of arrays again...). For the Plot.create() Plot.add() procedure to work properly I need to have ready a set of arrays before Plot.creat() function and right then I can plug all the arrays in the multiple plot using Plot.add. And the loop does not give/stores a new variable with each cycle.... I´m afraid I´ll need jus a long series of If ... to assign the slices -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Pedro,
how about doing something like (continuing the hint I wrote) Plot.create("Multiple Plot", "Time", "Ratio"); for (i=0; i < numROI; i++) { Plot.add("line", Array.slice(x, i * 3, (i + 1)* 3) ); } Plot.show(); For plotting with different colors for each curve, see http://cmci.embl.de/downloads/spindlefanalyzer Cheers, Kota On Thu, Jun 5, 2014 at 2:30 PM, Pedro J Camello <[hidden email]> wrote: > Hi Kota, > > many thanks for your help. > > I can easily do all the work but, when slicing the final array, the > problem persists: how can I assign a variable for each slice without using > an array of names? (array of arrays again...). For the Plot.create() > Plot.add() procedure to work properly I need to have ready a set of arrays > before Plot.creat() function and right then I can plug all the arrays in > the multiple plot using Plot.add. And the loop does not give/stores a new > variable with each cycle.... > I´m afraid I´ll need jus a long series of If ... to assign the slices > > > > -- > 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 |
In reply to this post by Pedro J CamelloDr Pedro J Camello
Many thanks, it works!
I thought that the Plot.create() and Plot.add() did not allow any code in between (I had played placing there If() statements but were not allowed) And your code in the link has been very useful for the color of the traces. I really appreciate your help. This is what makes ImageJ great. Regards Pedro -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |