From 5111213d42fcc488bf4fde676caf94e84982a4cc Mon Sep 17 00:00:00 2001 From: Peter Steinbach <steinbac@mpi-cbg.de> Date: Mon, 18 May 2015 11:01:43 +0200 Subject: [PATCH] added Christopher Schmied's pipeline to ghub repo --- spim_registration/timelapse/Snakefile | 157 ++++++++++++++++++ spim_registration/timelapse/cluster.json | 22 +++ .../timelapse/deconvolution_CPU.bsh | 135 +++++++++++++++ .../timelapse/deconvolution_GPU.bsh | 143 ++++++++++++++++ spim_registration/timelapse/registration.bsh | 156 +++++++++++++++++ spim_registration/timelapse/tomancak.json | 88 ++++++++++ spim_registration/timelapse/transform.bsh | 56 +++++++ spim_registration/timelapse/xml_merge.bsh | 34 ++++ 8 files changed, 791 insertions(+) create mode 100644 spim_registration/timelapse/Snakefile create mode 100644 spim_registration/timelapse/cluster.json create mode 100644 spim_registration/timelapse/deconvolution_CPU.bsh create mode 100644 spim_registration/timelapse/deconvolution_GPU.bsh create mode 100644 spim_registration/timelapse/registration.bsh create mode 100644 spim_registration/timelapse/tomancak.json create mode 100644 spim_registration/timelapse/transform.bsh create mode 100644 spim_registration/timelapse/xml_merge.bsh diff --git a/spim_registration/timelapse/Snakefile b/spim_registration/timelapse/Snakefile new file mode 100644 index 0000000..67ce937 --- /dev/null +++ b/spim_registration/timelapse/Snakefile @@ -0,0 +1,157 @@ +import os, glob, sys + +#where are we +if "datadir" not in config.keys(): + JOBDIR=os.path.abspath(os.path.curdir) +else: + if os.path.isdir(config['datadir']): + JOBDIR=config['datadir'] + else: + print("given data dir does not exist {data}".format(data=config['datadir'])) + sys.exit(1) + +if JOBDIR[-1] != "/": + JOBDIR+="/" + +datasets = glob.glob('*00.h5') + +#data specific config file +configfile: "tomancak.json" + +def produce_string(_fstring, *args, **kwargs): + contents = dict() + for item in args: + if type(item) == type(kwargs): + contents.update(item) + + contents.update(kwargs) + return _fstring.format(**contents) + +rule done: + input: [ ds+"-deconvolved" for ds in datasets ] + +rule registration: + input: "{xml_base}-{file_id,\d+}-00.h5" + output: "{xml_base}-{file_id,\d+}-00.h5_registered", #convenience files + "{xml_base}.job_{file_id,\d+}.xml" + log: "{xml_base}-{file_id,\d+}-registration.log" + run: + cmd_string = produce_string( + """{fiji-prefix} {fiji-app} \ +-Dparallel_timepoints={file_id_w} \ +-Dimage_file_directory={jdir} \ +-Dxml_filename={input_xml} \ +-Dprocess_timepoint={timepoint} \ +-Dprocess_channel={channel} \ +-Dprocess_illumination={illuminations} \ +-Dprocess_angle={angle} \ +-Dprocessing_channel={proc-ch} \ +-Dlabel_interest_points={label_interest_points} \ +-Dtype_of_registration={type_of_registration} \ +-Dtype_of_detection={type_of_detection} \ +-Dsubpixel_localization={subpixel_localization} \ +-Dimglib_container={imglib_container} \ +-Dradius_1={radius_1} \ +-Dradius_2={radius_2} \ +-Dthreshold={threshold} \ +-Dinitial_sigma={initial_sigma} \ +-Dthreshold_gaussian={threshold_gaussian} \ +-Dregistration_algorithm={algorithm} \ +-Dinterest_points_channel_0={interest_points_channel_0} \ +-Dinterest_points_channel_1={interest_points_channel_1} \ +-Dfix_tiles={fix_tiles} \ +-Dmap_back_tiles={map_back_tiles} \ +-Dtransformation_model={transformation_model} \ +-Dmodel_to_regularize_with={model_to_regularize_with} \ +-Dlambda={lambda} \ +-Dallowed_error_for_ransac={allowed_error_for_ransac} \ +-Ddetection_min_max={detection_min_max} \ +-- --no-splash {bsh_file}""", + config["common"], + config["registration"], + file_id_w="{wildcards.file_id}", + jdir=JOBDIR, + input_xml="{wildcards.xml_base}") + cmd_string += "> {log} 2>&1 && touch {output}" + shell(cmd_string) + #shell("touch {output}") + +rule xml_merge: + input: [ item+"_registered" for item in datasets ] + output: "{xml_base}_merge.xml" + log: "{xml_base}_merge.log" + run: + cmd_string = produce_string("{fiji-prefix} {fiji-app} -Dimage_file_directory={jdir} -Dmerged_xml={merged_xml} -- --no-splash {bsh_file} > {log} 2>&1", + config["common"], + config["xml_merge"], + log="{log}", + jdir=JOBDIR) + shell(cmd_string) + +rule external_trafo: + input: rules.xml_merge.output + output: rules.xml_merge.output[0] + "_external_trafo" + log: "external_trafo.log" +# message: "etrafo {input} -> {output}" + run: + cmd_string = produce_string("""{fiji-prefix} {fiji-app} \ +-Dimage_file_directory={jdir} \ +-Dmerged_xml={merged_xml} \ +-Dtransform_angle={angle} \ +-Dtransform_channel={channel} \ +-Dtransform_illumination={illumination} \ +-Dtransform_timepoint={timepoint} \ +-Dtransformation={transformation} \ +-Dapply_transformation={apply_transformation} \ +-Ddefine_mode_transform={define_mode_transform} \ +-Dmatrix_transform={matrix_transform} \ +-- --no-splash {bsh_file}""", + config["common"], + config["external_transform"], + jdir=JOBDIR) + cmd_string += "> {log} 2>&1 && touch {output}" + shell(cmd_string) + +rule deconvolution: + input: rules.external_trafo.output, "{xml_base}-{file_id,\d+}-00.h5" + output: "{xml_base}-{file_id,\d+}-00.h5-deconvolved" + log: "{xml_base}-{file_id,\d+}-00.h5-deconvolution.log" + run: + cmd_string = produce_string("""{fiji-prefix} {fiji-app} \ +-Dimage_file_directory={jdir} \ +-Ddeco_output_file_directory={jdir} \ +-Dmerged_xml={merged_xml} \ +-Dparallel_timepoints={file_id_w} \ +-Dprocess_timepoint={process_timepoint} \ +-Dprocess_channel={process_channel} \ +-Dprocess_illumination={process_illumination} \ +-Dprocess_angle={process_angle} \ +-Dminimal_x_deco={minimal_x} \ +-Dminimal_y_deco={minimal_y} \ +-Dminimal_z_deco={minimal_z} \ +-Dmaximal_x_deco={maximal_x} \ +-Dmaximal_y_deco={maximal_y} \ +-Dmaximal_z_deco={maximal_z} \ +-Dimglib2_container_deco={imglib2_container} \ +-Dtype_of_iteration={type_of_iteration} \ +-Dosem_acceleration={osem_acceleration} \ +-DTikhonov_parameter={Tikhonov_parameter} \ +-Dcompute={compute} \ +-Dpsf_estimation={psf_estimation} \ +-Ddirectory_cuda={directory_cuda} \ +-Ddetections_to_extract_psf_for_channel_0={detections_to_extract_psf_for_channel_0} \ +-Ddetections_to_extract_psf_for_channel_1={detections_to_extract_psf_for_channel_1} \ +-Dpsf_size_x={psf_size_x} \ +-Dpsf_size_y={psf_size_y} \ +-Dpsf_size_z={psf_size_z} \ +-Diterations={iterations} \ +-- --no-splash {bsh_file}""", + config["common"], + config["deconvolution"], + file_id_w="{wildcards.file_id}", + jdir=JOBDIR) + cmd_string += "> {log} 2>&1 && touch {output}" + shell(cmd_string) + +rule clean: + shell : "rm -rf *registered" diff --git a/spim_registration/timelapse/cluster.json b/spim_registration/timelapse/cluster.json new file mode 100644 index 0000000..da4af28 --- /dev/null +++ b/spim_registration/timelapse/cluster.json @@ -0,0 +1,22 @@ +{ + "__default__" : + { + "fiji-app" : "/projects/pilot_spim/Christopher/Test_pipeline_3.0/test_unicore/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64", + "fiji-good-4-resave" : "/sw/users/schmied/lifeline/Fiji.app.lifeline2/ImageJ-linux64", + "fiji-good-4-deconv" : "/projects/pilot_spim/Christopher/Test_pipeline_3.0/test_unicore/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64", + "fiji-prefix" : "/sw/bin/xvfb-run -a", + "lsf_extra" : "-R span[hosts=1]", + "lsf_queue" : "short" + }, + + "registration" : + { + "lsf_extra" : "-R span[hosts=1] -R rusage[mem=100000]", + "lsf_queue" : "gpu" + }, + + "produce" : + { + "lsf_queue" : "short" + } +} diff --git a/spim_registration/timelapse/deconvolution_CPU.bsh b/spim_registration/timelapse/deconvolution_CPU.bsh new file mode 100644 index 0000000..b2ba8ab --- /dev/null +++ b/spim_registration/timelapse/deconvolution_CPU.bsh @@ -0,0 +1,135 @@ +// Load Fiji dependencies +import ij.IJ; +import ij.ImagePlus; +import java.lang.Runtime; +import java.io.File; +import java.io.FilenameFilter; + +runtime = Runtime.getRuntime(); +System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); + +System.out.println( "Start to load Parameters:" ); + +// Select xml +image_file_directory = System.getProperty( "image_file_directory" ); +merged_xml = System.getProperty( "merged_xml" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Load xml file: " ); +System.out.println( "selected_xml = " + image_file_directory + merged_xml + ".xml"); + +// Load general Parameters +parallel_timepoints = System.getProperty( "parallel_timepoints" ); +process_timepoint = System.getProperty( "process_timepoint" ); +process_channel = System.getProperty( "process_channel" ); +process_illumination = System.getProperty( "process_illumination" ); +process_angle = System.getProperty( "process_angle" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "General parameters: " ); +System.out.println( "timepoint_processed = " + parallel_timepoints ); +System.out.println( "process_timepoints = " + process_timepoint ); +System.out.println( "process_channel = " + process_channel ); +System.out.println( "process_illumination = " + process_illumination ); +System.out.println( "process_angle = " + process_angle ); + +// Load bounding box +minimal_x_deco = System.getProperty( "minimal_x_deco" ); +minimal_y_deco = System.getProperty( "minimal_y_deco" ); +minimal_z_deco = System.getProperty( "minimal_z_deco" ); +maximal_x_deco = System.getProperty( "maximal_x_deco" ); +maximal_y_deco = System.getProperty( "maximal_y_deco" ); +maximal_z_deco = System.getProperty( "maximal_z_deco" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Bounding box: " ); +System.out.println( "minimal_x_deco = " + minimal_x_deco ); +System.out.println( "minimal_y_deco = " + minimal_y_deco ); +System.out.println( "minimal_z_deco = " + minimal_z_deco ); +System.out.println( "maximal_x_deco = " + maximal_x_deco ); +System.out.println( "maximal_y_deco = " + maximal_y_deco ); +System.out.println( "maximal_z_deco = " + maximal_z_deco ); + +// Load deconvolution Parameters +imglib2_container_deco = System.getProperty( "imglib2_container_deco" ); +type_of_iteration = System.getProperty( "type_of_iteration" ); +osem_acceleration = System.getProperty( "osem_acceleration" ); +Tikhonov_parameter = System.getProperty( "Tikhonov_parameter" ); +//float Tikhonov_parameter = Float.parseFloat( System.getProperty( "Tikhonov_parameter" ) ); +compute = System.getProperty( "compute" ); +psf_estimation = System.getProperty( "psf_estimation" ); +iterations = System.getProperty( "iterations" ); +deco_output_file_directory = System.getProperty( "deco_output_file_directory" ); +detections_to_extract_psf_for_channel_0 = System.getProperty( "detections_to_extract_psf_for_channel_0" ); +detections_to_extract_psf_for_channel_1 = System.getProperty( " detections_to_extract_psf_for_channel_1" ); +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Deconvolution settings: " ); +System.out.println( "imglib2_container = " + imglib2_container_deco ); +System.out.println( "type_of_iteration = "+ type_of_iteration ); +System.out.println( "osem_acceleration = " + osem_acceleration ); +System.out.println( "Tikhonov_parameter = " + Tikhonov_parameter ); +System.out.println( "compute = " + compute ); +System.out.println( "psf_estimation = " + psf_estimation ); +System.out.println( "number_of_iterations = " + iterations ); +System.out.println( "deco_output_file_directory = " + deco_output_file_directory ); +System.out.println( "detections_to_extract_psf_for_channel_0 = " + detections_to_extract_psf_for_channel_0 ); +System.out.println( "detections_to_extract_psf_for_channel_1 = " + detections_to_extract_psf_for_channel_1 ); + +// Search for CUDA +directory_cuda = System.getProperty( "directory_cuda" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Loading CUDA directory: " ); +System.out.println( "directory_cuda = " + directory_cuda ); + +// PSF Parameters +psf_size_x = System.getProperty( "psf_size_x" ); +psf_size_y = System.getProperty( "psf_size_y" ); +psf_size_z = System.getProperty( "psf_size_z" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "PSF Parameters: " ); +System.out.println( "psf_size_x = " + psf_size_x ); +System.out.println( "psf_size_y = " + psf_size_y ); +System.out.println( "psf_size_z = " + psf_size_z ); + +// Execute Fiji Plugin +System.out.println( "=======================================================" ); +System.out.println( "Starting Deconvolution" ); + +IJ.run("Fuse/Deconvolve Dataset", + "select_xml=" + image_file_directory + merged_xml + ".xml " + + "process_angle=[All angles] " + + "process_channel=[All channels] " + + "process_illumination=[All illuminations] " + + "process_timepoint=[" + process_timepoint + "] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "type_of_image_fusion=[Multi-view deconvolution] " + + "bounding_box=[Define manually] " + + "fused_image=[Save as TIFF stack] " + + "minimal_x=" + minimal_x_deco + " " + + "minimal_y=" + minimal_y_deco + " " + + "minimal_z=" + minimal_z_deco + " " + + "maximal_x=" + maximal_x_deco + " " + + "maximal_y=" + maximal_y_deco + " " + + "maximal_z=" + maximal_z_deco + " " + + "imglib2_container=" + imglib2_container_deco + " " + + "type_of_iteration=[" + type_of_iteration + "] " + + "osem_acceleration=[" + osem_acceleration + "] " + + "number_of_iterations=" + iterations + " " + +// "adjust_blending_parameters " + + "use_tikhonov_regularization " + + "tikhonov_parameter=" + Tikhonov_parameter + " " + + "compute=[" + compute + "] " + + "compute_on=[CPU (Java)] " + + "psf_estimation=[" + psf_estimation + "] " + + "psf_display=[Do not show PSFs] " + + "output_file_directory=" + deco_output_file_directory + " " + + "detections_to_extract_psf_for_channel_0=" + detections_to_extract_psf_for_channel_0 + " " + + "detections_to_extract_psf_for_channel_1=" + detections_to_extract_psf_for_channel_1 + " " + // Dual Channel + "psf_size_x=" + psf_size_x + " " + + "psf_size_y=" + psf_size_y + " " + + "psf_size_z=" + psf_size_z + ""); + +/* shutdown */ +runtime.exit(0); diff --git a/spim_registration/timelapse/deconvolution_GPU.bsh b/spim_registration/timelapse/deconvolution_GPU.bsh new file mode 100644 index 0000000..f06b777 --- /dev/null +++ b/spim_registration/timelapse/deconvolution_GPU.bsh @@ -0,0 +1,143 @@ +// Load Fiji dependencies +import ij.IJ; +import ij.ImagePlus; +import java.lang.Runtime; +import java.io.File; +import java.io.FilenameFilter; + +runtime = Runtime.getRuntime(); +System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); + +System.out.println( "Start to load Parameters:" ); + +// Select xml +image_file_directory = System.getProperty( "image_file_directory" ); +merged_xml = System.getProperty( "merged_xml" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Load xml file: " ); +System.out.println( "selected_xml = " + image_file_directory + merged_xml + ".xml"); + +// Load general Parameters +parallel_timepoints = System.getProperty( "parallel_timepoints" ); +process_timepoint = System.getProperty( "process_timepoint" ); +process_channel = System.getProperty( "process_channel" ); +process_illumination = System.getProperty( "process_illumination" ); +process_angle = System.getProperty( "process_angle" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "General parameters: " ); +System.out.println( "timepoint_processed = " + parallel_timepoints ); +System.out.println( "process_timepoints = " + process_timepoint ); +System.out.println( "process_channel = " + process_channel ); +System.out.println( "process_illumination = " + process_illumination ); +System.out.println( "process_angle = " + process_angle ); + +// Load bounding box +minimal_x_deco = System.getProperty( "minimal_x_deco" ); +minimal_y_deco = System.getProperty( "minimal_y_deco" ); +minimal_z_deco = System.getProperty( "minimal_z_deco" ); +maximal_x_deco = System.getProperty( "maximal_x_deco" ); +maximal_y_deco = System.getProperty( "maximal_y_deco" ); +maximal_z_deco = System.getProperty( "maximal_z_deco" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Bounding box: " ); +System.out.println( "minimal_x_deco = " + minimal_x_deco ); +System.out.println( "minimal_y_deco = " + minimal_y_deco ); +System.out.println( "minimal_z_deco = " + minimal_z_deco ); +System.out.println( "maximal_x_deco = " + maximal_x_deco ); +System.out.println( "maximal_y_deco = " + maximal_y_deco ); +System.out.println( "maximal_z_deco = " + maximal_z_deco ); + +// Load deconvolution Parameters +imglib2_container_deco = System.getProperty( "imglib2_container_deco" ); +type_of_iteration = System.getProperty( "type_of_iteration" ); +osem_acceleration = System.getProperty( "osem_acceleration" ); +Tikhonov_parameter = System.getProperty( "Tikhonov_parameter" ); +//float Tikhonov_parameter = Float.parseFloat( System.getProperty( "Tikhonov_parameter" ) ); +compute = System.getProperty( "compute" ); +psf_estimation = System.getProperty( "psf_estimation" ); +iterations = System.getProperty( "iterations" ); +deco_output_file_directory = System.getProperty( "deco_output_file_directory" ); +detections_to_extract_psf_for_channel_0 = System.getProperty( "detections_to_extract_psf_for_channel_0" ); +detections_to_extract_psf_for_channel_1 = System.getProperty( "detections_to_extract_psf_for_channel_1" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Deconvolution settings: " ); +System.out.println( "imglib2_container = " + imglib2_container_deco ); +System.out.println( "type_of_iteration = "+ type_of_iteration ); +System.out.println( "osem_acceleration = " + osem_acceleration ); +System.out.println( "Tikhonov_parameter = " + Tikhonov_parameter ); +System.out.println( "compute = " + compute ); +System.out.println( "psf_estimation = " + psf_estimation ); +System.out.println( "number_of_iterations = " + iterations ); +System.out.println( "deco_output_file_directory = " + deco_output_file_directory ); +System.out.println( "detections_to_extract_psf_for_channel_0 = " + detections_to_extract_psf_for_channel_0 ); +System.out.println( "detections_to_extract_psf_for_channel_1 = " + detections_to_extract_psf_for_channel_1 ); + +// Search for CUDA +directory_cuda = System.getProperty( "directory_cuda" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Loading CUDA directory: " ); +System.out.println( "directory_cuda = " + directory_cuda ); + +// PSF Parameters +psf_size_x = System.getProperty( "psf_size_x" ); +psf_size_y = System.getProperty( "psf_size_y" ); +psf_size_z = System.getProperty( "psf_size_z" ); + +System.out.println( "-------------------------------------------------------" ); +System.out.println( "PSF Parameters: " ); +System.out.println( "psf_size_x = " + psf_size_x ); +System.out.println( "psf_size_y = " + psf_size_y ); +System.out.println( "psf_size_z = " + psf_size_z ); + +// Execute Fiji Plugin +System.out.println( "=======================================================" ); +System.out.println( "Starting Deconvolution" ); + +IJ.run("Fuse/Deconvolve Dataset", + "select_xml=" + image_file_directory + merged_xml + ".xml " + + "process_angle=[All angles] " + + "process_channel=[All channels] " + + "process_illumination=[All illuminations] " + + "process_timepoint=[" + process_timepoint + "] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + +// "processing_timepoint=[Timepoint 0] " + + "type_of_image_fusion=[Multi-view deconvolution] " + + "bounding_box=[Define manually] " + + "fused_image=[Save as TIFF stack] " + + "minimal_x=" + minimal_x_deco + " " + + "minimal_y=" + minimal_y_deco + " " + + "minimal_z=" + minimal_z_deco + " " + + "maximal_x=" + maximal_x_deco + " " + + "maximal_y=" + maximal_y_deco + " " + + "maximal_z=" + maximal_z_deco + " " + + "imglib2_container=" + imglib2_container_deco + " " + + "type_of_iteration=[" + type_of_iteration + "] " + + "osem_acceleration=[" + osem_acceleration + "] " + + "number_of_iterations=" + iterations + " " + +// "adjust_blending_parameters " + + "use_tikhonov_regularization " + + "tikhonov_parameter=" + Tikhonov_parameter + " " + + "compute=[" + compute + "] " + + "compute_on=[GPU (Nvidia CUDA via JNA)] " + + "psf_estimation=[" + psf_estimation + "] " + + "psf_display=[Do not show PSFs] " + + "output_file_directory=" + deco_output_file_directory + " " + +// "directory=[/sw/users/schmied/packages/Fiji.app.cuda_new/lib/] " + + "directory=[" + directory_cuda + "] " + + "select_native_library_for_cudafourierconvolution=libFourierConvolutionCUDALib.so " + + "gpu_1 " + +// "gpu_2 " + + "detections_to_extract_psf_for_channel_0=" + detections_to_extract_psf_for_channel_0 + " " + +// "detections_to_extract_psf_for_channel_1=" + detections_to_extract_psf_for_channel_1 + " " + // Dual Channel + "psf_size_x=" + psf_size_x + " " + + "psf_size_y=" + psf_size_y + " " + + "psf_size_z=" + psf_size_z + ""); + + +/* shutdown */ +runtime.exit(0); diff --git a/spim_registration/timelapse/registration.bsh b/spim_registration/timelapse/registration.bsh new file mode 100644 index 0000000..ab21bba --- /dev/null +++ b/spim_registration/timelapse/registration.bsh @@ -0,0 +1,156 @@ +import ij.IJ; +import ij.ImagePlus; +import java.lang.Runtime; +import java.io.File; +import java.io.FilenameFilter; + +runtime = Runtime.getRuntime(); +System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); + +System.out.println("Start loading parameters"); + +// select xml +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Load xml file: " ); + +xml_path = System.getProperty( "image_file_directory" ); +xml_filename = System.getProperty( "xml_filename" ); + +System.out.println( "selected_xml = " + xml_path + xml_filename + ".xml"); + + +// Load general Parameters +System.out.println( "-------------------------------------------------------" ); +System.out.println( "General parameters: " ); + +parallel_timepoints = System.getProperty( "parallel_timepoints" ); +process_timepoint = System.getProperty( "process_timepoint" ); +process_channel = System.getProperty( "process_channel" ); +process_illumination = System.getProperty( "process_illumination" ); +process_angle = System.getProperty( "process_angle" ); +processing_channel = System.getProperty( "processing_channel" ); + +System.out.println( "parallel_timepoints = " + parallel_timepoints ); +System.out.println( "process_timepoints = " + process_timepoint ); +System.out.println( "process_channel = " + process_channel ); +System.out.println( "process_illumination = " + process_illumination ); +System.out.println( "process_angle = " + process_angle ); +System.out.println( "processing_channel = " + processing_channel ); + +// Interest point detection parameters +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Detection of Interest Points: " ); + +label_interest_points= System.getProperty( "label_interest_points" ); +type_of_registration = System.getProperty( "type_of_registration" ); +type_of_detection = System.getProperty( "type_of_detection" ); +subpixel_localization = System.getProperty( "subpixel_localization" ); +imglib_container = System.getProperty( "imglib_container" ); + +System.out.println( "label_interest_points = " + label_interest_points ); +System.out.println( "type_of_registration = " + type_of_registration ); +System.out.println( "type_of_detection = " + type_of_detection ); +System.out.println( "subpixel_localization = " + subpixel_localization ); +System.out.println( "imglib_container = " + imglib_container ); + +// Parameters for difference of mean !!Comment out for Difference of Gaussian!! +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Difference of Mean detection: " ); + +int radius_1 = Integer.parseInt( System.getProperty( "radius_1" ) ); +int radius_2 = Integer.parseInt( System.getProperty( "radius_2" ) ); +float threshold = Float.parseFloat( System.getProperty( "threshold" ) ); + +System.out.println( "radius_1 = " + radius_1 ); +System.out.println( "radius_2 = " + radius_2 ); +System.out.println( "threshold = " + threshold ); + +//Parameters for difference of gaussian !!Comment out for Differnence of Mean!! +//System.out.println( "-------------------------------------------------------" ); +//System.out.println( "Difference of Gaussian detection: " ); +//float initial_sigma = Float.parseFloat( System.getProperty( "initial_sigma" ) ); +//float threshold_gaussian = Float.parseFloat( System.getProperty( "threshold_gaussian" ) ); +//System.out.println( "initial_sigma = " + initial_sigma ); +//System.out.println( "threshold_gaussian = " + threshold_gaussian ); + +// Registration parameters +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Parameters for Registration: " ); + +registration_algorithm = System.getProperty( "registration_algorithm" ); +interest_points_channel_0 = System.getProperty( "interest_points_channel_0" ); +interest_points_channel_1 = System.getProperty( "interest_points_channel_1" ); +fix_tiles = System.getProperty( "fix_tiles" ); +map_back_tiles = System.getProperty( "map_back_tiles" ); +transformation_model = System.getProperty( "transformation_model" ); +model_to_regularize_with = System.getProperty( "model_to_regularize_with" ); +float lambda = Float.parseFloat( System.getProperty( "lambda" ) ); +int allowed_error_for_ransac = Integer.parseInt( System.getProperty( "allowed_error_for_ransac" ) ); +detection_min_max = System.getProperty( "detection_min_max" ); + +System.out.println( "registration_algorithm = " + registration_algorithm ); +System.out.println( "interest_points_channel_0 = " + interest_points_channel_0 ); +System.out.println( "interest_points_channel_1 = " + interest_points_channel_1 ); +System.out.println( "fix_tiles = " + fix_tiles ); +System.out.println( "map_back_tiles = " + map_back_tiles ); +System.out.println( "transformation = " + transformation_model); +System.out.println( "model_to_regularize_with = " + model_to_regularize_with ); +System.out.println( "lambda = " + lambda ); +System.out.println( "allowed_error_for_ransac = " + allowed_error_for_ransac ); +System.out.println( "detection_min_max = " + detection_min_max ); + +//activate cluster processing +System.out.println( "=======================================================" ); +IJ.run("Toggle Cluster Processing", "display_cluster"); +System.out.println( "Activated Cluster Processing" ); + + +//interest point detection +System.out.println( "=======================================================" ); +System.out.println( "Starting Detection of Interest Points" ); +IJ.run("Detect Interest Points for Registration", + "select_xml=" + xml_path + xml_filename + ".xml " + + "unique_id=" + parallel_timepoints + " " + + "process_angle=[" + process_angle + "] " + + "process_channel=[" + process_channel + "] " + + "process_illumination=[" + process_illumination + "] " + + "process_timepoint=[" + process_timepoint + "] " + + "processing_channel=[" + processing_channel + "] " + // Dual Channel: 1 Channel contains the beads + "xml_output=[Save every XML with user-provided unique id]" + " " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "type_of_interest_point_detection=[" + type_of_detection + "] " + + "label_interest_points=" + label_interest_points + " " + + "subpixel_localization=[" + subpixel_localization + "] " + + "interest_point_specification_(channel_0)=[Advanced ...] " + +// "interest_point_specification_(channel_1)=[Advanced ...] " + // Dual Channel + "radius_1=" + radius_1 + " " + + "radius_2=" + radius_2 + " " + + "threshold=" + threshold + " " + + "find_maxima"); + +//registration based on interest point detection +System.out.println( "=======================================================" ); +System.out.println( "Starting Registration" ); +IJ.run("Register Dataset based on Interest Points", + "select_xml=" + xml_path + xml_filename + ".job_" + parallel_timepoints + ".xml " + + "process_angle=[" + process_angle + "] " + + "process_channel=[" + process_channel + "] " + + "process_illumination=[" + process_illumination + "] " + + "process_timepoint=[" + process_timepoint + "] " + + "xml_output=[Do not process on cluster] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "registration_algorithm=[" + registration_algorithm + "] " + + "type_of_registration=[" + type_of_registration + "] " + + "interest_points_channel_0=" + interest_points_channel_0 + " " + +// check? "interest_points_channel_0=[[DO NOT register this channel]] " + +// "interest_points_channel_1=" + interest_points_channel_1 + " " + // Dual Channel + "fix_tiles=[" + fix_tiles + "] " + + "map_back_tiles=[" + map_back_tiles + "] " + + "transformation=" + transformation_model + " " + + "regularize_model " + + "model_to_regularize_with=" + model_to_regularize_with + " " + + "lamba=" + lambda + " " + + "allowed_error_for_ransac=" + allowed_error_for_ransac); + +/* shutdown */ +runtime.exit(0); diff --git a/spim_registration/timelapse/tomancak.json b/spim_registration/timelapse/tomancak.json new file mode 100644 index 0000000..b1a87ba --- /dev/null +++ b/spim_registration/timelapse/tomancak.json @@ -0,0 +1,88 @@ +{ + "common" : + { + "fiji-app" : "/projects/hpcsupport/steinbac/unicore/christopher-sandbox/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64", + "fiji-prefix" : "/sw/bin/xvfb-run -a", + "directory_cuda" : "/lustre/projects/hpcsupport/steinbac/unicore/christopher/unicore_jobs/Fiji.app.cuda_new/lib/", + "merged_xml" : "hdf5_test_unicore_merge" + }, + + "registration" : + { + "timepoint" : "\"Single Timepoint (Select from List)\"", + "illuminations" : "\"All illuminations\"", + "angle" : "\"All angles\"", + "channel" : "\"All channels\"", + "proc-ch" : "\"channel 1\"", + "algorithm" : "\"Fast 3d geometric hashing (rotation invariant)\"", + "label_interest_points" : "\"beads\"", + "type_of_registration" : "\"Register timepoints individually\"", + "type_of_registration_timelapse" : "\"Match against one reference timepoint (no global optimization)\"", + "type_of_detection" : "\"Difference-of-Mean (Integral image based)\"" , + "subpixel_localization" : "\"3-dimensional quadratic fit\"", + "imglib_container" : "\"ArrayImg (faster)\"", + "radius_1" : "2", + "radius_2" : "3", + "threshold" : "0.005", + "interest_points_channel_0" : "\"[DO NOT register this channel]\"" , + "interest_points_channel_1" : "\"beads\"", + "fix_tiles" : "\"Fix first tile\"" , + "map_back_tiles" : "\"Map back to first tile using rigid model\"", + "transformation_model" : "Affine", + "model_to_regularize_with" : "Rigid", + "lambda" : "0.10" , + "allowed_error_for_ransac" : "5", + "detection_min_max" : "find_maxima", + "initial_sigma" : "1.8", + "threshold_gaussian" : "0.0080", + "bsh_file" : "registration.bsh" + }, + + "xml_merge" : + { + "bsh_file" : "xml_merge.bsh" + }, + + "external_transform" : + { + "bsh_file" : "transform.bsh", + "angle" : "\"All angles\"", + "channel" : "\"All channels\"", + "illumination" : "\"All illuminations\"", + "timepoint" : "\"All Timepoints\"", + "transformation" : "\"Rigid\"", + "apply_transformation" : "\"Current view transformations (appends to current transforms)\"", + "define_mode_transform" : "\"Matrix\"", + "matrix_transform" : "\"0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0\"" + }, + + "deconvolution" : + { + + "bsh_file" : "deconvolution_GPU.bsh", + "process_timepoint" : "\"Single Timepoint (Select from List)\"", + "process_channel" : "\"All channels\"", + "process_illumination" : "\"All illuminations\"", + "process_angle" : "\"All angles\"", + "minimal_x" : "76", + "minimal_y" : "4", + "minimal_z" : "-192", + "maximal_x" : "488", + "maximal_y" : "956", + "maximal_z" : "214", + "imglib2_container" : "\"ArrayImg \"", + "type_of_iteration" : "\"Efficient Bayesian - Optimization I (fast, precise)\"", + "osem_acceleration" : "\"1 (balanced)\"", + "Tikhonov_parameter" : "0.0006", + "compute" : "\"in 512x512x512 blocks\"", + "compute_on" : "\"GPU (Nvidia CUDA via JNA)\"", + "psf_estimation" : "\"Extract from beads\"", + "iterations" : "5", + "detections_to_extract_psf_for_channel_0" : "\"beads\"", + "detections_to_extract_psf_for_channel_1" : "\"beads\"", + "psf_size_x" : "19", + "psf_size_y" : "19", + "psf_size_z" : "25" + } + +} diff --git a/spim_registration/timelapse/transform.bsh b/spim_registration/timelapse/transform.bsh new file mode 100644 index 0000000..3a1cb2e --- /dev/null +++ b/spim_registration/timelapse/transform.bsh @@ -0,0 +1,56 @@ +import ij.IJ; +import ij.ImagePlus; +import java.lang.Runtime; +import java.io.File; +import java.io.FilenameFilter; + +runtime = Runtime.getRuntime(); +System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); + + +// Load Parameters form job file +image_file_directory = System.getProperty( "image_file_directory" ); +merged_xml = System.getProperty( "merged_xml" ); +transform_angle = System.getProperty( "transform_angle" ); +transform_channel = System.getProperty( "transform_channel" ); +transform_illumination = System.getProperty( "transform_illumination" ); +transform_timepoint = System.getProperty( "transform_timepoint" ); +transformation = System.getProperty( "transformation" ); +apply_transformation = System.getProperty( "apply_transformation" ); +define_mode_transform = System.getProperty( "define_mode_transform" ); +matrix_transform = System.getProperty( "matrix_transform" ); + +// Print Parameters into output file + +System.out.println( "browse = " + image_file_directory ); +System.out.println( "select_xml = " + image_file_directory + merged_xml + ".xml" ); +System.out.println( "apply_to_angle = " + transform_angle ); +System.out.println( "apply_to_channel = " + transform_channel ); +System.out.println( "apply_to_illumination = " + transform_illumination ); +System.out.println( "apply_to_timepoint = " + transform_timepoint ); +System.out.println( "transformation = " + transformation ); +System.out.println( "apply = " + apply_transformation ); +System.out.println( "define = " + define_mode_transform ); +System.out.println( "all_timepoints_channel_0_illumination_0_all_angles = " + matrix_transform ); + +// Execute Fiji Plugin +IJ.run("Apply Transformations", + "browse=" + image_file_directory + " " + + "select_xml=" + image_file_directory + merged_xml + ".xml " + + "apply_to_angle=[" + transform_angle + "] " + + "apply_to_channel=[" + transform_channel + "] " + + "apply_to_illumination=[" + transform_illumination + "] " + + "apply_to_timepoint=[" + transform_timepoint + "] " + + "transformation=" + transformation + " " + + "apply=[" + apply_transformation + "] " + + "define=" + define_mode_transform + " " + + "same_transformation_for_all_timepoints " + + "same_transformation_for_all_angles " + +// "all_timepoints_channel_0_illumination_0_all_angles=[0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0]"); + "all_timepoints_channel_0_illumination_0_all_angles=[" + matrix_transform + "]"); + +/* shutdown */ +runtime.exit(0); + + + diff --git a/spim_registration/timelapse/xml_merge.bsh b/spim_registration/timelapse/xml_merge.bsh new file mode 100644 index 0000000..99925e7 --- /dev/null +++ b/spim_registration/timelapse/xml_merge.bsh @@ -0,0 +1,34 @@ +import ij.IJ; +import ij.ImagePlus; +import java.lang.Runtime; +import java.io.File; +import java.io.FilenameFilter; + +runtime = Runtime.getRuntime(); +System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); + + +System.out.println( "Load Parameters:"); + + // Getting parameters from job file +image_file_directory = System.getProperty( "image_file_directory" ); +merged_xml = System.getProperty( "merged_xml" ); + +// Printing parameters into output file +System.out.println( "directory=" + image_file_directory ); +System.out.println( "merged_xml=" + merged_xml ); + +System.out.println( "=======================================================" ); +System.out.println( "Start to merge .xml files" ); + +// Executing Fiji plugin +IJ.run("Merge Cluster Jobs", + "directory=" + image_file_directory + " " + + "filename_contains=job_ " + + "filename_also_contains=.xml " + + "display " + +// "delete_xml's " + + "merged_xml=" + merged_xml + ".xml"); + +/* shutdown */ +runtime.exit(0); -- GitLab