print("\\Clear")
// MIT License
// Copyright (c) 2018 Nicholas Condon n.condon@uq.edu.au
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
scripttitle="IMB_Dual-Projection-Type-Script";
version="0.6";
versiondate="13/08/2018";
description="Details:
Takes 1/2/3/4 Channel images, and lets user decide on which channel is brightfield/fluorescence and projects them according to the users input. Brightfield images will be minimum projected, while fluorescence channel projection type can be selected.
Files to be processed should be in their own directory, processed images will be placed into a subdirectory called Projected_Results_(date and time)"
showMessage("Institute for Molecular Biosciences ImageJ Script", ""
+"
ACRF: Cancer Biology Imaging Facility
+"The Institute for Molecular Bioscience
The University of Queensland
+"ACRF: Cancer Biology Imaging Facility<\h4>"
+"ImageJ Script Macro: "+scripttitle+"
"
+"Version: "+version+" ("+versiondate+")"
+"Created by Nicholas Condon
"
+" contact n.condon@uq.edu.au \n "
+" Available for use/modification/sharing under the "+"MIT License<\h4> "
+" <\h3>"
+""+description+"."
+"
"
+" "
+"");
//Log Window Title and Acknowledgement
print("");
print("FIJI Macro: "+scripttitle);
print("Version: "+version+" ("+versiondate+")");
print("ACRF: Cancer Biology Imaging Facility");
print("By Nicholas Condon (2018) n.condon@uq.edu.au")
print("");
getDateAndTime(year, month, week, day, hour, min, sec, msec);
print("Script Run Date: "+day+"/"+(month+1)+"/"+year+" Time: " +hour+":"+min+":"+sec);
print("");
//Directory Warning and Instruction panel
Dialog.create("Choosing your working directory.");
Dialog.addMessage("Use the next window to navigate to the directory of your images.");
Dialog.addMessage("(Note a sub-directory will be made within this folder for output files) ");
Dialog.addMessage("Take note of your file extension (eg .tif, .czi)");
Dialog.show();
//Setting up File directory locations
run("Clear Results");
path = getDirectory("Choose Source Directory ");
list = getFileList(path);
setBatchMode(true);
//Main Parameters Dialog
ext = ".czi";
Dialog.create("Parameters");
Dialog.addMessage("Select which channel is Fluorescence or brightfield.")
Dialog.addMessage("Select No Data for any channels not used.")
Dialog.addChoice("Ch1", newArray("Fluorescence", "Brightfield", "No Data"));
Dialog.addChoice("Ch2", newArray("Fluorescence", "Brightfield", "No Data"));
Dialog.addChoice("Ch3", newArray("Fluorescence", "Brightfield", "No Data"));
Dialog.addChoice("Ch4", newArray("Fluorescence", "Brightfield", "No Data"));
Dialog.addChoice("Run Z-Projection for Fluoresence Images", newArray("Max Intensity", "Average Intensity", "Sum Slices"));
Dialog.addMessage("Note: Brightfield Images will be 'Minimum Projected");
Dialog.addMessage(" ");
Dialog.addString("Choose your file extension:", ext);
Dialog.addMessage("(For example .czi .lsm .nd2 .lif .ims)");
Dialog.addCheckbox("Add Scale Bar?", false);
Dialog.addCheckbox("Convert to RGB?", false);
Dialog.addCheckbox("Re-Merge Channels?",false);
Dialog.show();
ext = Dialog.getString();
ch1 = Dialog.getChoice();
ch2 = Dialog.getChoice();
ch3 = Dialog.getChoice();
ch4 = Dialog.getChoice();
projectiontype=Dialog.getChoice();
scale = Dialog.getCheckbox();
rgb=Dialog.getCheckbox();
merge=Dialog.getCheckbox();
//Printing Parameters to log file
print("**** Parameters ****")
print("Projection Method: "+projectiontype);
print("File extension: "+ext);
print("Ch1 Image Type = "+ch1);
print("Ch2 Image Type = "+ch2);
print("Ch3 Image Type = "+ch3);
print("Ch4 Image Type = "+ch4);
if (scale == 1) print("Scale Bar: ON");
if (scale == 0) print("Scale Bar: OFF");
if (rgb == 1) print("RGB Conversion: ON");
if (rgb == 0) print("RGB Conversion: OFF");
if (merge == 1) print("Channel Merge: ON");
if (merge == 0) print("Channel Merge: OFF");
//Scale Bar Parameter dialog
if (scale==1){
Dialog.create("Scale Bar Parameters");
if(ext == ".tif") Dialog.addMessage("WARNING: Make sure your file has the correct metadata for scale");
Dialog.addMessage("Choose the following parameters for your scale bar");
Dialog.addString("Line width (microns):", 10);
Dialog.addString("Line height:", 3);
Dialog.addChoice("Colour", newArray("White", "Black", "Yellow"));
Dialog.addChoice("Location", newArray("Lower Right", "Lower Left", "Upper Right", "Upper Left"));
Dialog.show();
lwidth=Dialog.getString();
lheight=Dialog.getString();
colour=Dialog.getChoice();
location=Dialog.getChoice();
//Printing scale bar parameters into log file
print("Scale Line Width: "+lwidth);
print("Scale Line Height: "+lheight);
print("Scale Line Colour: "+colour);
print("Scale Line Position: "+location);
}
//File Directory Section
start = getTime();
resultsDir = path+"Projected_Results_"+year+"-"+(month+1)+"-"+day+"__"+hour+"."+min+"."+sec+"/";
File.makeDirectory(resultsDir);
print("Working Directory Location: "+path);
print("");
//Running Loop
for (z=0; z