// Jan Wisniewski, Experimental Immunology Branch, NCI/NIH, Bethesda MD // This Macro automatically recognizes Z-stacks and and applies MaxIP tiff // converts 3 channel ZEN or ND2 images // saves 16-bit tiff, RGB and composite versions into separate folders // Note: Please enable File/Import/Bio-Formats(Windowless) //create custom table title1 = "Processing Summary"; title2 = "["+title1+"]"; f=title2; run("New... ", "name="+title2+" type=Table"); print(f,"\\Headings:Image\tZ_Number\tMaxInt_Projection?\tTarget/Label\tDisplay_Color\tOriginal_Width_(um)\tOriginal_Height(um)\tCropping_Factor\tContrast_Method\tLower_Limit\tUpper_Limit"); // specify folders Dialog.create("Output and Input Folders"); Dialog.addCheckbox("Save Original Images as 16-bit Tiff", true); items1 = newArray("Yes", "No"); Dialog.addRadioButtonGroup("Are Those Images Multichannel?", items1, 1, 2, "Yes"); items2 = newArray("Yes", "No"); Dialog.addRadioButtonGroup("If YES, Would You Like to Save Individual Channels Separately?", items2, 1, 2, "No"); items3 = newArray("Yes", "No"); Dialog.addRadioButtonGroup("If Z-stacks, Would You Like to Save Them as AVI as well?", items3, 1, 2, "No"); Dialog.setLocation(1300,800); Dialog.show(); tif16=Dialog.getCheckbox(); multi=Dialog.getRadioButton(); selct=Dialog.getRadioButton(); avi=Dialog.getRadioButton(); if(selct=="Yes") {splt=1; } else {splt=0; } if(avi=="Yes") {mov=1; ext=".avi";} else {mov=0; } if(tif16==1) {output2=getDirectory("Choose a Destination for 16-bit Tifs"); } if(splt==1) {output4=getDirectory("_Choose a Destination for Split 16-bit Channels"); } if(mov==1) {outputavi=getDirectory("_Choose_a Destination for AVI Files"); } if(multi=="No") {output1=getDirectory("Choose_a Destination for 8-bit Tifs"); } output3=getDirectory("Choose__a Destination for Montage"); input=getDirectory("Select a Source Directory"); NAMES=getFileList(input); setTool("rectangle"); run("Set Measurements...", "modal min bounding display redirect=None decimal=2"); //define functions function channel_set() {run("Enhance Contrast", "saturated=0.10"); // Dialog.create("Title"); Dialog.addString("Enter Dye and/or Target ID", " "); items = newArray("B&W", "Blue", "Cyan", "Green", "Yellow", "Red", "Magenta"); Dialog.addRadioButtonGroup("Display This Channel as:", items, 1, 7, "B&W"); Dialog.addCheckbox("Exclude This Channel From Color Composite (It will be Shown Separately)", false); Dialog.addCheckbox("Highlight Cell Details (if Tramsmitted Light Image)", false); Dialog.addCheckbox("Use Only Selected Planes instead of MaxIP of Whole Z-Stack", false); Dialog.setLocation(1300,800); Dialog.show(); } function mansc() {run("Brightness/Contrast..."); waitForUser("Adjust Brightness/Contrast Using B&C Tool Before Proceeding !"); Dialog.create("Manual B&C Limits"); Dialog.addNumber("Enter Low Limit:", 0); Dialog.addString("Enter High Limit:", "4095"); Dialog.setLocation(1300,800); Dialog.show(); } function crop_sz() {if(channels>1) {run("Brightness/Contrast..."); waitForUser("Select Relevant Channel and Autoscale Brightness and Contrast Before Proceeding !"); } if(channels==1) { } Dialog.create("Crop_Size"); Dialog.addString("Enter Fraction of the Image (Use 1 for Full Size)", " "); Dialog.setLocation(1300,800); Dialog.show(); } function crop_it() {run("Select All"); run("Scale... ", "x=cr_sz y=cr_sz centered"); waitForUser("Move Rectangle over the Area of Interest Before Proceeding - Do Not Change Aspect Ratio!"); run("Crop"); run("Select None"); print("Cropped image: ", cr_sz, "x", cr_sz); } function autosc() {run("Enhance Contrast", "saturated=0.10"); run("Gamma...", "value=0.99"); run("Measure"); } function autodic() {run("Bandpass Filter...", "filter_large=10 filter_small=3 suppress=None tolerance=5"); run("Enhance Contrast", "saturated=0.35"); run("Gamma...", "value=0.99"); run("Measure"); } function flatstack() {rename("z"); run("Z Project...", "projection=[Max Intensity]"); close("z"); } function stackDefine() {run("Brightness/Contrast..."); waitForUser("Inspect Stack to Decide Which Slices to Use"); Dialog.create("Select Slices"); Dialog.addNumber("Starting Plane:", 0); Dialog.addNumber("How Many Planes to Use Altogether?", 1); items2=newArray("All Channels", "This Channel Only"); Dialog.addRadioButtonGroup("Use Those Planes for:", items2, 1, 2, "This Channel Only"); Dialog.setLocation(1300,800); Dialog.show(); } function stackSelect() {rename("t"); run("Slice Keeper", "first=strt last=rend increment=1"); rename("q"); close("t"); } //open sample image showMessage("Open Sample Image to Test Brightness/Contrast"); open(); rename("y"); getDimensions(width, height, channels, slices, frames); chns=channels; print("CH:", chns, " ", "Z:", slices); // set channels if(chns==1) {if(slices>1) {run("Brightness/Contrast..."); waitForUser("Move to the Central/Best Z-slice and adjust B&C"); } run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_1"); channel_set(); C1=Dialog.getString(); CX1=Dialog.getRadioButton(); if(CX1=="B&W") {CC1="Grays"; } else {CC1=CX1; } CE1=Dialog.getCheckbox(); CT1=Dialog.getCheckbox(); CTC1=Dialog.getCheckbox(); print("Channel_1: ", C1, " Displayed_as: ", CC1, " Exclude?", CE1, " Trans?", CT1, " Center Z?", CTC1); run(CC1); brcon=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon==1) { } else {mansc(); valmin=Dialog.getNumber(); valmax=Dialog.getString(); function sca() {setMinAndMax(valmin, valmax); print("Manual Scaling Range: ", valmin, " to ", valmax); } } close("y"); } if(chns>1) {if(slices>1) {run("Brightness/Contrast..."); waitForUser("Move to the Central/Best Z-slice and adjust B&C"); run("Split Channels"); } else {run("Split Channels"); } selectWindow("C1-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_1"); channel_set(); C1=Dialog.getString(); CX1=Dialog.getRadioButton(); if(CX1=="B&W") {CC1="Grays"; } else {CC1=CX1; } CE1=Dialog.getCheckbox(); CT1=Dialog.getCheckbox(); CTC1=Dialog.getCheckbox(); print("Channel_1: ", C1, " Displayed_as: ", CC1, " Exclude?", CE1, " Trans?", CT1, " Center Z?", CTC1); run(CC1); brcon1=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon1==1) { } else {mansc(); valmin1=Dialog.getNumber(); valmax1=Dialog.getString(); function sca1() {setMinAndMax(valmin1, valmax1); print("Channel_1 Manual Range: ", valmin1, " to ", valmax1); } } close ("C1-y"); selectWindow("C2-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_2"); channel_set(); C2=Dialog.getString(); CX2=Dialog.getRadioButton(); if(CX2=="B&W") {CC2="Grays"; } else {CC2=CX2; } CE2=Dialog.getCheckbox(); CT2=Dialog.getCheckbox(); CTC2=Dialog.getCheckbox(); print("Channel_2: ", C2, " Displayed_as: ", CC2, " Exclude?", CE2, " Trans?", CT2, " Center Z?", CTC2); run(CC2); brcon2=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon2==1) { } else {mansc(); valmin2=Dialog.getNumber(); valmax2=Dialog.getString(); function sca2() {setMinAndMax(valmin2, valmax2); print("Channel_2 Manual Range: ", valmin2, " to ", valmax2); } } close ("C2-y"); } if(chns>2) {selectWindow("C3-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel 3"); channel_set(); C3=Dialog.getString(); CX3=Dialog.getRadioButton(); if(CX3=="B&W") {CC3="Grays"; } else {CC3=CX3; } CE3=Dialog.getCheckbox(); CT3=Dialog.getCheckbox(); CTC3=Dialog.getCheckbox(); print("Channel_3: ", C3, " Displayed_as: ", CC3, " Exclude?", CE3, " Trans?", CT3, " Center Z?", CTC3); run(CC3); brcon3=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon3==1) { } else {mansc(); valmin3=Dialog.getNumber(); valmax3=Dialog.getString(); function sca3() {setMinAndMax(valmin3, valmax3); print("Channel_3 Manual Range: ", valmin3, " to ", valmax3); } } close ("C3-y"); } if(chns>3) {selectWindow("C4-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_4"); channel_set(); C4=Dialog.getString(); CX4=Dialog.getRadioButton(); if(CX4=="B&W") {CC4="Grays"; } else {CC4=CX4; } CE4=Dialog.getCheckbox(); CT4=Dialog.getCheckbox(); CTC4=Dialog.getCheckbox(); print("Channel_4: ", C4, " Displayed_as: ", CC4, " Exclude?", CE4, " Trans?", CT4, " Center Z?", CTC4); run(CC4); brcon4=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon4==1) { } else {mansc(); valmin4=Dialog.getNumber(); valmax4=Dialog.getString(); function sca4() {setMinAndMax(valmin4, valmax4); print("Channel_4 Manual Range: ", valmin4, " to ", valmax4); } } close ("C4-y"); } if(chns>4) {selectWindow("C5-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_5"); channel_set(); C5=Dialog.getString(); CX5=Dialog.getRadioButton(); if(CX5=="B&W") {CC5="Grays"; } else {CC5=CX5; } CE5=Dialog.getCheckbox(); CT5=Dialog.getCheckbox(); CTC5=Dialog.getCheckbox(); print("Channel_5: ", C5, " Displayed_as: ", CC5, " Exclude?", CE5, " Trans?", CT5, " Center Z?", CTC5); run(CC5); brcon5=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon5==1) { } else {mansc(); valmin5=Dialog.getNumber(); valmax5=Dialog.getString(); function sca5() {setMinAndMax(valmin5, valmax5); print("Channel_5 Manual Range: ", valmin5, " to ", valmax5); } } close ("C5-y"); } if(chns>5) {selectWindow("C6-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_6"); channel_set(); C6=Dialog.getString(); CX6=Dialog.getRadioButton(); if(CX6=="B&W") {CC6="Grays"; } else {CC6=CX6; } CE6=Dialog.getCheckbox(); CT6=Dialog.getCheckbox(); CTC6=Dialog.getCheckbox(); print("Channel_6: ", C6, " Displayed_as: ", CC6, " Exclude?", CE6, " Trans?", CT6, " Center Z?", CTC6); run(CC6); brcon6=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon6==1) { } else {mansc(); valmin6=Dialog.getNumber(); valmax6=Dialog.getString(); function sca6() {setMinAndMax(valmin6, valmax6); print("Channel_6 Manual Range: ", valmin6, " to ", valmax6); } } close ("C6-y"); } if(chns>6) {selectWindow("C7-y"); run("Enhance Contrast", "saturated=0.10"); Dialog.create("Channel_7"); channel_set(); C7=Dialog.getString(); CX7=Dialog.getRadioButton(); if(CX7=="B&W") {CC7="Grays"; } else {CC7=CX7; } CE7=Dialog.getCheckbox(); CT7=Dialog.getCheckbox(); CTC7=Dialog.getCheckbox(); print("Channel_7: ", C7, " Displayed_as: ", CC7, " Exclude?", CE7, " Trans?", CT7, " Center Z?", CTC7); run(CC7); brcon7=getBoolean("Is Automatic Brightness/Contrast OK?", "Yes", "Try Manual"); if(brcon7==1) { } else {mansc(); valmin7=Dialog.getNumber(); valmax7=Dialog.getString(); function sca7() {setMinAndMax(valmin7, valmax7); print("Channel_7 Manual Range: ", valmin7, " to ", valmax7); } } close ("C7-y"); } //extra info Dialog.create("Additional Settings"); items = newArray("Yes", "No"); Dialog.addRadioButtonGroup("Would You Like to Crop Individual Images?", items, 1, 2, "No"); Dialog.addChoice("Montage Size reduction", newArray("Full Size", "0.5", "0.33", "0.25"), "0.5"); Dialog.addNumber("Font Size", 25); Dialog.addString("Scale Bar (microns)", "10"); //Dialog.addCheckbox("Exclude DIC/BF Channel from Color-Composite Panel", false); Dialog.setLocation(1300,800); Dialog.show(); imcrp=Dialog.getRadioButton; if(imcrp=="Yes") {crp=0; } else{crp=1; } mosrdx=Dialog.getChoice(); if(mosrdx=="Full size") {rdx=1; } else{rdx=mosrdx; } fnt=Dialog.getNumber(); fntbar=2*fnt/3; lngt=Dialog.getString; //transm=Dialog.getCheckbox(); print("Image Cropping: ", imcrp); print("Montage Size Reduction: ", mosrdx); print("Font_Size: ", fnt, " Scale_Bar: ", lngt, "microns "); //if(transm==1) {if(channels>1) {print("Transmitted Light Image Excluded from Color-Composite"); } // else { // } // } if(chns>1) {if(CE1==1) {print(C1, " Excluded from Color-Composite"); } if(CE2==1) {print(C2, " Excluded from Color-Composite"); } } if(chns>2) {if(CE3==1) {print(C3, " Excluded from Color-Composite"); } } if(chns>3) {if(CE4==1) {print(C4, " Excluded from Color-Composite"); } } if(chns>4) {if(CE5==1) {print(C5, " Excluded from Color-Composite"); } } if(chns>5) {if(CE6==1) {print(C6, " Excluded from Color-Composite"); } } if(chns>6) {if(CE7==1) {print(C7, " Excluded from Color-Composite"); } } print(" "); print("Images:"); print(" "); //process images for (i=0; i1) {if(mov==1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+ext+"]"); } } } rename("x"); if(chns>1) {if(splt==1) {run("Duplicate...", "duplicate"); rename("u"); run("Split Channels"); selectWindow("C1-u"); run(CC1); saveAs("Tiff", output4+ttl+"-"+CC1); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=5 save=["+outputavi+ttl+CC1+ext+"]");} } close(); selectWindow("C2-u"); run(CC2); saveAs("Tiff", output4+ttl+"-"+CC2); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC2+ext+"]");} } close(); if(chns>2) { selectWindow("C3-u"); run(CC3); saveAs("Tiff", output4+ttl+"-"+CC3); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC3+ext+"]");} } close(); } if(chns>3) { selectWindow("C4-u"); run(CC4); saveAs("Tiff", output4+ttl+"-"+CC4); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC4+ext+"]");} } close(); } if(chns>4) { selectWindow("C5-u"); run(CC5); saveAs("Tiff", output4+ttl+"-"+CC5); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC5+ext+"]");} } close(); } if(chns>5) { selectWindow("C6-u"); run(CC6); saveAs("Tiff", output4+ttl+"-"+CC6); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC6+ext+"]");} } close(); } if(chns>6) { selectWindow("C7-u"); run(CC7); saveAs("Tiff", output4+ttl+"-"+CC7); if(mov==1) {if(slices>1) {run("AVI... ", "compression=None frame=10 save=["+outputavi+ttl+CC7+ext+"]");} } close(); } } } //process channel 1 run("Enhance Contrast", "saturated=0.10"); if(crp==1) {print("Full image"); cr_sz="Full"; } else { crop_sz(); cr_sz=Dialog.getString(); if(cr_sz==1) {print("Full image"); cr_sz="Full"; } else {crop_it(); } } if(chns==1) { labl=C1; colr=CC1; if(slices>1) {print("# of Z-slices: ", slices); if(CTC1==1) {stackDefine(); strt=Dialog.getNumber(); rnge=Dialog.getNumber(); rend=strt+rnge-1; some=Dialog.getRadioButton(); if(some=="All Channels") {chce=1; } else {chce=0; } print(strt, rnge, rend, chce); stackSelect(); maxip="selected"; } else {flatstack(); rename("x"); maxip="all";} } else { maxip="n/a"; } if(CT1=="Yes") {autodic(); minval=Table.getString("Min"); maxval=Table.getString("Max"); print("Auto-scaled: ", minval, " ", maxval, " FFT "); meth="Auto"; l_lim=minval; u_lim=maxval; } else {if (brcon==1) {autosc(); minval=Table.getString("Min"); maxval=Table.getString("Max"); print("Auto-scaled: ", minval, " ", maxval); meth="Auto"; l_lim=minval; u_lim=maxval; } else {sca(); meth="Manual"; l_lim=valmin; u_lim=valmax; } } if(crp==0) { if(cr_sz==1) { } else {rename("v"); enl=1/cr_sz; run("Scale...", "x=enl y=enl width=w height=h interpolation=Bilinear create"); print("Resampled to Original Display Size"); close("v"); rename("x"); } } else { } run(CC1); run("Apply LUT"); run("8-bit"); run("Scale Bar...", "width=lngt height=4 font=fntbar color=White background=None location=[Upper Right] bold overlay"); run("Flatten"); saveAs("Tiff", output1+NAMES[i]); close(); selectWindow("Processing Summary"); print(f,ttl+"\t"+slices+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+wdt+"\t"+hgt+"\t"+cr_sz+"\t"+meth+"\t"+l_lim+"\t"+u_lim); close("x"); } if(chns>1) {run("Split Channels"); selectWindow("C1-x"); labl=C1; colr=CC1; if(slices>1) {print("# of Z-slices: ", slices); if(CTC1==1) {stackDefine(); strt=Dialog.getNumber(); rnge=Dialog.getNumber(); rend=strt+rnge-1; print(strt, rnge, rend); stackSelect(); maxip="selected"; } else {flatstack(); rename("C1-x"); maxip="all";} } else { maxip="n/a"; } if(CT1==1) {autodic(); minval1=Table.getString("Min"); maxval1=Table.getString("Max"); print("Channel_1 Auto-scaled: ", minval1, " ", maxval1, " FFT "); meth="Auto"; l_lim=minval1; u_lim=maxval1; } else {if (brcon1==1) {autosc(); minval1=Table.getString("Min"); maxval1=Table.getString("Max"); print("Channel_1 Auto-scaled: ", minval1, " ", maxval1); meth="Auto"; l_lim=minval1; u_lim=maxval1; } else {sca1(); meth="Manual"; l_lim=valmin1; u_lim=valmax1; } } run(CC1); run("Apply LUT"); run("RGB Color"); rename(C1); selectWindow("Processing Summary"); print(f,ttl+"\t"+slices+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+wdt+"\t"+hgt+"\t"+cr_sz+"\t"+meth+"\t"+l_lim+"\t"+u_lim); selectWindow("C2-x"); labl=C2; colr=CC2; if(slices>1) {print("# of Z-slices: ", slices); if(CTC2==1) {stackDefine(); strt=Dialog.getNumber(); rnge=Dialog.getNumber(); rend=strt+rnge-1; print(strt, rnge, rend); stackSelect(); maxip="selected"; } else {flatstack(); rename("C2-x"); maxip="all";} } else { maxip="n/a"; } if(CT2==1) {autodic(); minval2=Table.getString("Min"); maxval2=Table.getString("Max"); print("Channel_2 Auto-scaled: ", minval2, " ", maxval2, " FFT "); meth="Auto"; l_lim=minval2; u_lim=maxval2; } else {if (brcon2==1) {autosc(); minval2=Table.getString("Min"); maxval2=Table.getString("Max"); print("Channel_2 Auto-scaled: ", minval2, " ", maxval2); meth="Auto"; l_lim=minval2; u_lim=maxval2; } else {sca2(); meth="Manual"; l_lim=valmin2; u_lim=valmax2; } } run(CC2); run("Apply LUT"); run("RGB Color"); rename(C2); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } if(chns>2) {selectWindow("C3-x"); labl=C3; colr=CC3; if(slices>1) {print("# of Z-slices: ", slices); if(CTC3==1) {stackDefine(); stackSelect(); maxip="selected"; } else {flatstack(); rename("C3-x"); maxip="all";} } else { maxip="n/a"; } if(CT3==1) {autodic(); minval3=Table.getString("Min"); maxval3=Table.getString("Max"); print("Channel_3 Auto-scaled: ", minval3, " ", maxval3, " FFT "); meth="Auto"; l_lim=minval3; u_lim=maxval3; } else {if (brcon3==1) {autosc(); minval3=Table.getString("Min"); maxval3=Table.getString("Max"); print("Channel_3 Auto-scaled: ", minval3, " ", maxval3); meth="Auto"; l_lim=minval3; u_lim=maxval3; } else {sca3(); meth="Manual"; l_lim=valmin3; u_lim=valmax3; } } run(CC3); run("Apply LUT"); run("RGB Color"); rename(C3); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } if(chns>3) {selectWindow("C4-x"); labl=C4; colr=CC4; if(slices>1) {print("# of Z-slices: ", slices); if(CTC4==1) {stackDefine(); stackSelect(); maxip="selected"; } else {flatstack(); rename("C4-x"); maxip="all";} } else { maxip="n/a"; } if(CT4==1) {autodic(); minval4=Table.getString("Min"); maxval4=Table.getString("Max"); print("Channel_4 Auto-scaled: ", minval4, " ", maxval4, " FFT "); meth="Auto"; l_lim=minval4; u_lim=maxval4; } else { if (brcon4==1) {autosc(); minval4=Table.getString("Min"); maxval4=Table.getString("Max"); print("Channel_4 Auto-scaled: ", minval4, " ", maxval4); meth="Auto"; l_lim=minval4; u_lim=maxval4; } else {sca4(); meth="Manual"; l_lim=valmin4; u_lim=valmax4; } } run(CC4); run("Apply LUT"); run("RGB Color"); rename(C4); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } if(chns>4) {selectWindow("C5-x"); labl=C5; colr=CC5; if(slices>1) {print("# of Z-slices: ", slices); if(CTC5==1) {stackDefine(); stackSelect(); maxip="selected"; } else {flatstack(); rename("C5-x"); maxip="all";} } else { maxip="n/a"; } if(CT5==1) {autodic(); minval5=Table.getString("Min"); maxval5=Table.getString("Max"); print("Channel_5 Auto-scaled: ", minval5, " ", maxval5, " FFT "); meth="Auto"; l_lim=minval5; u_lim=maxval5; } else { if (brcon5==1) {autosc(); minval5=Table.getString("Min"); maxval5=Table.getString("Max"); print("Channel_5 Auto-scaled: ", minval5, " ", maxval5); meth="Auto"; l_lim=minval5; u_lim=maxval5; } else {sca5(); meth="Manual"; l_lim=valmin5; u_lim=valmax5; } } run(CC5); run("Apply LUT"); run("RGB Color"); rename(C5); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } if(chns>5) {selectWindow("C6-x"); labl=C6; colr=CC6; if(slices>1) {print("# of Z-slices: ", slices); if(CTC6==1) {stackDefine(); stackSelect(); maxip="selected"; } else {flatstack(); rename("C6-x"); maxip="all";} } else { maxip="n/a"; } if(CT6==1) {autodic(); minval6=Table.getString("Min"); maxval6=Table.getString("Max"); print("Channel_6 Auto-scaled: ", minval6, " ", maxval6, " FFT "); meth="Auto"; l_lim=minval6; u_lim=maxval6; } else { if (brcon6==1) {autosc(); minval6=Table.getString("Min"); maxval6=Table.getString("Max"); print("Channel_6 Auto-scaled: ", minval6, " ", maxval6); meth="Auto"; l_lim=minval6; u_lim=maxval6; } else {sca6(); meth="Manual"; l_lim=valmin6; u_lim=valmax6; } } run(CC6); run("Apply LUT"); run("RGB Color"); rename(C6); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } if(chns>6) {selectWindow("C7-x"); labl=C7; colr=CC7; if(slices>1) {print("# of Z-slices: ", slices); if(CTC7==1) {stackDefine(); stackSelect(); maxip="selected"; } else {flatstack(); rename("C7-x"); maxip="YES";} } else { maxip="n/a"; } if(CT7==1) {autodic(); minval7=Table.getString("Min"); maxval7=Table.getString("Max"); print("Channel_7 Auto-scaled: ", minval7, " ", maxval7, " FFT "); meth="Auto"; l_lim=minval7; u_lim=maxval7; } else { if (brcon7==1) {autosc(); minval7=Table.getString("Min"); maxval7=Table.getString("Max"); print("Channel_7 Auto-scaled: ", minval7, " ", maxval7); meth="Auto"; l_lim=minval7; u_lim=maxval7; } else {sca7(); meth="Manual"; l_lim=valmin7; u_lim=valmax7; } } run(CC7); run("Apply LUT"); run("RGB Color"); rename(C7); selectWindow("Processing Summary"); print(f," "+"\t"+" "+"\t"+maxip+"\t"+labl+"\t"+colr+"\t"+" "+"\t"+" "+"\t"+" "+"\t"+meth+"\t"+l_lim+"\t"+u_lim); } print(" "); //if(channels>1) {if(transm==1) {run("Images to Stack", "name=All title=[] use keep"); // selectWindow("DIC/BF"); // close(); // run("Images to Stack", "name=Comp title=[] use"); // run("Z Project...", "projection=[Max Intensity]"); // rename(NAMES[i]); // saveAs("Tiff", output1+NAMES[i]); // selectWindow("Comp"); // close(); // selectWindow("All"); // run("Stack to Images"); // run("Images to Stack", "name=Stack title=[] use");} if(chns>1) {run("Images to Stack", "name=All title=[] use keep"); if(CE1==1) {close(C1); } if(CE2==1) {close(C2); } if(chns>2) {if(CE3==1) {close(C3); } } if(chns>3) {if(CE4==1) {close(C4); } } if(chns>4) {if(CE5==1) {close(C5); } } if(chns>5) {if(CE6==1) {close(C6); } } if(chns>6) {if(CE7==7) {close(C7); } } run("Images to Stack", "name=Comp title=[] use"); run("Z Project...", "projection=[Max Intensity]"); rename(NAMES[i]); // saveAs("Tiff", output1+NAMES[i]); // selectWindow("Comp"); // close(); selectWindow("All"); run("Stack to Images"); run("Images to Stack", "name=Stack title=[] use"); getDimensions(width, height, channels, slices, frames); if(slices<4) {rws=1; clm=slices; } else {rws=0.75+slices/4; rows=rws; clm=4; } // else {run("Images to Stack", "name=Stack title=[] use"); // run("Z Project...", "projection=[Max Intensity]"); // rename(NAMES[i]); // saveAs("Tiff", output1+NAMES[i]); // selectWindow("Stack"); // run("Stack to Images"); // run("Images to Stack", "name=Stack title=[] use"); } //if(channels==2) {run("Make Montage...", "columns=3 rows=1 scale=rdx border=2 font=fnt label"); } //if(channels==3) {run("Make Montage...", "columns=2 rows=2 scale=rdx border=2 font=fnt label"); } //if(channels==4) {run("Make Montage...", "columns=3 rows=2 scale=rdx border=2 font=fnt label"); } //if(channels==5) {run("Make Montage...", "columns=3 rows=1 scale=rdx border=2 font=fnt label"); } //if(channels==6) {run("Make Montage...", "columns=4 rows=2 scale=rdx border=2 font=fnt label"); } //if(channels==7) {run("Make Montage...", "columns=4 rows=2 scale=rdx border=2 font=fnt label"); } run("Make Montage...", "columns=clm rows=rws scale=rdx border=2 font=fnt label"); run("Scale Bar...", "width=lngt height=4 font=fntbar color=White background=None location=[Upper Right] bold overlay"); run("Flatten"); saveAs("Tiff", output3+NAMES[i]); close(); close(); close(); close(); } if(chns==1) {LIST=getFileList(output1); for (i=0; i