average above threshold

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

average above threshold

Glen MacDonald-2
Hello,
Is it possible in ImageJ to create an Average projection over the z-axis that only includes pixel intensities above threshold?  We would like to get an average intensity plot along a structure but the tissue section is not completely flat.  

thanks,
Glen


Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Pablo Manuel Jais
Glen MacDonald wrote:
> Hello,
> Is it possible in ImageJ to create an Average projection over the z-axis
> that only includes pixel intensities above threshold?  We would like to
> get an average intensity plot along a structure but the tissue section is
> not completely flat.
>
> thanks,
> Glen

I'm far from being an expert here, but I don't think there's an easy way
to do that. If I understand correctly, you want the Z projection to
average each column of pixels, but only taking into account those values
that are above the threshold. That is, if a column has the values
10,20,30,40,50 and your threshold is 35, you want to get (40+50)/2, right?

I just tried thresholding an image and using Process->Math->NaN
Background. This takes all pixels below the threshold to NaN. My idea was
that maybe the Z projection ignored the NaN values when calculating the
average. However, it doesn't, the average results to NaN too (I think this
is on purpose, though).

You might need to hack the Z projection function to make a new kind of
average. Check the source if you feel confident, or ask for help. Maybe
someone can give you further advice.

Hope this helps,
  Pablo
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Glen MacDonald-2
I think the alternatives are to plot the integrated intensity profile of the thresholded stack, or to create a single frame 3D Mean projection limited to a threshold.

Regards,
Glen

Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]








On Jan 27, 2010, at 9:26 AM, Pablo Manuel Jais wrote:

> Glen MacDonald wrote:
>> Hello,
>> Is it possible in ImageJ to create an Average projection over the z-axis
>> that only includes pixel intensities above threshold?  We would like to
>> get an average intensity plot along a structure but the tissue section is
>> not completely flat.
>>
>> thanks,
>> Glen
>
> I'm far from being an expert here, but I don't think there's an easy way
> to do that. If I understand correctly, you want the Z projection to
> average each column of pixels, but only taking into account those values
> that are above the threshold. That is, if a column has the values
> 10,20,30,40,50 and your threshold is 35, you want to get (40+50)/2, right?
>
> I just tried thresholding an image and using Process->Math->NaN
> Background. This takes all pixels below the threshold to NaN. My idea was
> that maybe the Z projection ignored the NaN values when calculating the
> average. However, it doesn't, the average results to NaN too (I think this
> is on purpose, though).
>
> You might need to hack the Z projection function to make a new kind of
> average. Check the source if you feel confident, or ask for help. Maybe
> someone can give you further advice.
>
> Hope this helps,
>  Pablo
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Gabriel Landini
On Wednesday 27 January 2010 17:50:57 you wrote:
> I think the alternatives are to plot the integrated intensity profile of
>  the thresholded stack, or to create a single frame 3D Mean projection
>  limited to a threshold.

I think there is another way, but I have not tested it:
For each slice, you know if a pixel is above or below the threshold when you
threshold it. Let's say that the t=35 and so the pixels >=t are set to 255,
then if you divide the thresholded stack by 255, each thresholded pixel
becomes 1, add up the slices (z projection sum) and now you know how many
slices were >= t for each pixel.
The same thresholded stack (before dividing by 255) can be used to delete the
data from the original that is <=t (invert the thresholded stack and subtract
this from the original, so if <t then pixel = 0 ).
Now sum up the result. The pixels <t are set to 0 so they do not contribute to
the total sum.
Now divide by the sum of thresholded slices (that were divided by 255).
This could be all done with a macro.
Cheers

G.
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Glen MacDonald-2
Dear Gabriel,
This worked:
Duplicate stack
threshold, dark bg
make binary
divide by 255
multiply result with original to set pixels <t to 0
Z-axis projection to sum slices - automatically creates 32-bit result.  

The structure of interest in each stack is at an angle, and Plot Profile doesn't work with rectangular ROIs created with the Polygon tool.  Which means the final step is to draw a line along the structure's axis to set image rotation so we can use a rectangular ROI to get an averaged profile plot of the summed intensities.  

thanks for the concept.

Glen
Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]








On Jan 27, 2010, at 1:19 PM, Gabriel Landini wrote:

> On Wednesday 27 January 2010 17:50:57 you wrote:
>> I think the alternatives are to plot the integrated intensity profile of
>> the thresholded stack, or to create a single frame 3D Mean projection
>> limited to a threshold.
>
> I think there is another way, but I have not tested it:
> For each slice, you know if a pixel is above or below the threshold when you
> threshold it. Let's say that the t=35 and so the pixels >=t are set to 255,
> then if you divide the thresholded stack by 255, each thresholded pixel
> becomes 1, add up the slices (z projection sum) and now you know how many
> slices were >= t for each pixel.
> The same thresholded stack (before dividing by 255) can be used to delete the
> data from the original that is <=t (invert the thresholded stack and subtract
> this from the original, so if <t then pixel = 0 ).
> Now sum up the result. The pixels <t are set to 0 so they do not contribute to
> the total sum.
> Now divide by the sum of thresholded slices (that were divided by 255).
> This could be all done with a macro.
> Cheers
>
> G.
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Gabriel Landini
On Friday 29 Jan 2010  11:43:46 you wrote:
> This worked:
> Duplicate stack
> threshold, dark bg
> make binary
> divide by 255
> multiply result with original to set pixels <t to 0
> Z-axis projection to sum slices - automatically creates 32-bit result.
 
> The structure of interest in each stack is at an angle, and Plot Profile
>  doesn't work with rectangular ROIs created with the Polygon tool.  Which
>  means the final step is to draw a line along the structure's axis to set
>  image rotation so we can use a rectangular ROI to get an averaged profile
>  plot of the summed intensities.

However the "sum intensities" should be divided by the "sum of binary slices
with values 0 and 1" because the first sum is not guaranteed to be due to the
same number of contributing slices. (not sure I am being clear).

Let's say for a pixel, your sum of 200 can be contributed by 4 slices with a
value of 50 in each slice, or by 2 slices with 100 in each slice.
In the first case your average should be 50 in the second 100.

Cheers

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: average above threshold

Glen MacDonald-2
That is a good point although the results may represent absolute amount of label, the influence of unstained structures such as blood vessel lumina or unstained cell types on label distribution would be lost, since they are "0".  In this particular instance, the sections aren't entirely flat, but the confocal images are through their entirety.

It will be interesting to compare results for this particular application.

Regards,
Glen


 
Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]








On Jan 29, 2010, at 3:50 AM, Gabriel Landini wrote:

> On Friday 29 Jan 2010  11:43:46 you wrote:
>> This worked:
>> Duplicate stack
>> threshold, dark bg
>> make binary
>> divide by 255
>> multiply result with original to set pixels <t to 0
>> Z-axis projection to sum slices - automatically creates 32-bit result.
>
>> The structure of interest in each stack is at an angle, and Plot Profile
>> doesn't work with rectangular ROIs created with the Polygon tool.  Which
>> means the final step is to draw a line along the structure's axis to set
>> image rotation so we can use a rectangular ROI to get an averaged profile
>> plot of the summed intensities.
>
> However the "sum intensities" should be divided by the "sum of binary slices
> with values 0 and 1" because the first sum is not guaranteed to be due to the
> same number of contributing slices. (not sure I am being clear).
>
> Let's say for a pixel, your sum of 200 can be contributed by 4 slices with a
> value of 50 in each slice, or by 2 slices with 100 in each slice.
> In the first case your average should be 50 in the second 100.
>
> Cheers
>
> Gabriel