// Just open this in the Macro Editor in FIJI, click on your image, and click 'Run' // it should do what you want. Make sure you only do it with a 1D image. // it will let you pick a gaussian kernal size. I usually recommend 10-20% of your // image width, but definitely play around with it. AutoFFC(); function AutoFFC() { start = getTitle() getDimensions(width, height, channels, slices, frames); //print(height); print(width) getVoxelSize(vwidth, vheight, vdepth, vunit) blur= floor(width*0.08); Dialog.create("Set Blur Kernel") Dialog.addMessage("Enter Blur Kernel Size") Dialog.addNumber("Blur Kernel (px) = ", blur) Dialog.show() blur = Dialog.getNumber() if (frames>1) { // For time series where the flat field is relatively stable run("Z Project...", "stop=5 projection=[Average Intensity]"); avgBkgd = getTitle(); run("Gaussian Blur...", "sigma=&blur"); getStatistics(area, mean, min, max, std, histogram); mean = floor(mean); run("Calculator Plus","i1=&start i2=&avgBkgd operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=&mean create"); rename(start+"_bkgdSub"); stk_bkgd = getTitle(); } if (slices>1) { // for z stacks where each image may have a different Flat field run("Duplicate...", "duplicate"); avgBkgd = getTitle(); run("Gaussian Blur...", "sigma=&blur stack"); getStatistics(area, mean, min, max, std, histogram); mean = floor(mean); run("Calculator Plus","i1=&start i2=&avgBkgd operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=&mean create"); rename(start+"_bkgdSub"); stk_bkgd = getTitle(); } else { // Single images run("Duplicate...", start+"_bkgdsub"); avgBkgd = getTitle(); run("Gaussian Blur...", "sigma=&blur"); getStatistics(area, mean, min, max, std, histogram); mean = floor(mean); run("Calculator Plus","i1=&start i2=&avgBkgd operation=[Subtract: i2 = (i1-i2) x k1 + k2] k1=1 k2=&mean create"); rename(start+"_bkgdSub"); stk_bkgd = getTitle(); } close(avgBkgd); selectWindow(stk_bkgd); setVoxelSize(vwidth, vheight, vdepth, vunit); }