Commit b306deb4 authored by Stephan Janosch's avatar Stephan Janosch

inital checking

parents
/*
* Author: Stephan Janosch, janosch@mpi-cbg.de, ORCID
*
*/
#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix
#@ String (label = "File stiching indicator", value = "_stitch_") filenameStitchCondition
// See also Process_Folder.py for a version of this code
// in the Python scripting language.
print("\\Clear");
processFolder(input);
print("Macro done!");
return;
// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
//skip folder Notes
if ( endsWith(input, "Notes/") )
return;
list = getFileList(input);
list = Array.sort(list);
print("Processing Folder: " + input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + File.separator + list[i]))
{
processFolder(input + File.separator + list[i]);
}
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
//don't process files not intended for stitching
if (! matches(file, ".*"+filenameStitchCondition+".*"))
{
//print("Ignoring: " + input + File.separator + file);
return;
}
//be nice, don't redo Files already stitched
doneFileName=input+File.separator+replace(file, suffix, "")+".macrodone";
if ( File.exists(doneFileName) )
{
print("Skipping: "+doneFileName);
return;
}
print("Processing: " + input + File.separator + file);
pathElements = split(input,File.separator);
date = split(pathElements[2], " ");
date=date[0];
specimen = pathElements[3];
filename_without_suffix = replace(file, suffix, "");
filename_without_suffix = replace(filename_without_suffix, filenameStitchCondition, "");
//print(input);
//print(filename_without_suffix);
//print(specimen);
//print(date);
//create dataset
run("Define dataset ...", "define_dataset=[Automatic Loader (Bioformats based)] exclude=10 bioformats_series_are?=Tiles bioformats_channels_are?=Channels move_tiles_to_grid_(per_angle)?=[Do not move Tiles to Grid (use Metadata if available)] how_to_load_images=[Load raw data virtually (with caching)] check_stack_sizes " +
"project_filename="+filename_without_suffix+".xml " +
"path=["+input+file+"] "+
"dataset_save_path=["+input+"]");
xmlfile = input+filename_without_suffix+".xml";
run("Calculate pairwise shifts ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] "+
"select=["+xmlfile+"] ");
run("Filter pairwise shifts ...", "filter_by_link_quality min_r=0.7 max_r=1 max_shift_in_x=0 max_shift_in_y=0 max_shift_in_z=0 max_displacement=0 "+
"select=["+xmlfile+"] ");
run("Optimize globally and apply shifts ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] relative=2.500 absolute=3.500 global_optimization_strategy=[Two-Round using Metadata to align unconnected Tiles] fix_group_0-0 " +
"select=["+xmlfile+"]" );
outputPath = output+File.separator+specimen+File.separator+date+File.separator+filename_without_suffix+File.separator;
File.makeDirectory(output+File.separator+specimen);
File.makeDirectory(output+File.separator+specimen+File.separator+date);
File.makeDirectory(output+File.separator+specimen+File.separator+date+File.separator+filename_without_suffix);
print("created: "+outputPath);
run("Fuse dataset ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] bounding_box=[Currently Selected Views] downsampling=1 pixel_type=[16-bit unsigned integer] interpolation=[Linear Interpolation] image=[Precompute Image] blend preserve_original produce=[Each timepoint & channel] fused_image=[Save as (compressed) TIFF stacks] lossless "+
"select=["+xmlfile+"] "+
"output_file_directory=["+outputPath+"] ");
donefile = File.open(doneFileName);
File.close(donefile)
}
/*
* Author: Stephan Janosch, janosch@mpi-cbg.de, ORCID
*
*/
#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix
#@ String (label = "File stiching indicator", value = "_stitch_") filenameStitchCondition
// See also Process_Folder.py for a version of this code
// in the Python scripting language.
print("\\Clear");
processFolder(input);
print("Macro done");
return;
// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
//skip folder Notes
if ( endsWith(input, "Notes/") )
return;
list = getFileList(input);
list = Array.sort(list);
print("Processing Folder: " + input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + File.separator + list[i]))
{
processFolder(input + File.separator + list[i]);
}
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
//don't process files not intended for stitching
if (! matches(file, ".*"+filenameStitchCondition+".*"))
{
//print("Ignoring: " + input + File.separator + file);
return;
}
//be nice, don't redo Files already stitched
doneFileName=input+File.separator+replace(file, suffix, "")+".macrodone";
if ( File.exists(doneFileName) )
{
print("Skipping: "+doneFileName);
return;
}
print("Processing: " + input + File.separator + file);
pathElements = split(input,File.separator);
date = split(pathElements[1], " ");
date=date[0];
specimen = pathElements[2];
filename_without_suffix = replace(file, suffix, "");
filename_without_suffix = replace(filename_without_suffix, filenameStitchCondition, "");
//print(input);
//print(filename_without_suffix);
//print(specimen);
//print(date);
//create dataset
run("Define dataset ...", "define_dataset=[Automatic Loader (Bioformats based)] exclude=10 bioformats_series_are?=Tiles bioformats_channels_are?=Channels move_tiles_to_grid_(per_angle)?=[Do not move Tiles to Grid (use Metadata if available)] how_to_load_images=[Load raw data virtually (with caching)] check_stack_sizes " +
"project_filename="+filename_without_suffix+".xml " +
"path=["+input+file+"] "+
"dataset_save_path=["+input+"]");
xmlfile = input+filename_without_suffix+".xml";
run("Calculate pairwise shifts ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] "+
"select=["+xmlfile+"] ");
run("Filter pairwise shifts ...", "filter_by_link_quality min_r=0.7 max_r=1 max_shift_in_x=0 max_shift_in_y=0 max_shift_in_z=0 max_displacement=0 "+
"select=["+xmlfile+"] ");
run("Optimize globally and apply shifts ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] relative=2.500 absolute=3.500 global_optimization_strategy=[Two-Round using Metadata to align unconnected Tiles] fix_group_0-0 " +
"select=["+xmlfile+"]" );
outputPath = output+File.separator+specimen+File.separator+date+File.separator+filename_without_suffix+File.separator;
File.makeDirectory(output+File.separator+specimen);
File.makeDirectory(output+File.separator+specimen+File.separator+date);
File.makeDirectory(output+File.separator+specimen+File.separator+date+File.separator+filename_without_suffix);
print("created: "+outputPath);
run("Fuse dataset ...", "process_angle=[All angles] process_channel=[All channels] process_illumination=[All illuminations] process_tile=[All tiles] process_timepoint=[All Timepoints] bounding_box=[Currently Selected Views] downsampling=2 pixel_type=[16-bit unsigned integer] interpolation=[Linear Interpolation] image=[Precompute Image] blend preserve_original produce=[Each timepoint & channel] fused_image=[Save as (compressed) TIFF stacks] lossless "+
"select=["+xmlfile+"] "+
"output_file_directory=["+outputPath+"] ");
donefile = File.open(doneFileName);
File.close(donefile)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment