Hello,
I've in-lined the final version of the Intensity Stabilizer macro. Is there a better public posting method for small macros? //=================================================================== // This macro divides (normalizes) each slice in an image stack by the mean of previously defined per-slice ROIs. // It is useful to produce fluorescent images with good intensity stabilization which is needed to accurately determine the area change over time. // It assumes that an ROI is defined for every slice in your stack. // The input image stack is normalized in-place. // This macro was based on the 'Subtract background based on ROI' macro. macro "Intensity Stabilizer Action Tool - Cbdb76bD07D37D67D97Dc7Df7L0330L3063L6390L90c3Lc3f0"{ setBatchMode(true); image_to_process = getImageID(); run("Set Measurements...", "mean redirect=None decimal=5"); selectImage(image_to_process); roiManager("Show All"); roiManager("Measure"); for (i=1; i<=nSlices; i++){ roi_mean=getResult("Mean",(i-1)); 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 resetMinAndMax(); setBatchMode(false); } Thx e.- --- 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 Tom 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: [log in to unmask] From: Eric Kischell [mailto:[log in to unmask]] Sent: Friday, November 23, 2018 8:35 PM To: Suchyna, Thomas <[log in to unmask]> 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"); selectImage(image_to_process); roiManager("Show All"); roiManager("Measure"); for (i=1; i<=nSlices; i++){ roi_mean=getResult("Mean",(i-1)); 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 resetMinAndMax(); } On Fri, Nov 23, 2018 at 6:54 PM Eric Kischell <[log in to unmask]> wrote: Tom, I have found a good starting point (IJ macro)-- https://list.nih.gov/cgi-bin/wa.exe?A2=ind1706&L=IMAGEJ&P=R22915&1=IMAGEJ&9=A&J=on&d=No+Match%3BMatch%3BMatches&z=4 I replaced run("Subtract...", "slice value="+bgmean); by 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? Also 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. e.- -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |