Re: divide stack by list

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Re: divide stack by list

Thomas Suchyna
I received the following assistance by Eric Kischell regarding the help I requested on 11-13-18. It allowed me to stabilize image intensity of a stack. Thanks.


Hi Eric,

Thank you so much! After I figured out that I needed to have an individual ROI for each image in the ROI manager, it worked exactly as stated.

I checked to make sure it stabilized the intensity as planned.

The original stack data showed an intensity changes of >15% as the experiment progressed through two cycles.

The intensity stabilized stack I generated with the macro you sent, changed by <4%.

More importantly, the area changes were much smaller after using the corrected stacks (as I suspected they would be). And the area changes that did occur were not correlated with any small changes in intensity – verifying the area changes are real!

Thanks again.

Should I post this to the help forum, or is the problem too specific?

Best wishes


Thomas M. Suchyna, Ph.D.
Dept. of Physiology and Biophysics
301 Cary Hall
SUNY at Buffalo
Buffalo, NY 14214
Phone: 716-829-5156
e-mail: [hidden email]

From: Eric Kischell [mailto:[hidden email]]
Sent: Friday, November 23, 2018 8:35 PM
To: Suchyna, Thomas <[hidden email]>
Subject: Re: divide stack by list

Try the following macro.
Attached and inline.
Let me know what you think.

// Assumes that an ROI is defined for every slice in your stack.
// Normalizes each slice by the mean of each ROI.
// The input image is destructively modified.
macro "Fluor Divide"{
            image_to_process = getImageID();
            run("Set Measurements...", "mean redirect=None decimal=5");
            roiManager("Show All");
            for (i=1; i<=nSlices; i++){
              run("Set Slice...", "slice="+i);
              run("Divide...", "slice value="+roi_mean);            
            } // for loop
            run("Select None");
            run("Min...", "value=0 stack");  // if type was 32 bit

On Fri, Nov 23, 2018 at 6:54 PM Eric Kischell <[hidden email]> wrote:
I have found a good starting point (IJ macro)--
I replaced
run("Subtract...", "slice value="+bgmean);
run("Divide...", "slice value="+bgmean); // where bgmean could be an roi mean

I am having trouble understanding why
 run("Plot Z-axis Profile"); gives the same mean for 3 different rois in 3 different slices?
I am getting errors on the following line--
bgmean=getResult("Mean",(i-1)) .

If I cannot bypass these issues, I may have to develop a Java plugin.

ImageJ mailing list: