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="Z Projection and AVI output";
version="1.2";
versiondate="14/09/2018";
description="Details:
This script takes 3D/4D images and Z-projects (Maximum, Minimum, Average, Sum Slices) them as well as outputting .tif and/or .avi. Files are filtered by their extension (.czi, .lsm etc) and are opened via Bioformats importer.
Files to be processed should be within their own directory. Processed images/movies will be placed into a subdirectory called (projectiontype)_Results_(Date&time).
This script can be used to convert files to .tif by selecting 'No Projection' and 'Save .tif output'.
A log file (.txt) will be saved within this directory for recording the processing steps chosen"
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+" Version Date: "+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("");
print("Script Run Date: "+day+"/"+(month+1)+"/"+year+" Time: " +hour+":"+min+":"+sec);
//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 directory locations etc
run("Clear Results");
path = getDirectory("Choose Source Directory ");
list = getFileList(path);
//file extension selector
ext = ".tif";
Dialog.create("Parameters");
Dialog.addMessage("Select the processing steps you would like to run:")
Dialog.addMessage(" ");
Dialog.addChoice("Run Z-Projection", newArray("Max Intensity", "Min Intensity", "Average Intensity", "Sum Slices", "No Projection"));
Dialog.addString("Choose your file extension:", ext);
Dialog.addMessage("(For example .czi .lsm .nd2 .lif .ims)");
Dialog.addCheckbox("Re-set Brightness & Contrast", true);
Dialog.addCheckbox("Save AVI movie output", false);
Dialog.addCheckbox("Save .tif output", true);
Dialog.addMessage(" ");
Dialog.addCheckbox("Run in batch mode (Background)", true);
Dialog.show();
projectiontype = Dialog.getChoice();
autoscale = Dialog.getCheckbox();
avi = Dialog.getCheckbox();
tif = Dialog.getCheckbox();
ext = Dialog.getString();
batch=Dialog.getCheckbox();
print("**** Parameters ****")
print("Projection Method: "+projectiontype);
print("File extension: "+ext);
if (autoscale == 1) print("Reset Brightness & Contrast: ON");
if (autoscale == 0) print("Reset Brightness & Contrast: OFF");
if (avi == 1) print("Avi output: ON");
if (avi == 0) print("Avi output: OFF");
if (tif == 1) print(".tif output: ON");
if (tif == 0) print(".tif output: OFF");
//batch mode conditional run
if (batch==1){
setBatchMode(true);
print("Running in batch mode.");
}
print("");
print("");
//AVI parameter box
if (avi==1){
fps=10;
Dialog.create("Avi Parameters");
Dialog.addMessage("Select the AVI output parameters")
Dialog.addMessage(" ");
Dialog.addChoice("Compression", newArray("None", "PNG", "JPEG"));
Dialog.addString("Frame Rate (fps):", fps);
Dialog.show();
compression = Dialog.getChoice();
fps = Dialog.getString();
}
//Setting up output file directory
getDateAndTime(year, month, week, day, hour, min, sec, msec);
start = getTime();
resultsDir = path+projectiontype+"_Results__"+year+"-"+month+1+"-"+day+"_at_"+hour+"."+min+"/";
File.makeDirectory(resultsDir);
//File opening loop
for (z=0; z