ROI to calculate mean grey value of 2 stacks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Nan
Reply | Threaded
Open this post in threaded view
|

ROI to calculate mean grey value of 2 stacks

Nan
I'm a fresh new in ImageJ, and the problem comes from calcutating fluorescence intensity of 2 different stacks.
For only one stack, it always goes easier by following steps :Import image sequence --> Set Measurement --> Select a 'ROI' --> Press 't' to add in ROI manager --> More --> Multi Measure the fluorescence intensity of all slices is done with the result showing in Result window. However, I would like to measure the same value in two different stacks at the same time, the selected ROIs are messed up and only one of them can be processed with measurement. Is there a solution for it?

Best regards,
Nan
Reply | Threaded
Open this post in threaded view
|

Re: ROI to calculate mean grey value of 2 stacks

Swayne, Theresa C.

Hi Nan,

However, I would like to measure the same value in two different stacks at the same time

Measurement is done on one image window at a time. You can’t measure 2 different stacks “at the same time.” But you can write a macro to measure each in turn.

As an alternative, when you do ROI Manager > More > Multi-Measure, check the box “Append Results.”
Then clear the Results table, measure the first stack, then measure the 2nd stack.
The results from the 2nd stack will be added to the Results table right after the results from the 1st stack.

the selected ROIs are messed up

Could you give more details on this? What steps do you take, what is the result, and how is the result different from what you want?

Ideally, you could attach or link to images that illustrate the issue.

Hope this helps.

On Mar 23, 2017, at 1:49 AM, Nan <[hidden email]<mailto:[hidden email]>> wrote:

I'm a fresh new in ImageJ, and the problem comes from calcutating fluorescence intensity of 2 different stacks.
For only one stack, it always goes easier by following steps :Import image sequence --> Set Measurement --> Select a 'ROI' --> Press 't' to add in ROI manager --> More --> Multi Measure the fluorescence intensity of all slices is done with the result showing in Result window. However, I would like to measure the same value in two different stacks at the same time, the selected ROIs are messed up and only one of them can be processed with measurement. Is there a solution for it?

Best regards,
Nan




--
View this message in context: http://imagej.1557.x6.nabble.com/ROI-to-calculate-mean-grey-value-of-2-stacks-tp5018354.html
Sent from the ImageJ mailing list archive at Nabble.com<http://Nabble.com>.

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

------------------------------------
Theresa Swayne, Ph.D.
Manager
Confocal and Specialized Microscopy Shared Resource<http://hiccc.columbia.edu/research/sharedresources/confocal>

Herbert Irving Comprehensive Cancer Center
Columbia University Medical Center
1130 St. Nicholas Ave., Room 222A
New York, NY 10032
Phone: 212-851-4613
[hidden email]<mailto:[hidden email]>


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Nan
Reply | Threaded
Open this post in threaded view
|

Re: ROI to calculate mean grey value of 2 stacks

Nan
In reply to this post by Nan
Hi Theresa,

Thanks a lot for your reply! You will find the well explained question via this link: https://pan.baidu.com/s/1dFL13ix,  the pass word is: gn9h.

Best regards,
Nan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ROI to calculate mean grey value of 2 stacks

Swayne, Theresa C.
In reply to this post by Nan
Dear Nan,

Thanks for the details. I think I understand your issue now.

The Multi-Measure function is working as intended. It measures multiple
ROIs and also multiple slices within a stack. But it only measures the
active image.

If you want the results from multiple images in one table, you can do this
manually or with a macro.

The manual method:
1. Click on 1st stack.
2. Edit > Select All, then press T to add to the ROI Manager.
3. ROI Manager > More > Multi-Measure. Check Measure all slices, One row
per slice.
4. Click on 2nd stack. (* you don¹t need to add another ROI if the images
are the same size.)
5. ROI Manager > More > Multi-Measure. This time, check all 3 boxes
including Append Results.

The macro method (this will work whether you have 2 stacks or 200!):
1. Open one of your input images, create the ROI of the whole image, and
press T to add to the ROI Manager.
2. Place the stacks you want to measure in a folder. This is the input
folder.
3. Create an output folder (it cannot be inside the input folder).
4. Process > Batch > MacroŠ (see link to screenshot below)
        ‹ Select the input and output folders.
        ‹ Paste the following text into the large box:
                roiManager("multi-measure measure_all one append²);
        ‹ Click Process.

You can delete the images in the ³output² folder.

Screenshot of the Process > Batch > Macro window:
https://drive.google.com/open?id=0B-8RX8d7WOd9V1dSdmVONU5CcjQ

After either method, your results table will have the data from all images.

They will be in sequence, first the Image1 results, then the Image2
results.

I think you were hoping to have the results into adjacent columns, but
this would require some more intense macro writing. So it might be most
efficient to rearrange the results in your spreadsheet.

Hope this helps!


------------------------------------
Theresa Swayne, Ph.D.
Manager
Confocal and Specialized Microscopy Shared Resource
<http://hiccc.columbia.edu/research/sharedresources/confocal>

Herbert Irving Comprehensive Cancer Center
Columbia University Medical Center
1130 St. Nicholas Ave., Room 222A
New York, NY 10032
Phone: 212-851-4613
[hidden email]















On 3/23/17, 11:06 PM, "Nan Hu" <[hidden email]> wrote:

>Dear Theresa,
>
>Thanks a lot for your reply! The attachment explains my question well.
>Hope it helps.
>
>Best regards,
>Nan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ROI to calculate mean grey value of 2 stacks

Swayne, Theresa C.
In reply to this post by Nan

Dear Nan,

You’re welcome!

It is possible to do what you want, although ImageJ is not designed to easily rearrange text.

To re-format the results, you need to 1) read in the data from the existing table, and then 2) re-write it to a new table in the order that you want.  I am not adept enough to write this for you quickly.

But as an example, below is part of a macro I wrote to take certain data from the particle analysis summary table and rewrite it in a different order. You may be able to adapt this snippet for your purpose.

For more help I recommend searching this list’s archives, and the ImageJ forum at forum.imagej.net, for posts related to the Results Table. That is what I did to put together my code.

Hope this helps.

======================================================
// read data from the Summary window
selectWindow("Summary");
lines = split(getInfo(), "\n");     // reads in all the contents of the table as an array
headings = split(lines[0], "\t");  // splits the 0th row (table headings) into an array
C1Values = split(lines[1], "\t");  // 1st row of data in the table
C1Name = C1Values[0]; // 0th column in the 1st row of data — the image name
C2Values = split(lines[2], "\t");  // 2nd row of data
C2Name = C2Values[0];           // 0th column in the 2nd row of data — the image name
OverlapValues = split(lines[3], "\t"); // 3rd row of data

// convert strings to integers
C1Count = parseInt(C1Values[1]); // 1st data row, 1st data column, converted from string to int so that I can calculate with it
C2Count = parseInt(C2Values[1]); // 2nd data row, 1st data column, converted from string to int
OverlapCount = parseInt(OverlapValues[1]); // 3rd data row, 1st data column, converted from string to int

// calculate the percent overlap
C1withC2 = OverlapCount/C1Count;
C2withC1 = OverlapCount/C2Count;

// create a new table with all colocalization data
// format: image name, n cells, n cells colocalized with other label, % colocalized with other label
run("New... ", "name=[Cell_Colocalization] type=Table");
print("[Cell_Colocalization]", "Filename\tChannel\tTotal Cells\tColocalized Cells\tFraction Colocalized\n”); // new table headings
print("[Cell_Colocalization]", C1Name+"\t1\t" + C1Count+ "\t"+ OverlapCount + "\t" + C1withC2); // 1st row of data in new table
print("[Cell_Colocalization]", C2Name+"\t2\t" + C2Count+ "\t"+ OverlapCount + "\t" + C2withC1); // 2nd row of data in new table

// save the table
selectWindow("Cell_Colocalization");
saveAs("Text", path+"coloc-"+basename+".xls”);
==========================================================



> On Mar 27, 2017, at 3:37 AM, Nan Hu <[hidden email]> wrote:
>
> Dear Theresa,
>
> Thank you so much for your detailed explaination. Now things worked pretty well except for showing the results in different colums. The results are shown as you said "in one append", and the macro I use is shown as following:
>
> -------------------------------Macro Begin---------------------------------
> run("Image Sequence...", "open=[E:\\AF\stack1.tif] sort");
> run("Select All");
> roiManager("Add");
> roiManager("Multi Measure");
> run("Image Sequence...", "open=[E:\\SHG\stack1.tif] sort");
> roiManager("multi-measure measure_all one append");
> -------------------------------Macro Finished--------------------------------
>
> Do you know how to change the macro to separate the results in different colums?
>
> Best regards,
> Nan
>
>

------------------------------------
Theresa Swayne, Ph.D.
Manager
Confocal and Specialized Microscopy Shared Resource

Herbert Irving Comprehensive Cancer Center
Columbia University Medical Center
1130 St. Nicholas Ave., Room 222A
New York, NY 10032
Phone: 212-851-4613
[hidden email]


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