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.
//IMB Macro Splash screen (Do not remove this acknowledgement)
scripttitle="Nuclei and Cytoplasm Measuring Script";
version="1.5";
versiondate="05/09/2019";
description="Details:
This script takes 2D images of Zebrafish and finds the nuclei for measuring.
It then converts all Green labelling (ch1) into 32-bit, "
+"NaN background, before measuring the nuclei mean intensity.
A region around the nuclei is measured by creating a banding selection of a user defined distance. "
+"
Output files are saved into a directory called results"
print("FIJI Macro: "+scripttitle); //Prints script title to log window
print("Version: "+version+" ("+versiondate+")");
//Prints script version & version date to log window
print("ACRF: Cancer Biology Imaging Facility");
//Prints script acknowledgement to log window
print("By Nicholas Condon (2018) n.condon@uq.edu.au")
//Prints script acknowledgement to log window
print("");
//Prints linespace to log window
//IMB script dialog box (Do not remove this acknowledgement).
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+""
+"
"
+" "
+"");
Dialog.create("Choosing your working directory."); //Directory Warning and Instruction panel
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) ");
Dialog.addMessage("Take note of your file extension (eg .tif, .czi)");
Dialog.show();
run("Set Measurements...", "area mean standard median display redirect=None decimal=3"); //Defines the measurements required for this script
run("Clear Results"); //Clears any results from the results window
roiManager("Reset"); //Deletes any ROIs from the manager
path = getDirectory("Choose Source Directory "); //Variable for directory
list = getFileList(path); //Variable for file list
xlsVar = 2; //Variable for excel row calculations (excludes title row)
ext = ".tif"; //Variable for file exension
Dialog.create("Choosing your settings"); //Dialogue requesting user input settings
Dialog.addString("File Extension:", ext); //Dialogue requesting file extension
Dialog.addMessage("(For example .czi .lsm .nd2 .lif .ims)");
Dialog.addNumber("Banding Distance (Pixels): ", 1.5) //Dialogue requesting band spacing size
Dialog.addCheckbox("Run in batch mode (Background)", true); //Dialogue toggle for batch (background mode)
Dialog.show();
ext = Dialog.getString(); //VAR = file extensino [string]
batch=Dialog.getCheckbox(); //VAR = batch mode status [boolean]
band = Dialog.getNumber(); //VAR = size of band [number]
print("********** Paramaters **********"); //Prints user settings to the log window
print("Working directory: "+path); //Prints directory location to the log window
print("Chosen file extension: "+ext); //Prints chosen file extension to the log window
print("Banding Size (Pixels): "+band); //Prints band size to the log window
if (batch==1){ //Batch mode conditional run
setBatchMode(true); //Turns on background mode
print("Running In batch mode."); //Prints to the log that batch mode is enabled
}
getDateAndTime(year, month, week, day, hour, min, sec, msec); //Obtaining date and time
print("Script Run Date: "+day+"/"+(month+1)+"/"+year+" Time: " +hour+":"+min+":"+sec); //Prints the script run time and date to the log window
start = getTime(); //Starts the script timer
print(""); //Prints a linespace to the log window
resultsDir = path+"Results"+year+"-"+(month+1)+"-"+day+"__"+hour+"."+min+"."+sec+"/"; //VAR = location of the results directory within the working directory [string]
File.makeDirectory(resultsDir); //Creates an output directory with the name using the VAR=resultsDir
summaryFile = File.open(resultsDir+"Results.xls"); //Creates a results file named Results.xls
print(summaryFile,"Filename \t Nuclei # \t Nuclei Intensity \t Cytoplasm Intensity \t Number of Nuclei \t Cyto/Nuclei \t Nuclei/Cyto");
//Prints title colunms into Results.xls
for (z=0; z= 1) { //Loop for if one of more nuclei was found
nucI = newArray(numNuc); //ARRAY = arrary for nuclei intensity (number of nuclei long)
cytoI = newArray(numNuc); //ARRAY = arrary for cytoplasmic intensity (number of nuclei long)
selectWindow("green32"); //Selects the cytoplasmic window (green32)
roiManager("Measure"); //Measures every nuclei found as defined by ROI list
for (r=0; r 0){close();} //Closes any remaining open windows
print("All outputs saved and closed"); //Prints all windows closed to the log window
print("");} //Prints a line space to the log window
roiManager("reset"); //Removes any ROIs from the ROI manager
}} //End of all file loops
print("Batch Completed");print("Total Runtime was:");print((getTime()-start)/1000); //Prints run stats to the log window
selectWindow("Log"); //Selects the log window
saveAs("Text", resultsDir+"Log.txt"); //Saves the log window
title = "Batch Completed"; msg = "Put down that coffee! Your job is finished"; //VARs = Dialog window text [sting]
waitForUser(title, msg); //Displays dialogue to user
//End of Script