I have a large time series (thousands of frames) of micrographs of a stationary structure that pulsates over time. I need to collect data from a single profile measurement (of a 100 pixel wide x ca. 4mm long perpendicular line) of each time point (frame) and combine into a single data sheet.
This problem must have been solved previously but I could find no suitably applicable posts. I have used the ROI manager and multi measure to analyze the same images for other parameters but do not see a way to apply these tools to the "plot profile" measurement. Any formulas/scripts/macros that can be sent will be so gratefully appreciated! |
Christopher,
this looks like a task for a ImageJ-macro. Here you find some docs for macro coding: <http://rsb.info.nih.gov/ij/developer/index.html> 1. Make the appropriate selection in the first image (frame) of the stack (it will be present in the other images too). 2. While looping through the frames apply "getProfile" and append the array of profile values to a text file by using "File.append(string, path)". HTH Herbie :::::::::::::::::::::::::::::::::::::: Am 13.04.16 um 19:52 schrieb cpanders: > I have a large time series (thousands of frames) of micrographs of a > stationary structure that pulsates over time. I need to collect data from a > single profile measurement (of a 100 pixel wide x ca. 4mm long perpendicular > line) of each time point (frame) and combine into a single data sheet. > > This problem must have been solved previously but I could find no suitably > applicable posts. I have used the ROI manager and multi measure to analyze > the same images for other parameters but do not see a way to apply these > tools to the "plot profile" measurement. > > Any formulas/scripts/macros that can be sent will be so gratefully > appreciated! > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by cpanders
Hi,
You don't really need a script for that. 1. Reslice with "100 slices", then you get a stack of 100 slices (= width of the line ROI) 2. Do Z-Projection. If you want an average for each x position, then choose "average" as the projection method. This then gives you a single projected 2D image. 3. Save this image as a text image. It will then be a text file with average intensity profile per line (= time point) good luck, Kota On Wed, Apr 13, 2016 at 7:52 PM, cpanders <[hidden email]> wrote: > I have a large time series (thousands of frames) of micrographs of a > stationary structure that pulsates over time. I need to collect data from > a > single profile measurement (of a 100 pixel wide x ca. 4mm long > perpendicular > line) of each time point (frame) and combine into a single data sheet. > > This problem must have been solved previously but I could find no suitably > applicable posts. I have used the ROI manager and multi measure to analyze > the same images for other parameters but do not see a way to apply these > tools to the "plot profile" measurement. > > Any formulas/scripts/macros that can be sent will be so gratefully > appreciated! > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ------------------------------------------------------------- Dr. Kota Miura <[hidden email]> Freelance Image Analyst EMBL Meyerhofstr. 1, 69117 Heidelberg, GERMANY Tel +49 6221 387 8404 Mobile +49 160 95001177http://cmci.embl.de ++++++++++++++++++ Dr. Kota Miura <[hidden email]> Research Collaboration Fellow National Institute of Basic Biology Okazaki, 444-8585 JAPAN ------------------------------------------------------------- -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Herbie
Progress! I found a macro (copied below) that will capture the profile plot for each frame of the stack with one click, generating a plot window in which each frame has a page with its unique plot. However, the "list" and "save" options are absent.
I now need to extract the x-y data for each page into a single sheet containing all plot data for the entire stack for further analysis in R. Here is the macro which works very nicely as far as it goes: // StackProfilePlot // This macro generates profile plots of all the images // in a stack and stores then in another stack. macro "Stack profile Plot" { ymin = 0; ymax = 255; saveSettings(); if (nSlices==1) exit("Stack required"); run("Profile Plot Options...", "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); setBatchMode(true); stack1 = getImageID; stack2 = 0; n = nSlices; for (i=1; i<n; i++) { showProgress(i, n); selectImage(stack1); setSlice(i); run("Plot Profile"); run("Copy"); w = getWidth; h = getHeight; close(); if (stack2==0) { newImage("Plots", "8-bit", w, h, 1); stack2 = getImageID; } else { selectImage(stack2); run("Add Slice"); } run("Paste"); } setSlice(1); setBatchMode(false); restoreSettings(); } |
Christopher,
while the suggestion of Kota is really straightforward, you could adapt the code you've posted according to my suggestion. If you like single click solutions, you may record the process suggested by Kota by using the macro recorder. Best Herbie :::::::::::::::::::::::::::::::::::::: Am 14.04.16 um 18:12 schrieb cpanders: > Progress! I found a macro (copied below) that will capture the profile plot > for each frame of the stack with one click, generating a plot window in > which each frame has a page with its unique plot. However, the "list" and > "save" options are absent. > I now need to extract the x-y data for each page into a single sheet > containing all plot data for the entire stack for further analysis in R. > > > Here is the macro which works very nicely as far as it goes: > > // StackProfilePlot > // This macro generates profile plots of all the images > // in a stack and stores then in another stack. > > macro "Stack profile Plot" { > ymin = 0; > ymax = 255; > saveSettings(); > if (nSlices==1) > exit("Stack required"); > run("Profile Plot Options...", > "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); > setBatchMode(true); > stack1 = getImageID; > stack2 = 0; > n = nSlices; > for (i=1; i<n; i++) { > showProgress(i, n); > selectImage(stack1); > setSlice(i); > run("Plot Profile"); > run("Copy"); > w = getWidth; h = getHeight; > close(); > if (stack2==0) { > newImage("Plots", "8-bit", w, h, 1); > stack2 = getImageID; > } else { > selectImage(stack2); > run("Add Slice"); > } > run("Paste"); > } > setSlice(1); > setBatchMode(false); > restoreSettings(); > } > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124p5016139.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Kota Miura
Thank you for the tip! I tried your suggestion but have reservations on the utility for my purpose. I’m somewhat concerned about averaging in a way that is not transparent- all I need
data for the average profile of ca 80-100 pixels across a linear structure for each time point. Also, when saving image as text file (which is quite nice) I still am limited to a single page of data per file. There is a macro in the forum which nicely generates a profile plot for each frame of an image stack, but I have been unsuccessful in extracting the x-y data from
the plot and combining it into a single data sheet/text file. Any suggestions? I do not ever need to see the plot, if the data can go directly into a file rather than being graphed I will be set. Thank you very much for your consideration- Here is the existing macro: // StackProfilePlot // This macro generates profile plots of all the images // in a stack and stores then in another stack. macro "Stack profile Plot" { ymin = 0; ymax = 255; saveSettings(); if (nSlices==1) exit("Stack required"); run("Profile Plot Options...",
"width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); setBatchMode(true); stack1 = getImageID; stack2 = 0; n = nSlices; for (i=1; i<n; i++) { showProgress(i, n); selectImage(stack1); setSlice(i); run("Plot Profile"); run("Copy"); w = getWidth; h = getHeight; close(); if (stack2==0) { newImage("Plots", "8-bit", w, h, 1); stack2 = getImageID; } else { selectImage(stack2); run("Add Slice"); } run("Paste"); } setSlice(1); setBatchMode(false); restoreSettings(); } From: Kota Miura [via ImageJ] [mailto:ml-node+[hidden email]]
Hi,
If you reply to this email, your message will be added to the discussion below: To unsubscribe from combine data from multiple profile measurements of a time series to single data sheet,
click here. |
In reply to this post by Kota Miura
I tried your suggestion but have reservations on the utility for my purpose. First of all , if the values represent the average over time it is not usable- I need data for the average profile of ca 80-100 pixels across a linear structure for each time point. Also, when saving image s test file (which is quite nice) I still am limited to a single page of data per file.
There is a macro in the forum which nicely generates a profile plot for each frame of an image stack, but I have been unsuccessful in extracting the x-y data from the plot and combining it into a single data sheet/text file. Any suggestions? I do not ever need to see the plot, if the data can go directly into a file rather than being graphed I will be set. Here is the existing macro: // StackProfilePlot // This macro generates profile plots of all the images // in a stack and stores then in another stack. macro "Stack profile Plot" { ymin = 0; ymax = 255; saveSettings(); if (nSlices==1) exit("Stack required"); run("Profile Plot Options...", "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); setBatchMode(true); stack1 = getImageID; stack2 = 0; n = nSlices; for (i=1; i<n; i++) { showProgress(i, n); selectImage(stack1); setSlice(i); run("Plot Profile"); run("Copy"); w = getWidth; h = getHeight; close(); if (stack2==0) { newImage("Plots", "8-bit", w, h, 1); stack2 = getImageID; } else { selectImage(stack2); run("Add Slice"); } run("Paste"); } setSlice(1); setBatchMode(false); restoreSettings(); } |
Chris,
now you've cross-posted your question to the IJ-forum. You can't access the values from plots after they have been saved as images or put in a stack. I'm still am convinced that the approach suggested by Kota works. If you could post a partial stack (some frames) with the selection you like to use, then one could help you much better. "a ca. 2 mm long perpendicular line" What does 2mm mean in pixels or what scale did you set for your images? And to what is the line perpendicular? Please be more specific and post an example stack. Best Herbie :::::::::::::::::::::::::::::::::::::: Am 18.04.16 um 20:19 schrieb cpanders: > I tried your suggestion but have reservations on the utility for my purpose. > First of all , if the values represent the average over time it is not > usable- I need data for the average profile of ca 80-100 pixels across a > linear structure for each time point. Also, when saving image s test file > (which is quite nice) I still am limited to a single page of data per file. > > There is a macro in the forum which nicely generates a profile plot for each > frame of an image stack, but I have been unsuccessful in extracting the x-y > data from the plot and combining it into a single data sheet/text file. > Any suggestions? I do not ever need to see the plot, if the data can go > directly into a file rather than being graphed I will be set. > > > > > Here is the existing macro: > > // StackProfilePlot > // This macro generates profile plots of all the images > // in a stack and stores then in another stack. > > macro "Stack profile Plot" { > ymin = 0; > ymax = 255; > saveSettings(); > if (nSlices==1) > exit("Stack required"); > run("Profile Plot Options...", > "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); > setBatchMode(true); > stack1 = getImageID; > stack2 = 0; > n = nSlices; > for (i=1; i<n; i++) { > showProgress(i, n); > selectImage(stack1); > setSlice(i); > run("Plot Profile"); > run("Copy"); > w = getWidth; h = getHeight; > close(); > if (stack2==0) { > newImage("Plots", "8-bit", w, h, 1); > stack2 = getImageID; > } else { > selectImage(stack2); > run("Add Slice"); > } > run("Paste"); > } > setSlice(1); > setBatchMode(false); > restoreSettings(); > } > > > > -- > View this message in context: http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124p5016169.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by cpanders
Christopher,
you may want to look into kymographs or time-space-plots, which however are substantially very similar to what Kota suggested. Greetings, Jens On 18 Apr 2016 8:34 p.m., "cpanders" <[hidden email]> wrote: > I tried your suggestion but have reservations on the utility for my > purpose. > First of all , if the values represent the average over time it is not > usable- I need data for the average profile of ca 80-100 pixels across a > linear structure for each time point. Also, when saving image s test file > (which is quite nice) I still am limited to a single page of data per file. > > There is a macro in the forum which nicely generates a profile plot for > each > frame of an image stack, but I have been unsuccessful in extracting the x-y > data from the plot and combining it into a single data sheet/text file. > Any suggestions? I do not ever need to see the plot, if the data can go > directly into a file rather than being graphed I will be set. > > > > > Here is the existing macro: > > // StackProfilePlot > // This macro generates profile plots of all the images > // in a stack and stores then in another stack. > > macro "Stack profile Plot" { > ymin = 0; > ymax = 255; > saveSettings(); > if (nSlices==1) > exit("Stack required"); > run("Profile Plot Options...", > "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); > setBatchMode(true); > stack1 = getImageID; > stack2 = 0; > n = nSlices; > for (i=1; i<n; i++) { > showProgress(i, n); > selectImage(stack1); > setSlice(i); > run("Plot Profile"); > run("Copy"); > w = getWidth; h = getHeight; > close(); > if (stack2==0) { > newImage("Plots", "8-bit", w, h, 1); > stack2 = getImageID; > } else { > selectImage(stack2); > run("Add Slice"); > } > run("Paste"); > } > setSlice(1); > setBatchMode(false); > restoreSettings(); > } > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124p5016169.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Jens Rietdorf
Visiting Scientist
Fundação Oswaldo Cruz - Ministério da Saúde, Centro de Desenvolvimento Tecnológico em Saúde (CDTS), Rio de Janeiro, Brasil.
|
In reply to this post by cpanders
Success! On the ImageJ forum Bio7 incorporated a macro from (https://sunhaehong.wordpress.com/2015/06/25/60/) into the stack plot macro, and it works quite nicely. I'm posting the entire macro below for others with similar needs. There is an image from the stacks we are measuring attached FYI. We have 6x 24 hour timestacks captured at an 8 second frame interval, we could never analyze them without this tool.
Thank you for the assistance! macro "Stack profile Plot" { collectedValues=""; ymin = 0; ymax = 255; saveSettings(); if (nSlices==1) exit("Stack required"); run("Profile Plot Options...", "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); setBatchMode(true); stack1 = getImageID; stack2 = 0; n = nSlices; for (i=1; i<n; i++) { showProgress(i, n); selectImage(stack1); setSlice(i); run("Clear Results"); profile = getProfile(); for (j=1; j<profile.length; j++) { collectedValues=collectedValues+profile[j] + "\t"; } collectedValues=collectedValues+"\n"; run("Plot Profile"); run("Copy"); w = getWidth; h = getHeight; close(); if (stack2==0) { newImage("Plots", "8-bit", w, h, 1); stack2 = getImageID; } else { selectImage(stack2); run("Add Slice"); } run("Paste"); } f = File.open("/Users/evanbuss/Documents/CA Analysis 2013/Polyp Removal 2016/stack profile data/profileValues.txt"); print(f, collectedValues); setSlice(1); setBatchMode(false); restoreSettings(); } |
Hi everyone,
For reference, the forum post to which Christopher refers is: http://forum.imagej.net/t/how-to-obtain-xy-values-from-repeated-profile-plot/1398/2 It is always good to cross-link these things for the archives, so that people can understand the discussion more easily later. Regards, Curtis -- Curtis Rueden LOCI software architect - http://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden Did you know ImageJ has a forum? http://forum.imagej.net/ On Wed, Apr 20, 2016 at 12:41 PM, cpanders <[hidden email]> wrote: > Success! On the ImageJ forum Bio7 incorporated a macro from > (https://sunhaehong.wordpress.com/2015/06/25/60/) into the stack plot > macro, > and it works quite nicely. I'm posting the entire macro below for others > with similar needs. There is an image from the stacks we are measuring > attached FYI. We have 6x 24 hour timestacks captured at an 8 second frame > interval, we could never analyze them without this tool. > > Thank you for the assistance! > <http://imagej.1557.x6.nabble.com/file/n5016200/test_frame_1_w_scale.png> > > > > macro "Stack profile Plot" { > collectedValues=""; > ymin = 0; > ymax = 255; > saveSettings(); > if (nSlices==1) > exit("Stack required"); > run("Profile Plot Options...", > "width=400 height=200 minimum="+ymin+" maximum="+ymax+" fixed"); > setBatchMode(true); > stack1 = getImageID; > stack2 = 0; > n = nSlices; > for (i=1; i<n; i++) { > showProgress(i, n); > selectImage(stack1); > setSlice(i); > run("Clear Results"); > profile = getProfile(); > for (j=1; j<profile.length; j++) { > collectedValues=collectedValues+profile[j] + "\t"; > } > collectedValues=collectedValues+"\n"; > > run("Plot Profile"); > run("Copy"); > w = getWidth; h = getHeight; > close(); > if (stack2==0) { > newImage("Plots", "8-bit", w, h, 1); > stack2 = getImageID; > } else { > selectImage(stack2); > run("Add Slice"); > } > run("Paste"); > } > > f = File.open("/Users/evanbuss/Documents/CA Analysis 2013/Polyp Removal > 2016/stack profile data/profileValues.txt"); > print(f, collectedValues); > setSlice(1); > setBatchMode(false); > restoreSettings(); > } > > > > > -- > View this message in context: > http://imagej.1557.x6.nabble.com/combine-data-from-multiple-profile-measurements-of-a-time-series-to-single-data-sheet-tp5016124p5016200.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by cpanders
Good day Christopher,
nice to see that you found a way of performing the desired task. In addition I should like to propose an example macro based on Kota's approach. The essential part of it is quite concise. -- You need an open internet connection to run the macro. -- // example macro (watch for mailer line breaks!) width = 15; // integration width perpendicular to the line selection // the following is for the generation of an test image only run( "Confocal Series (2.2MB)" ); setBatchMode( true ); name = "TestStack"; Stack.setDisplayMode( "grayscale" ); run("Reduce Dimensionality...", "slices"); run( "Set Scale...", "distance=0" ); setLineWidth( 0 ); // example line selection for the profile makeLine( 66, 328, 218, 176 ); // here comes the beef --------------------------------------------- run( "Reslice [/]...", "output=1.000 slice_count="+width+" rotate"); run( "32-bit" ); run( "Z Project...", "projection=[Average Intensity]" ); rename( "ProfileValues_of_" + name ); saveAs( "Text Image" ); setBatchMode( "exit and display" ); // end of beef tail ------------------------------------------------ The text file that you are going to save contains the profile values in columns. Each column contains the profile values from one frame. Please note that the integration starts from the selection line downwards. In the example case 15 pixels wide. Best Herbie |
Herbie- Thank you so much for taking the time to do this.! I will try this method as well, I was intrigued while looking into the reslice tool earlier iin the week From: Herbie [via ImageJ] [mailto:ml-node+[hidden email]]
Good day Christopher, If you reply to this email, your message will be added to the discussion below: To unsubscribe from combine data from multiple profile measurements of a time series to single data sheet,
click here. |
Free forum by Nabble | Edit this page |