Divide each slice in stack by different value

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

Divide each slice in stack by different value

Aaron Hendrickson
Hello,

I have two stack where I want to measure the mean pixel intensity of
each slice in the first stack then divide the second stack (with the
same number of slices) by the list of mean intensities.  In other
words, divide the first slice in stack two by the mean intensity of
the first slice in stack one, divide the second slice in stack two by
the mean intensity of the second slice in stack one, so on and so
forth.  Is there a plugin that can perform this task?

Thanks,
-Aaron.
Reply | Threaded
Open this post in threaded view
|

Re: Divide each slice in stack by different value

Rasband, Wayne (NIH/NIMH) [E]
On Feb 9, 2012, at 8:20 AM, Aaron Hendrickson wrote:

> Hello,
>
> I have two stack where I want to measure the mean pixel intensity of
> each slice in the first stack then divide the second stack (with the
> same number of slices) by the list of mean intensities.  In other
> words, divide the first slice in stack two by the mean intensity of
> the first slice in stack one, divide the second slice in stack two by
> the mean intensity of the second slice in stack one, so on and so
> forth.  Is there a plugin that can perform this task?

Here is a macro that does it.

-wayne

  n = nSlices;
  if (nImages!=2 || nSlices<2)
     exit("Two stacks expected");
  means = newArray(n);
  for (i=0; i<n; i++) {
     setSlice(i+1);
     getStatistics(area, mean);
     means[i] = mean;
  }
  run("Put Behind [tab]");
  if (n!=nSlices)
     exit("Stacks must be the same size");
  for (i=0; i<n; i++) {
     setSlice(i+1);
     mean = means[i];
     run("Divide...", "value=&mean slice");
  }
Reply | Threaded
Open this post in threaded view
|

Re: Divide each slice in stack by different value

Aaron Hendrickson
Thanks Wayne!  If I wanted to use the integrated sum instead of the
mean can I simply type "integrated sum" in where the scripts says
"mean"?

Thanks again,
-Aaron.

On 2/9/12, Rasband, Wayne (NIH/NIMH) [E] <[hidden email]> wrote:

> On Feb 9, 2012, at 8:20 AM, Aaron Hendrickson wrote:
>
>> Hello,
>>
>> I have two stack where I want to measure the mean pixel intensity of
>> each slice in the first stack then divide the second stack (with the
>> same number of slices) by the list of mean intensities.  In other
>> words, divide the first slice in stack two by the mean intensity of
>> the first slice in stack one, divide the second slice in stack two by
>> the mean intensity of the second slice in stack one, so on and so
>> forth.  Is there a plugin that can perform this task?
>
> Here is a macro that does it.
>
> -wayne
>
>   n = nSlices;
>   if (nImages!=2 || nSlices<2)
>      exit("Two stacks expected");
>   means = newArray(n);
>   for (i=0; i<n; i++) {
>      setSlice(i+1);
>      getStatistics(area, mean);
>      means[i] = mean;
>   }
>   run("Put Behind [tab]");
>   if (n!=nSlices)
>      exit("Stacks must be the same size");
>   for (i=0; i<n; i++) {
>      setSlice(i+1);
>      mean = means[i];
>      run("Divide...", "value=&mean slice");
>   }
>