diff --git a/spim_registration/timelapse/Snakefile b/spim_registration/timelapse/Snakefile old mode 100644 new mode 100755 index 7d20dad47afc6e667ccf51e711464dd3cdd4bed9..812dccc659d3b7bfd2aed5728f94dd2c1cf1ebf2 --- a/spim_registration/timelapse/Snakefile +++ b/spim_registration/timelapse/Snakefile @@ -7,8 +7,8 @@ if JOBDIR[-1] != "/": # this checks if jobdir ends with slash if not it adds a s JOBDIR+="/" #data specific config file, expected to be inside JOBDIR -configfile: "tomancak_test_cluster.json" -# configfile: "tomancak_test_cluster.yaml" +# configfile: "tomancak_test_cluster.json" +configfile: "tomancak_test_cluster.yaml" padding_format = "{0:0"+str(padding_of_file_id(int(config["common"]["ntimepoints"])))+"d}" @@ -21,6 +21,7 @@ xml_merge_in = produce_xml_merge_job_files(datasets) rule done: input: [ ds + "_output_hdf5" for ds in datasets ] + #input: [ ds + "_fusion" for ds in datasets ] rule resave_prepared: input: expand("{dataset}.{suffix}",dataset=[ config["common"]["hdf5_xml_filename"] ], suffix=["xml","h5"]) @@ -34,20 +35,15 @@ rule define_xml_czi: cmd_string = produce_string("""{fiji-prefix} {fiji-app} \ -Dimage_file_directory={jdir} \ -Dfirst_czi={first_czi} \ - -Dangle_1={angle_1} \ - -Dangle_2={angle_2} \ - -Dangle_3={angle_3} \ - -Dangle_4={angle_4} \ - -Dangle_5={angle_5} \ - -Dchannel_1={channel_1} \ - -Dchannel_2={channel_2} \ - -Dillumination_1={illumination_1} \ - -Drotation_around={rotation_around} \ + -Dangles={angles} \ + -Dchannels={channels} \ + -Dillumination={illumination} \ -Dpixel_distance_x={pixel_distance_x} \ -Dpixel_distance_y={pixel_distance_y} \ -Dpixel_distance_z={pixel_distance_z} \ -Dpixel_unit={pixel_unit} \ -Dfirst_xml_filename={first_xml_filename} \ + -Drotation_around={rotation_around} \ -- --no-splash {path_bsh}""", config["common"], config["define_xml_czi"], @@ -68,8 +64,9 @@ rule define_xml_tif: """{fiji-prefix} {fiji-app} \ -Dimage_file_directory={jdir} \ -Dtimepoints={timepoints} \ - -Dacquisition_angles={acquisition_angles} \ + -Dangles={angles} \ -Dchannels={channels} \ + -Dillumination={illumination} \ -Dimage_file_pattern={image_file_pattern} \ -Dpixel_distance_x={pixel_distance_x} \ -Dpixel_distance_y={pixel_distance_y} \ @@ -93,7 +90,7 @@ rule define_xml_tif: cmd_string +=" > {log} 2>&1" shell(cmd_string) -ruleorder: define_xml_tif > define_xml_czi +ruleorder: define_xml_czi > define_xml_tif # create mother .xml/.h5 rule hdf5_xml: @@ -135,7 +132,7 @@ rule resave_hdf5: run: part_string = produce_string( """{fiji-prefix} {fiji-app} \ - -Dimage_file_directory={jdir} \ + -Dimage_file_directory={jdir} \ -Dfirst_xml_filename={first_xml_filename} \ -Dhdf5_xml_filename={input_xml_base} \ -Dresave_angle={resave_angle} \ @@ -168,24 +165,24 @@ rule registration: -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} \ + -Dreg_process_timepoint={reg_process_timepoint} \ + -Dreg_process_channel={reg_process_channel} \ + -Dreg_process_illumination={reg_process_illumination} \ + -Dreg_process_angle={reg_process_angle} \ + -Dchannels={channels} \ + -Dreg_processing_channel={reg_processing_channel} \ -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} \ + -Dreg_radius_1={reg_radius_1} \ + -Dreg_radius_2={reg_radius_2} \ + -Dreg_threshold={reg_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} \ + -Dreg_interest_points_channel={reg_interest_points_channel} \ -Dfix_tiles={fix_tiles} \ -Dmap_back_tiles={map_back_tiles} \ -Dtransformation_model={transformation_model} \ @@ -193,6 +190,7 @@ rule registration: -Dlambda={lambda} \ -Dallowed_error_for_ransac={allowed_error_for_ransac} \ -Ddetection_min_max={detection_min_max} \ + -Dsignificance={significance} \ -- --no-splash {path_bsh}""", config["common"], config["registration"], @@ -233,15 +231,14 @@ rule timelapse: -Dimage_file_directory={jdir} \ -Dmerged_xml={input} \ -Dtimelapse_process_timepoints={timelapse_process_timepoints} \ - -Dprocess_channel_timelapse={channel} \ - -Dprocess_illumination={illuminations} \ - -Dprocess_angle={angle} \ + -Dreg_process_channel={reg_process_channel} \ + -Dreg_process_illumination={reg_process_illumination} \ + -Dreg_process_angle={reg_process_angle} \ -Dreference_timepoint={reference_timepoint} \ - -Dchannel_1={proc-ch} \ + -Dchannels={channels} \ -Dtype_of_registration_timelapse={type_of_registration_timelapse} \ -Dregistration_algorithm={algorithm} \ - -Dreg_1_interest_points_channel={interest_points_channel_0} \ - -Dreg_2_interest_points_channel={interest_points_channel_1} \ + -Dreg_interest_points_channel={reg_interest_points_channel} \ -Dtransformation_model={transformation_model} \ -Dmodel_to_regularize_with={model_to_regularize_with} \ -Dlambda={lambda} \ @@ -292,7 +289,7 @@ rule fusion: -- --no-splash {path_bsh}""", config["common"], config["fusion"], - config["resave_czi_hdf5"], + config["resave_hdf5"], path_bsh=config["common"]["bsh_directory"] + config["fusion"]["bsh_file"], jdir=JOBDIR, file_id_w="{wildcards.file_id}", @@ -310,10 +307,11 @@ rule external_transform: """{fiji-prefix} {fiji-app} \ -Dimage_file_directory={jdir} \ -Dmerged_xml={merged_xml_file} \ - -Dtransform_angle={angle} \ - -Dtransform_channel={channel} \ - -Dtransform_illumination={illumination} \ - -Dtransform_timepoint={timepoint} \ + -Dchannel_setting={channel_setting} \ + -Dtransform_angle={transform_angle} \ + -Dtransform_channel={transform_channel} \ + -Dtransform_illumination={transform_illumination} \ + -Dtransform_timepoint={transform_timepoint} \ -Dtransformation={transformation} \ -Dapply_transformation={apply_transformation} \ -Ddefine_mode_transform={define_mode_transform} \ @@ -329,7 +327,7 @@ rule external_transform: shell(cmd_string) rule deconvolution: - input: rules.external_transform.output, "{xml_base}-{file_id,\d+}-00.h5", merged_xml="{xml_base}_merge.xml" + input: rules.timelapse.output, "{xml_base}-{file_id,\d+}-00.h5", merged_xml="{xml_base}_merge.xml" # rules.external_transform.output, "{xml_base}-{file_id,\d+}-00.h5", merged_xml="{xml_base}_merge.xml" output: "{xml_base}-{file_id,\d+}-00.h5_deconvolution" log: "{xml_base}-{file_id,\d+}-00-deconvolution.log" run: @@ -343,12 +341,13 @@ rule deconvolution: -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} \ + -Dchannels={channels} \ + -Dminimal_x_deco={minimal_x_deco} \ + -Dminimal_y_deco={minimal_y_deco} \ + -Dminimal_z_deco={minimal_z_deco} \ + -Dmaximal_x_deco={maximal_x_deco} \ + -Dmaximal_y_deco={maximal_y_deco} \ + -Dmaximal_z_deco={maximal_z_deco} \ -Dimglib2_container_deco={imglib2_container} \ -Dtype_of_iteration={type_of_iteration} \ -Dosem_acceleration={osem_acceleration} \ @@ -356,8 +355,7 @@ rule deconvolution: -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} \ + -Ddetections_to_extract_psf_for_channel={detections_to_extract_psf_for_channel} \ -Dpsf_size_x={psf_size_x} \ -Dpsf_size_y={psf_size_y} \ -Dpsf_size_z={psf_size_z} \ @@ -409,7 +407,7 @@ rule hdf5_xml_output: input: config["hdf5_output"]["output_xml"].strip('\"') + ".xml" output: expand("{dataset}.{suffix}",dataset=[ config["common"]["hdf5_xml_filename"].strip('\"')], suffix=["xml","h5"]), [ item+"_output" for item in datasets ] - log: "hdf5_xml.log" + log: "output_hdf5_xml.log" run: part_string = produce_string( """{fiji-prefix} {fiji-app} \ @@ -420,8 +418,8 @@ rule hdf5_xml_output: -Dresave_channel={resave_channel} \ -Dresave_illumination={resave_illumination} \ -Dresave_timepoint={resave_timepoint} \ - -Dsubsampling_factors={subsampling_factors} \ - -Dhdf5_chunk_sizes={hdf5_chunk_sizes} \ + -Dsubsampling_factors={subsampling_output} \ + -Dhdf5_chunk_sizes={chunk_sizes_output} \ -Dtimepoints_per_partition={timepoints_per_partition} \ -Dsetups_per_partition={setups_per_partition} \ -Drun_only_job_number=0 \ @@ -432,7 +430,7 @@ rule hdf5_xml_output: config["hdf5_output"], config["resave_hdf5"], jdir=JOBDIR, - path_bsh=config["common"]["bsh_directory"] + config["resave_hdf5"]["bsh_file"]) + path_bsh=config["common"]["bsh_directory"] + config["hdf5_output"]["bsh_file_hdf5"]) part_string += " > {log} 2>&1 && touch {output}" shell(part_string) @@ -451,8 +449,8 @@ rule resave_hdf5_output: -Dresave_channel={resave_channel} \ -Dresave_illumination={resave_illumination} \ -Dresave_timepoint={resave_timepoint} \ - -Dsubsampling_factors={subsampling_factors} \ - -Dhdf5_chunk_sizes={hdf5_chunk_sizes} \ + -Dsubsampling_factors={subsampling_output} \ + -Dhdf5_chunk_sizes={chunk_sizes_output} \ -Dtimepoints_per_partition={timepoints_per_partition} \ -Dsetups_per_partition={setups_per_partition} \ -Drun_only_job_number={job_number} \ @@ -463,7 +461,7 @@ rule resave_hdf5_output: config["hdf5_output"], config["resave_hdf5"], jdir=JOBDIR, - path_bsh=config["common"]["bsh_directory"] + config["resave_hdf5"]["bsh_file"], + path_bsh=config["common"]["bsh_directory"] + config["hdf5_output"]["bsh_file_hdf5"], input_xml_base="{wildcards.xml_base}", job_number=int(wildcards.file_id)+1) part_string += " > {log} 2>&1 && touch {output}" diff --git a/spim_registration/timelapse/cluster.json b/spim_registration/timelapse/cluster.json old mode 100644 new mode 100755 index cb47db9c31910bf7f679d661b0a6a00fa177949e..4b2be746447e0fbd6c2b2892b30e26c895b4b0dd --- a/spim_registration/timelapse/cluster.json +++ b/spim_registration/timelapse/cluster.json @@ -15,7 +15,7 @@ "lsf_extra" : "-n 6 -R \"span[hosts=1] rusage[mem=100000]\"" }, - "external_trafo" : + "external_transfrom" : { "lsf_extra" : "-R \"span[hosts=1] rusage[mem=10000]\"" }, @@ -24,5 +24,10 @@ { "lsf_extra" : "-n 7 -R \"span[hosts=1] rusage[mem=50000]\"", "lsf_q" : "gpu" + }, + + "resave_hdf5_output" : + { + "lsf_extra" : "-n 7 -R \"span[hosts=1] rusage[mem=50000]\"" } } diff --git a/spim_registration/timelapse/deconvolution_CPU.bsh b/spim_registration/timelapse/deconvolution_CPU.bsh deleted file mode 100644 index f21f94d72529c6304592d7b59a592270ecfc550a..0000000000000000000000000000000000000000 --- a/spim_registration/timelapse/deconvolution_CPU.bsh +++ /dev/null @@ -1,146 +0,0 @@ -// 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" ); -if ( ! merged_xml.endsWith(".xml") ) - merged_xml = merged.xml + ".xml"; - -System.out.println( "-------------------------------------------------------" ); -System.out.println( "Load xml file: " ); -System.out.println( "selected_xml = " + image_file_directory + merged_xml); - -// Load general Parameters -parallel_timepoints = Integer.parseInt(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" ); - -try { -IJ.run("Fuse/Deconvolve Dataset", - "select_xml=" + image_file_directory + merged_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 + ""); -} -catch ( e ) { - - print( "[deconvolution-CPU] caught exception: "+e ); - //important to fail the process if exception occurs - runtime.exit(1); - -} - -/* shutdown */ -runtime.exit(0); diff --git a/spim_registration/timelapse/deconvolution_GPU.bsh b/spim_registration/timelapse/deconvolution_GPU.bsh old mode 100644 new mode 100755 index ec3d0d3b3d83d444708413c568a6d64f7175a8cf..32154c2c9986c8156073d169f1fa53071506cc35 --- a/spim_registration/timelapse/deconvolution_GPU.bsh +++ b/spim_registration/timelapse/deconvolution_GPU.bsh @@ -1,6 +1,6 @@ // Load Fiji dependencies -import ij.IJ; -import ij.ImagePlus; +import ij.IJ; // calls imagej +import ij.Prefs; // calls imagej settings import java.lang.Runtime; import java.io.File; import java.io.FilenameFilter; @@ -8,17 +8,19 @@ import java.io.FilenameFilter; runtime = Runtime.getRuntime(); System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); -System.out.println( "Start to load Parameters:" ); +Prefs.setThreads(7); // defines the number of threads allowed +print("Threads: "+Prefs.getThreads()); // prints thread setting in output +System.out.println( "Start to load Parameters:" ); // Select xml image_file_directory = System.getProperty( "image_file_directory" ); merged_xml = System.getProperty( "merged_xml" ); if ( ! merged_xml.endsWith(".xml") ) merged_xml = merged.xml + ".xml"; - + System.out.println( "-------------------------------------------------------" ); System.out.println( "Load xml file: " ); -System.out.println( "selected_xml = " + image_file_directory + merged_xml); +System.out.println( "selected_xml = " + image_file_directory + merged_xml + ".xml"); // Load general Parameters int parallel_timepoints = Integer.parseInt(System.getProperty( "parallel_timepoints" )); @@ -27,6 +29,7 @@ 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 ); @@ -62,8 +65,7 @@ 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: " ); @@ -75,14 +77,11 @@ 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: " ); +directory_cuda = System.getProperty( "directory_cuda" ); System.out.println( "directory_cuda = " + directory_cuda ); // PSF Parameters @@ -96,19 +95,48 @@ 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 ); + +// Channel settings +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Channel Settings: " ); +// Channel setting for Deconvolution +// parses channels and takes from there the number of channels +// parses detections_to_extract_psf_for_channel +channels = System.getProperty( "channels" ); +System.out.println( "Channels = " + channels ); + +detections_to_extract_psf_for_channel = System.getProperty( "detections_to_extract_psf_for_channel" ); +System.out.println( "PSF: " + detections_to_extract_psf_for_channel ); + +// Splits channels and detections_to_extract_psf_for_channel +String delims = "[,]"; +String[] channel_token = channels.split(delims); +String[] psf_token = detections_to_extract_psf_for_channel.split(delims); + +// Assembles channel_string +StringBuilder channel_string = new StringBuilder(); + +for (int channel=0; channel < channel_token.length; channel++ ) + +{ + String channel_part = "detections_to_extract_psf_for_channel_" + channel_token[channel] + "=" + psf_token[channel] + " "; + channel_string.append( channel_part ); + channel_string.append(" "); +} + +System.out.println( channel_string ); + // Execute Fiji Plugin System.out.println( "=======================================================" ); System.out.println( "Starting Deconvolution" ); - try { IJ.run("Fuse/Deconvolve Dataset", - "select_xml=" + image_file_directory + merged_xml + " " + + "select_xml=" + image_file_directory + merged_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] " + @@ -130,12 +158,10 @@ IJ.run("Fuse/Deconvolve Dataset", "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 + "] " + + "cuda_directory=[" + directory_cuda + "] " + "select_native_library_for_cudafourierconvolution=libFourierConvolutionCUDALib.so " + "gpu_1 " + - "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 + channel_string + "psf_size_x=" + psf_size_x + " " + "psf_size_y=" + psf_size_y + " " + "psf_size_z=" + psf_size_z + ""); diff --git a/spim_registration/timelapse/define_czi.bsh b/spim_registration/timelapse/define_czi.bsh old mode 100644 new mode 100755 index 74afeb13157ffa770376eed588bc2f6681682238..e3e1d30e788e27aa6888ce5a4a7e352162aae4d5 --- a/spim_registration/timelapse/define_czi.bsh +++ b/spim_registration/timelapse/define_czi.bsh @@ -26,25 +26,93 @@ System.out.println( "first_czi_path = " + image_file_directory + first_czi ); // Dataset settings System.out.println("---------------------------------------------------------"); -System.out.println("Dataset:"); -angle_1 = System.getProperty( "angle_1" ); -angle_2 = System.getProperty( "angle_2" ); -angle_3 = System.getProperty( "angle_3" ); -angle_4 = System.getProperty( "angle_4" ); -angle_5 = System.getProperty( "angle_5" ); -channel_1 = System.getProperty( "channel_1" ); -channel_2 = System.getProperty( "channel_2" ); -illumination_1 = System.getProperty( "illumination_1" ); -rotation_around = System.getProperty( "rotation_around" ); +System.out.println("Angle Settings:"); + +// Angle settings +// Parses angles and determines the number of angles +// uses tokens of string angles to assemble the string for angle_string +// via StringBuilder +angles = System.getProperty( "angles" ); +System.out.println( "Angles = " + angles ); + +// Parses string angles +String delims = "[,]"; +String[] angle_token = angles.split(delims); + +// Builds string using the number of tokens and inserts the tokens in the string +StringBuilder angle_string = new StringBuilder(); +String angle_part; + + for ( int angle = 0; angle < angle_token.length; angle++) { + int num_angles = angle + 1; + angle_part = "angle_" + num_angles + "=" + angle_token[angle]; + angle_string.append(angle_part); + angle_string.append(" "); + + } + +System.out.println( angle_string ); + +System.out.println("---------------------------------------------------------"); +System.out.println("Channel Settings:"); + +// Channel settings +// This parses channels and determines the number of channels +// then uses the tokens of channels to assemble the necessary string +// for channel_string via StringBuilder +channels = System.getProperty( "channels" ); +System.out.println( "Channel Names = " + channels ); + +// Parses string channel_names +String delims = "[,]"; +String[] channel_token = channels.split(delims); + +// Builds string using the number of tokens and inserts the tokens in the string +StringBuilder channel_string = new StringBuilder(); +String channel_part; + + for ( int channel = 0; channel < channel_token.length; channel++) { + int num_channel = channel + 1; + channel_part = "channel_" + num_channel + "=" + channel_token[channel]; + channel_string.append(channel_part); + channel_string.append(" "); + + } + +System.out.println( "Channel String = " + channel_string ); + +System.out.println("---------------------------------------------------------"); +System.out.println("Illumination Settings:"); + +// Illuminatin settings +// This parses illumination and determines the number of illuminations +// then uses the tokens of illuminations to assemble the string for +// illum_string via StringBuilder +illumination = System.getProperty( "illumination" ); +System.out.println( "Illumination = " + illumination ); + +// Parses string illumination +String delims = "[,]"; +String[] illum_token = illumination.split(delims); + +// Builds string using the number of tokens and inserts the tokens in the string +StringBuilder illum_string = new StringBuilder(); +String illum_part; -System.out.println( "angle_1 = " + angle_1 ); -System.out.println( "angle_2 = " + angle_2 ); -System.out.println( "angle_3 = " + angle_3 ); -System.out.println( "angle_4 = " + angle_4 ); -System.out.println( "angle_5 = " + angle_5 ); -System.out.println( "channel_1 = " + channel_1 ); -System.out.println( "channel_2 = " + channel_2 ); -System.out.println( "illumination_1 = " + illumination_1 ); + for ( int illum= 0; illum< illum_token.length; illum++) { + int num_illum = illum + 1; + illum_part = "_______illumination_" + num_illum + "=" + illum_token[illum]; + illum_string.append(illum_part); + illum_string.append(" "); + + } + +System.out.println( illum_string ); + +System.out.println("---------------------------------------------------------"); +System.out.println("Rotation setting:"); + +rotation_around = System.getProperty( "rotation_around" ); System.out.println( "rotation_around = " + rotation_around ); // Calibaration @@ -63,19 +131,30 @@ System.out.println( "pixel_unit = " + pixel_unit ); // Executes Fiji plugin System.out.println("========================================================="); System.out.println("Start plugin:"); +System.out.println("Define Multi-View Dataset type_of_dataset=[Zeiss Lightsheet Z.1 Dataset (LOCI Bioformats)] " + + "xml_filename=" + first_xml_filename + ".xml " + + "browse=" + image_file_directory + first_czi + " " + + "first_czi=" + image_file_directory + first_czi + " " + + angle_string + + channel_string + + illum_string + + "modify_calibration " + + "modify_rotation_axis " + + "pixel_distance_x=" + pixel_distance_x + " " + + "pixel_distance_y=" + pixel_distance_y + " " + + "pixel_distance_z=" + pixel_distance_z + " " + + "pixel_unit=" + pixel_unit + " " + + "rotation_around=" + rotation_around + ""); + +try { IJ.run("Define Multi-View Dataset", "type_of_dataset=[Zeiss Lightsheet Z.1 Dataset (LOCI Bioformats)] " + "xml_filename=" + first_xml_filename + ".xml " + "browse=" + image_file_directory + first_czi + " " + "first_czi=" + image_file_directory + first_czi + " " + - "angle_1=" + angle_1 + " " + - "angle_2=" + angle_2 + " " + - "angle_3=" + angle_3 + " " + - "angle_4=" + angle_4 + " " + - "angle_5=" + angle_5 + " " + - "channel_1=" + channel_1 + " " + -// "channel_2=" + channel_2 + " " + // for dual channel comment out if single channel - "_______illumination_1=" + illumination_1 + " " + + angle_string + + channel_string + + illum_string + "modify_calibration " + "modify_rotation_axis " + "pixel_distance_x=" + pixel_distance_x + " " + @@ -83,6 +162,13 @@ IJ.run("Define Multi-View Dataset", "pixel_distance_z=" + pixel_distance_z + " " + "pixel_unit=" + pixel_unit + " " + "rotation_around=" + rotation_around + ""); - +} +catch ( e ) { + + print( "[define_czi] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/define_output.bsh b/spim_registration/timelapse/define_output.bsh old mode 100644 new mode 100755 index aae8803a6c3a59398858e7af6b8376e9cb6b6572..e2469feb053fc3a11f2b2bf0169f2dbf699ffa15 --- a/spim_registration/timelapse/define_output.bsh +++ b/spim_registration/timelapse/define_output.bsh @@ -25,7 +25,6 @@ System.out.println( "xml_filename = " + xml_filename ); System.out.println("========================================================="); System.out.println("Dataset:"); timepoints = System.getProperty( "timepoints" ); - image_file_pattern = System.getProperty( "image_file_pattern" ); type_of_dataset = System.getProperty( "type_of_dataset" ); multiple_timepoints = System.getProperty( "multiple_timepoints" ); @@ -37,7 +36,6 @@ System.out.println( "timepoints = " + timepoints ); System.out.println( "image_file_pattern = " + image_file_pattern ); System.out.println( "type_of_dataset = " + type_of_dataset ); System.out.println( "multiple_timepoints = " + multiple_timepoints ); - System.out.println( "multiple_illumination_directions = " + multiple_illumination_directions ); System.out.println( "multiple_angles = " + multiple_angles ); System.out.println( "imglib_container = " + imglib_container ); @@ -55,7 +53,7 @@ System.out.println( "pixel_distance_y = " + pixel_distance_y ); System.out.println( "pixel_distance_z = " + pixel_distance_z ); System.out.println( "pixel_unit = " + pixel_unit ); -// Channel Switch +// Channel switch System.out.println("========================================================="); System.out.println("Channel Switch:"); multiple_channels = System.getProperty( "multiple_channels" ); @@ -63,7 +61,31 @@ System.out.println( "multiple_channels = " + multiple_channels ); channels = System.getProperty( "channels" ); -IJ.run("Define Multi-View Dataset , type_of_dataset=[" + type_of_dataset + "] " + +if ( multiple_channels.equalsIgnoreCase( "NO (one channel)" ) ) + +{ + + channels=""; + +} + +else if ( multiple_channels.equalsIgnoreCase( "YES (one file per channel)" ) ) + +{ + + channels = "channels_=" + channels + " "; + +} + +else { + + System.out.println( "Channel switch setting gibberish" ); + +} + +System.out.println( "channels = " + channels ); + +System.out.println("Define Multi-View Dataset , type_of_dataset=[" + type_of_dataset + "] " + "xml_filename=[" + xml_filename + ".xml] " + "multiple_timepoints=[" + multiple_timepoints + "] " + "multiple_channels=[" + multiple_channels + "] " + @@ -78,11 +100,12 @@ IJ.run("Define Multi-View Dataset , type_of_dataset=[" + type_of_dataset + "] " "pixel_distance_x=" + pixel_distance_x + " " + "pixel_distance_y=" + pixel_distance_y + " " + "pixel_distance_z=" + pixel_distance_z + " " + - "pixel_unit=" + pixel_unit + ""); - + "pixel_unit=" + pixel_unit + ""); + // Executes Fiji plugin System.out.println("========================================================="); System.out.println("Start plugin:"); +try { IJ.run("Define Multi-View Dataset", "type_of_dataset=[" + type_of_dataset + "] " + "xml_filename=[" + xml_filename + ".xml] " + @@ -100,7 +123,14 @@ IJ.run("Define Multi-View Dataset", "pixel_distance_y=" + pixel_distance_y + " " + "pixel_distance_z=" + pixel_distance_z + " " + "pixel_unit=" + pixel_unit + ""); - +} +catch ( e ) { + + print( "[define_output] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/define_tif_zip.bsh b/spim_registration/timelapse/define_tif_zip.bsh old mode 100644 new mode 100755 index f03b52fec9445b4a3408983a8ade1af437162245..a5f401511eb4263335f9aa64b2ad8307d39ebee7 --- a/spim_registration/timelapse/define_tif_zip.bsh +++ b/spim_registration/timelapse/define_tif_zip.bsh @@ -24,28 +24,91 @@ System.out.println( "xml_filename = " + xml_filename ); // Dataset settings System.out.println("========================================================="); System.out.println("Dataset:"); -timepoints = System.getProperty( "timepoints" ); -channels = System.getProperty( "channels" ); -acquisition_angles = System.getProperty( "acquisition_angles" ); image_file_pattern = System.getProperty( "image_file_pattern" ); type_of_dataset = System.getProperty( "type_of_dataset" ); +timepoints = System.getProperty( "timepoints" ); +angles = System.getProperty( "angles" ); + +System.out.println( "image_file_pattern = " + image_file_pattern ); +System.out.println( "type_of_dataset = " + type_of_dataset ); +System.out.println( "timepoints = " + timepoints ); +System.out.println( "angles = " + angles ); + multiple_timepoints = System.getProperty( "multiple_timepoints" ); multiple_channels = System.getProperty( "multiple_channels" ); multiple_illumination_directions = System.getProperty( "multiple_illumination_directions" ); multiple_angles = System.getProperty( "multiple_angles" ); imglib_container = System.getProperty( "imglib_container" ); -System.out.println( "timepoints = " + timepoints ); -System.out.println( "channels = " + channels ); -System.out.println( "acquisition_angles = " + acquisition_angles ); -System.out.println( "image_file_pattern = " + image_file_pattern ); -System.out.println( "type_of_dataset = " + type_of_dataset ); System.out.println( "multiple_timepoints = " + multiple_timepoints ); System.out.println( "multiple_channels = " + multiple_channels ); System.out.println( "multiple_illumination_directions = " + multiple_illumination_directions ); System.out.println( "multiple_angles = " + multiple_angles ); System.out.println( "imglib_container = " + imglib_container ); +System.out.println("---------------------------------------------------------"); +System.out.println("Channel setting:"); + +// Channel switch: parses channels and determines if Single or Multi Channel +// assembles the appropriate string for the channel setting +channels = System.getProperty( "channels" ); + +String channel_string = null; + +String delims = "[,]"; +String[] channel_token = channels.split(delims); + +if (channels.equalsIgnoreCase("")) + { + System.out.println("Warning: There are no channels set"); + } + +else if ( channel_token.length == 1 ) + { + channel_string=""; + System.out.println("Single Channel"); + } + + else if ( channel_token.length > 1) + { + channel_string = "channels_=" + channels + " "; + System.out.println("Multi Channel"); + } + +System.out.println( "Channels = " + channel_string ); + + +System.out.println("---------------------------------------------------------"); +System.out.println("Illumination setting:"); +// Illuminatin switch: parses illumination and determines if there is a single +// or multiple illumination sides and then assembles the illum_string + +illumination = System.getProperty( "illumination" ); + +String illum_string = null; + +String delims = "[,]"; +String[] illum_token = illumination.split(delims); + +if (illumination.equalsIgnoreCase("")) + { + System.out.println("Warning: There are no illuminations set"); + } + + else if ( illum_token.length == 1 ) + { + illum_string=""; + System.out.println("One illumination side or fused illumination"); + } + + else if ( illum_token.length > 1) + { + illum_string = "illumination_=" + illumination + " "; + System.out.println("Dual Illumination sides"); + } + +System.out.println( "Illuminations = " + illum_string ); + // Calibaration System.out.println("========================================================="); System.out.println("Calibration:"); @@ -59,9 +122,30 @@ System.out.println( "pixel_distance_y = " + pixel_distance_y ); System.out.println( "pixel_distance_z = " + pixel_distance_z ); System.out.println( "pixel_unit = " + pixel_unit ); + +System.out.println("Define Multi-View Dataset , type_of_dataset=[" + type_of_dataset + "] " + + "xml_filename=[" + xml_filename + ".xml] " + + "multiple_timepoints=[" + multiple_timepoints + "] " + + "multiple_channels=[" + multiple_channels + "] " + + "_____multiple_illumination_directions=[" + multiple_illumination_directions + "] " + + "multiple_angles=[" + multiple_angles + "] " + + "image_file_directory=" + image_file_directory + " " + + "image_file_pattern=" + image_file_pattern + " " + + "timepoints_=" + timepoints + " " + + channel_string + + illum_string + + "acquisition_angles_=" + acquisition_angles + " " + + "calibration_type=[Same voxel-size for all views] calibration_definition=[User define voxel-size(s)]" + " " + + "imglib2_data_container=[" + imglib_container + "] " + + "pixel_distance_x=" + pixel_distance_x + " " + + "pixel_distance_y=" + pixel_distance_y + " " + + "pixel_distance_z=" + pixel_distance_z + " " + + "pixel_unit=" + pixel_unit + ""); + // Executes Fiji plugin System.out.println("========================================================="); System.out.println("Start plugin:"); +try { IJ.run("Define Multi-View Dataset", "type_of_dataset=[" + type_of_dataset + "] " + "xml_filename=[" + xml_filename + ".xml] " + @@ -72,15 +156,23 @@ IJ.run("Define Multi-View Dataset", "image_file_directory=" + image_file_directory + " " + "image_file_pattern=" + image_file_pattern + " " + "timepoints_=" + timepoints + " " + -// "channels_=" + channels + " " + // for dual channel comment out if single channel - "acquisition_angles_=" + acquisition_angles + " " + + channel_string + + illum_string + + "acquisition_angles_=" + angles + " " + "calibration_type=[Same voxel-size for all views] calibration_definition=[User define voxel-size(s)]" + " " + "imglib2_data_container=[" + imglib_container + "] " + "pixel_distance_x=" + pixel_distance_x + " " + "pixel_distance_y=" + pixel_distance_y + " " + "pixel_distance_z=" + pixel_distance_z + " " + "pixel_unit=" + pixel_unit + ""); - +} +catch ( e ) { + + print( "[define_tif_zip] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/export.bsh b/spim_registration/timelapse/export.bsh old mode 100644 new mode 100755 index d7d064b4c9a544d15e508e6399f4a33db1854ce1..1e928a8113f474ce8523b99124eb68f196db4a1b --- a/spim_registration/timelapse/export.bsh +++ b/spim_registration/timelapse/export.bsh @@ -45,31 +45,33 @@ subsampling_factors = System.getProperty( "subsampling_factors" ); hdf5_chunk_sizes = System.getProperty( "hdf5_chunk_sizes" ); timepoints_per_partition = System.getProperty( "timepoints_per_partition" ); setups_per_partition = System.getProperty( "setups_per_partition" ); - +run_only_job_number = System.getProperty( "run_only_job_number" ); System.out.println( "subsampling_factors=" + subsampling_factors); System.out.println( "hdf5_chunk_sizes=" + hdf5_chunk_sizes ); System.out.println( "timepoints_per_partition=" + timepoints_per_partition ); System.out.println( "setups_per_partition=" + setups_per_partition ); - -int run_only_job_number = Integer.parseInt( System.getProperty( "run_only_job_number" ) ); System.out.println( "run_only_job_number=" + run_only_job_number ); // Activate cluster processing System.out.println("========================================================="); -try{ System.out.println("Cluster setting:"); +try { IJ.run("Toggle Cluster Processing", "display_cluster"); } -catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); - //important to fail the process if exception occurs - runtime.exit(1); +catch ( e ) { + + print( "[export::cluster setting] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + } + // Executes Fiji plugin System.out.println("========================================================="); System.out.println("Start plugin:"); -try{ + +try { IJ.run("As HDF5", "select_xml=" + image_file_directory + first_xml_filename + ".xml " + "resave_angle=[" + resave_angle + "] " + @@ -86,11 +88,14 @@ IJ.run("As HDF5", "use_deflate_compression " + "export_path=" + image_file_directory + hdf5_xml_filename ); } -catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); - //important to fail the process if exception occurs - runtime.exit(1); +catch ( e ) { + + print( "[export::resaving] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + } + /* shutdown */ System.exit(0); diff --git a/spim_registration/timelapse/export_output.bsh b/spim_registration/timelapse/export_output.bsh old mode 100644 new mode 100755 index af2019100282da641228067bd85c2c7757e58394..f05798a6b9e011e8d1b8737940a6a7cb08c5ca8e --- a/spim_registration/timelapse/export_output.bsh +++ b/spim_registration/timelapse/export_output.bsh @@ -54,26 +54,22 @@ System.out.println( "setups_per_partition=" + setups_per_partition ); System.out.println( "run_only_job_number=" + run_only_job_number ); // Add a switch for choosing between 16 or 32 bit - - output_data_type = System.getProperty( "output_data_type" ); - System.out.println( "Output Datatype = " + output_data_type ); +convert_32bit = System.getProperty( "convert_32bit" ); -if ( output_data_type.equalsIgnoreCase( "16Bit" ) ) +if ( output_data_type.equalsIgnoreCase( "32Bit" ) ) { - data_string = "convert_32bit=convert_32bit"; + data_string = "convert_32bit=" + convert_32bit; } -else if ( output_data_type.equalsIgnoreCase( "32Bit" ) ) +else if ( output_data_type.equalsIgnoreCase( "16Bit" ) ) { data_string = ""; } System.out.println( "Data string = " + data_string ); - - // Activate cluster processing System.out.println("========================================================="); System.out.println("Cluster setting:"); @@ -81,7 +77,7 @@ try{ IJ.run("Toggle Cluster Processing", "display_cluster"); } catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); + print( "[export_output::cluster setting] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } @@ -105,11 +101,10 @@ IJ.run("As HDF5", "run_only_job_number=" + run_only_job_number + " " + "use_deflate_compression " + "export_path=" + image_file_directory + hdf5_xml_filename + " " + - data_string + - ); + data_string + ""); } catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); + print( "[export_output::resaving] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } diff --git a/spim_registration/timelapse/fusion.bsh b/spim_registration/timelapse/fusion.bsh old mode 100644 new mode 100755 index 5731ddb35f66bf877091c2363b5c4c022fb739c7..79f9d54911da2bef0b7b3f57e4d64ce62dbdf6d7 --- a/spim_registration/timelapse/fusion.bsh +++ b/spim_registration/timelapse/fusion.bsh @@ -19,6 +19,7 @@ System.out.println( "Start to load Parameters:" ); System.out.println( "-------------------------------------------------------" ); System.out.println( "Load xml file: " ); image_file_directory = System.getProperty( "image_file_directory" ); + merged_xml = System.getProperty( "merged_xml" ); if ( ! merged_xml.endsWith(".xml") ) merged_xml = merged.xml + ".xml"; @@ -28,7 +29,7 @@ System.out.println( "xml_path=" + image_file_directory + merged_xml + ".xml" ); // Load general Parameters System.out.println( "-------------------------------------------------------" ); System.out.println( "General parameters: " ); -int parallel_timepoints = Integer.parseInt(System.getProperty( "parallel_timepoints" )); +int parallel_timepoints = Integer.parseInt( System.getProperty( "parallel_timepoints" ) ); process_timepoint = System.getProperty( "process_timepoint" ); process_channel = System.getProperty( "process_channel" ); process_illumination = System.getProperty( "process_illumination" ); @@ -74,7 +75,6 @@ System.out.println( "imglib2_data_container=" + imglib2_data_container ); // Execute Fiji Plugin System.out.println( "=======================================================" ); System.out.println( "Starting Fusion" ); - try{ IJ.run("Fuse/Deconvolve Dataset", "select_xml=" + image_file_directory + merged_xml + " " + @@ -98,17 +98,16 @@ IJ.run("Fuse/Deconvolve Dataset", "imglib2_container=" + imglib2_container_fusion + " " + "process_views_in_paralell=All " + "interpolation=[" + interpolation + "] " + - "blend " + - "content-based " + + //"blend " + + //"content-based " + "output_file_directory=" + image_file_directory + " " + "lossless " + "imglib2_data_container=[" + imglib2_data_container + "]"); } catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); + print( "[Contentbased multiview fusion] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } - /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/registration.bsh b/spim_registration/timelapse/registration.bsh old mode 100644 new mode 100755 index 849808589f1891bbadc20f0f08f98454e90a5b8f..d6872232b191687a082c3e8f591979528318672e --- a/spim_registration/timelapse/registration.bsh +++ b/spim_registration/timelapse/registration.bsh @@ -1,12 +1,18 @@ -import ij.IJ; +// Load Fiji dependencies +import ij.IJ; // calls imagej +import ij.Prefs; // calls imagej settings import ij.ImagePlus; import java.lang.Runtime; import java.io.File; import java.io.FilenameFilter; - +import java.lang.Object; + runtime = Runtime.getRuntime(); System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); +//Prefs.setThreads(1); // defines the number of threads allowed +//print("Threads: "+Prefs.getThreads()); // prints thread setting in output + System.out.println("Start loading parameters"); // select xml @@ -18,25 +24,20 @@ 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 = Integer.parseInt(System.getProperty( "parallel_timepoints" )); +int parallel_timepoints = Integer.parseInt(System.getProperty( "parallel_timepoints" )); unique_id = 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" ); +reg_process_timepoint = System.getProperty( "reg_process_timepoint" ); +reg_process_illumination = System.getProperty( "reg_process_illumination" ); +reg_process_angle = System.getProperty( "reg_process_angle" ); 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 ); +System.out.println( "process_timepoints = " + reg_process_timepoint ); +System.out.println( "process_illumination = " + reg_process_illumination ); +System.out.println( "process_angle = " + reg_process_angle ); // Interest point detection parameters System.out.println( "-------------------------------------------------------" ); @@ -54,53 +55,215 @@ 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" ); +significance = System.getProperty( "significance" ); 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 ); +System.out.println( "significance = " + significance ); + + +// detection_min_max = System.getProperty( "detection_min_max" ); +// System.out.println( "detection_min_max = " + detection_min_max ); +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Channel setting for Detection: " ); + +// Channel setting for Difference-of-Mean detection +// parses channels and takes from there the number of channels +// takes from reg_process_channel if it is Single Channel, Dual Channel or Dual Channel +// were one Channel contains the beads +// from this it decides which string to assemble +reg_process_channel = System.getProperty( "reg_process_channel" ); +System.out.println( "process_channel = " + reg_process_channel ); + +reg_processing_channel = System.getProperty( "reg_processing_channel" ); +System.out.println( "processing_channel = channel " + reg_processing_channel ); + +channels = System.getProperty( "channels" ); +System.out.println( "Channels = " + channels ); + +reg_radius_1 = System.getProperty( "reg_radius_1" ); +System.out.println( "reg_radius_1 = " + reg_radius_1 ); + +reg_radius_2 = System.getProperty( "reg_radius_2" ); +System.out.println( "reg_radius_2 = " + reg_radius_2 ); + +reg_threshold = System.getProperty( "reg_threshold" ); +System.out.println( "reg_threshold = " + reg_threshold); + +// Splits up channels, reg_radius_1, reg_radius_2 and reg_threshold +String delims = "[,]"; +String[] channel_token = channels.split(delims); +String[] radius_1_token = reg_radius_1.split(delims); +String[] radius_2_token = reg_radius_2.split(delims); +String[] threshold_token = reg_threshold.split(delims); + +String channel_string = ""; +String processing_channel_string = ""; +StringBuilder channel_string_multi = new StringBuilder(); + +// If there are no channels set returns an error +if (channels.equalsIgnoreCase("")) +{ + System.out.println("Warning: There are no channels set"); +} + +// Returns an Error if there is one channel in channels but multiple settings in radius and or threshold +else if ( channel_token.length == 1 && (radius_1_token.length > 1 || radius_2_token.length > 1 || threshold_token.length > 1 ) ) +{ + System.out.println( "Error: Only one channel detected but multiple channel settings for radius or threshold" ); +} + +// Assembles String for Singel Channel +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length == 1 ) +{ + processing_channel_string = ""; + channel_string_multi.append(""); + channel_string = "interest_point_specification=[Advanced ...] " + + "radius_1=" + reg_radius_1 + " " + + "radius_2=" + reg_radius_2 + " " + + "threshold=" + reg_threshold + " " + + "find_maxima"; +} + +// Dual Channels both Channels contain beads +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length > 1 ) +{ + // Assembles String using StringBuilder for 2 Channels + for (int channel=0; channel < channel_token.length; channel++ ) + { + String channel_part = "interest_point_specification_(channel_" + channel_token[channel] + ")=[Advanced ...] " + + "radius_1_" + channel_token[channel] + "=" + radius_1_token[channel] + " " + + "radius_2_" + channel_token[channel] + "=" + radius_2_token[channel] + " " + + "threshold_" + channel_token[channel] + "=" + threshold_token[channel] + " " + + "find_maxima_" + channel_token[channel]; + channel_string_multi.append(channel_part); + channel_string_multi.append(" "); + } + +} + +// Returns an Error if set to Dual Channel one Channel contains beads but there is only one channel in channels +else if ( reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && channel_token.length == 1 ) +{ + System.out.println( "Error: reg_process_channel or channels set incorrectly" ); +} + +// Returns and Error if set to Dual Channel processing one channel contains the beads but there are multiple settings in radius and or threshold +else if ( reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && (radius_1_token.length > 1 || radius_2_token.length > 1 || threshold_token.length > 1 ) ) +{ + System.out.println( "Error: You said you wanted to process only one channel but there are multiple settings for radius or threshold" ); +} + +// Assembles String for Dual Channel but only one Channel contains beads +else if (reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && channel_token.length > 1) +{ + channel_string_multi.append(""); + processing_channel_string = "processing_channel=[channel " + reg_processing_channel + "] "; + channel_string = "interest_point_specification=[Advanced ...] " + + "radius_1=" + reg_radius_1 + " " + + "radius_2=" + reg_radius_2 + " " + + "threshold=" + reg_threshold + " " + + "find_maxima"; +} + +// Returns and Error if no conditions above are met +else +{ + System.out.println( "Error: Incorrect settings" ); +} + +System.out.println( "Processing Channel = " + processing_channel_string ); +System.out.println( "Channel String: " + channel_string ); +System.out.println( reg_process_channel ); +System.out.println( "Multi channel String: " + channel_string_multi ); -//activate cluster processing +// Channel Setting Registration +System.out.println( "-------------------------------------------------------" ); +System.out.println( "Channel Setting for Registration: " ); +// parses channels and takes from there the number of channels +// takes from reg_process_channel if it is Single Channel, Dual Channel or Dual Channel +// were one Channel contains the beads +// from this it decides which string to assemble + +reg_interest_points_channel = System.getProperty( "reg_interest_points_channel" ); +System.out.println( "reg_interest_points_channel = " + reg_interest_points_channel ); + +// Splits up channels, reg_interest_points_channel +// String delims = "[,]"; +// String[] channel_token = channels.split(delims); +// Splits up channels, reg_interest_points_channel +String[] interest_token = reg_interest_points_channel.split(delims); +String reg_single_channel_string =""; +StringBuilder reg_multi_channel_string = new StringBuilder(); + +// If there are no channels set returns an error +if (channels.equalsIgnoreCase("")) +{ + System.out.println("Warning: There are no channels set"); +} + +// Assembles string for Single Channel registration +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length == 1 && interest_token.length == 1 ) +{ + reg_multi_channel_string.append( "" ); + reg_single_channel_string = "interest_points_channel_" + channels + "=" + reg_interest_points_channel + " "; +} + +// Returns error if Multi Channels are selected but not enough settings in channels or reg_interest_points_channel +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && ( channel_token.length < 1 || interest_token.length < 1) ) +{ + System.out.println( "Error: Multi Channel selected but only one setting in channels or reg_interest_points_channel" ); +} + +// Assembles string for Multi Channel registration +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length > 1 ) +{ + for (int channel=0; channel < channel_token.length; channel++ ) + { + String channel_part = "interest_points_channel_" + channel_token[channel] + "=" + interest_token[channel] + " "; + reg_multi_channel_string.append( channel_part ); + reg_multi_channel_string.append(" "); + } +} + +// Returns error of Multi Channels one Channel contains the beads is selected but not enough settings in channels or reg_interest_points_channel +else if (reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && ( channel_token.length < 1 || interest_token.length < 1 )) +{ + System.out.println( "Error: Multi Channel one Channel contains beads selected but only one setting in channls or reg_interest_points_channel" ); +} + +// Assembles string for Multi Channel Processing one Channel Contains the beads +else if (reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && channel_token.length > 1 && interest_token.length > 1) +{ + for (int channel=0; channel < channel_token.length; channel++ ) + { + String channel_part = "interest_points_channel_" + channel_token[channel] + "=" + interest_token[channel] + " "; + reg_multi_channel_string.append( channel_part ); + reg_multi_channel_string.append(" "); + } +} + + System.out.println( "reg_single_channel_string = " + reg_single_channel_string ); + System.out.println( "reg_multi_channel_string = " + reg_multi_channel_string ); + +// activate cluster processing System.out.println( "=======================================================" ); try { IJ.run("Toggle Cluster Processing", "display_cluster"); @@ -112,73 +275,107 @@ catch ( e ) { runtime.exit(1); } -System.out.println( "Activated Cluster Processing" ); +System.out.println( "Activated Cluster Processing" ); -//interest point detection +// interest point detection System.out.println( "=======================================================" ); System.out.println( "Starting Detection of Interest Points" ); + +System.out.println("Detect Interest Points for Registration , select_xml=" + xml_path + xml_filename + ".xml " + + "unique_id=" + unique_id + " " + + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + + "process_timepoint=[" + reg_process_timepoint + "] " + + processing_channel_string + + "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 + "] " + + channel_string + "" + + channel_string_multi + "" + + ""); + try { IJ.run("Detect Interest Points for Registration", "select_xml=" + xml_path + xml_filename + ".xml " + "unique_id=" + unique_id + " " + - "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 + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + + "process_timepoint=[" + reg_process_timepoint + "] " + + processing_channel_string + "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"); + channel_string + "" + + channel_string_multi + "" + + ""); } catch ( e ) { - print( "[registration::interest_points] caught exception: "+e ); + print( "[registration::detection of interest_points] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } -//registration based on interest point detection + +// registration based on interest point detection System.out.println( "=======================================================" ); System.out.println( "Starting Registration" ); +System.out.println("Register Dataset based on Interest Points , select_xml=" + xml_path + xml_filename + ".job_" + unique_id + ".xml " + + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + + "process_timepoint=[" + reg_process_timepoint + "] " + + "xml_output=[Do not process on cluster] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "registration_algorithm=[" + registration_algorithm + "] " + + "type_of_registration=[" + type_of_registration + "] " + + reg_single_channel_string + + reg_multi_channel_string + + "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 + " " + + "significance=" + significance + ""); + try { - IJ.run("Register Dataset based on Interest Points", - "select_xml=" + xml_path + xml_filename + ".job_" + unique_id + ".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); +IJ.run("Register Dataset based on Interest Points", + "select_xml=" + xml_path + xml_filename + ".job_" + unique_id + ".xml " + + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + + "process_timepoint=[" + reg_process_timepoint + "] " + + "xml_output=[Do not process on cluster] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "registration_algorithm=[" + registration_algorithm + "] " + + "type_of_registration=[" + type_of_registration + "] " + + reg_single_channel_string + + reg_multi_channel_string + + "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 + " " + + "significance=" + significance + ""); } catch ( e ) { - print( "[registration::based_on_interestpoints] caught exception: "+e ); + print( "[registration::registration of interest points] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } - /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/timelapse_registration.bsh b/spim_registration/timelapse/timelapse_registration.bsh old mode 100644 new mode 100755 index 76290e3288480b86bdb3f95aa30304c4b14f4ef3..82c051815af93ceee782daab02e48dd8c0f7abc2 --- a/spim_registration/timelapse/timelapse_registration.bsh +++ b/spim_registration/timelapse/timelapse_registration.bsh @@ -16,30 +16,27 @@ print("Threads: "+Prefs.getThreads()); // prints thread setting in output System.out.println("---------------------------------------------------------"); System.out.println("Xml file:"); +xml_path = System.getProperty( "image_file_directory" ); + xml_path = System.getProperty( "image_file_directory" ); merged_xml = System.getProperty( "merged_xml" ); if ( ! merged_xml.endsWith(".xml") ) merged_xml = merged.xml + ".xml"; -System.out.println( "selected_xml = " + xml_path + merged_xml + ".xml"); +System.out.println( "selected_xml = " + xml_path + merged_xml ); // General Registration Parameters and Channel Settings System.out.println("---------------------------------------------------------"); System.out.println( "General parameters: " ); + timelapse_process_timepoints = System.getProperty( "timelapse_process_timepoints" ); -process_channel_timelapse = System.getProperty( "process_channel_timelapse" ); -process_illumination = System.getProperty( "process_illumination" ); -process_angle = System.getProperty( "process_angle" ); -channel_1 = System.getProperty( "channel_1" ); -channel_2 = System.getProperty( "channel_2" ); +reg_process_illumination = System.getProperty( "reg_process_illumination" ); +reg_process_angle = System.getProperty( "reg_process_angle" ); System.out.println( "process_timepoints = " + timelapse_process_timepoints ); -System.out.println( "process_channel = " + process_channel_timelapse ); -System.out.println( "process_illumination = " + process_illumination ); -System.out.println( "process_angle = " + process_angle ); -System.out.println( "channel_1 = " + channel_1 ); -System.out.println( "channel_2 = " + channel_2 ); - +System.out.println( "process_illumination = " + reg_process_illumination ); +System.out.println( "process_angle = " + reg_process_angle ); + // Timelapse registration Parameter System.out.println("---------------------------------------------------------"); System.out.println( "Timelapse Registration: " ); @@ -49,13 +46,11 @@ System.out.println( "reference_timepoint=" + reference_timepoint ); type_of_registration_timelapse = System.getProperty( "type_of_registration_timelapse" ); registration_algorithm = System.getProperty( "registration_algorithm" ); -reg_1_interest_points_channel = System.getProperty( "reg_1_interest_points_channel" ); -reg_2_interest_points_channel = System.getProperty( "reg_2_interest_points_channel" ); // Dual Channel + System.out.println( "type_of_registration = " + type_of_registration_timelapse ); System.out.println( "registration_algorithm = " + registration_algorithm ); -System.out.println( "interest_points_channel_" + channel_1 + " = " + reg_1_interest_points_channel ); -System.out.println( "interest_points_channel_" + channel_2 + " = " + reg_2_interest_points_channel ); + transformation_model = System.getProperty( "transformation_model" ); model_to_regularize_with = System.getProperty( "model_to_regularize_with" ); @@ -63,25 +58,120 @@ float lambda = Float.parseFloat( System.getProperty( "lambda" ) ); int allowed_error_for_ransac = Integer.parseInt( System.getProperty( "allowed_error_for_ransac" ) ); significance = System.getProperty( "significance" ); -System.out.println( "transformation = " + transformation ); +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( "significance = " + significance ); +// Timelapse registration Parameter +System.out.println("---------------------------------------------------------"); +System.out.println( "Channel Settings: " ); +// Channel Setting Registration +// parses channels and takes from there the number of channels +// takes from reg_process_channel if it is Single Channel, Dual Channel or Dual Channel +// were one Channel contains the beads +// from this it decides which string to assemble + +reg_process_channel = System.getProperty( "reg_process_channel" ); +System.out.println( "process_channel = " + reg_process_channel ); + +channels = System.getProperty( "channels" ); +System.out.println( "Channels = " + channels ); + +reg_interest_points_channel = System.getProperty( "reg_interest_points_channel" ); +System.out.println( "reg_interest_points_channel = " + reg_interest_points_channel ); + +// Splits up channels, reg_interest_points_channel +String delims = "[,]"; +String[] channel_token = channels.split(delims); +String[] interest_token = reg_interest_points_channel.split(delims); + +String reg_single_channel_string = ""; +StringBuilder reg_multi_channel_string = new StringBuilder(); + +if (channels.equalsIgnoreCase("")) +{ + System.out.println("Warning: There are no channels set"); +} + +// Assembles string for Single Channel registration +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length == 1 ) +{ + reg_multi_channel_string.append( "" ); + reg_single_channel_string = "interest_points_channel_" + channels + "=" + reg_interest_points_channel + " "; +} + +// Assembles string for Multi Channel registration +else if (reg_process_channel.equalsIgnoreCase( "All channels" ) && channel_token.length > 1 ) +{ + for (int channel=0; channel < channel_token.length; channel++ ) + + { + String channel_part = "interest_points_channel_" + channel_token[channel] + "=" + interest_token[channel] + " "; + reg_multi_channel_string.append( channel_part ); + reg_multi_channel_string.append(" "); + } +} + +// Returns error of Multi Channels one Channel contains the beads is selected but not enough settings in channels or reg_interest_points_channel +else if (reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && ( channel_token.length < 1 || interest_token.length < 1 )) +{ + System.out.println( "Error: Multi Channel one Channel contains beads selected but only one setting in channls or reg_interest_points_channel" ); +} + +// Assembles string for Multi Channel Processing one Channel Contains the beads +else if (reg_process_channel.equalsIgnoreCase( "Single channel (Select from List)" ) && channel_token.length > 1 && interest_token.length > 1 ) +{ + for (int channel=0; channel < channel_token.length; channel++ ) + + { + String channel_part = "interest_points_channel_" + channel_token[channel] + "=" + interest_token[channel] + " "; + reg_multi_channel_string.append( channel_part ); + reg_multi_channel_string.append(" "); + } + +} + +System.out.println( "reg_single_channel_string = " + reg_single_channel_string ); +System.out.println( "reg_multi_channel_string = " + reg_multi_channel_string ); + + System.out.println( "=======================================================" ); System.out.println( "Starting Timelapse Registration" ); +System.out.println( "Register Dataset based on Interest Points , select_xml=" + xml_path + merged_xml + " " + + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + + "process_timepoint=[" + timelapse_process_timepoints + "] " + + "registration_algorithm=[" + registration_algorithm + "] " + + "type_of_registration=[" + type_of_registration_timelapse + "] " + + reg_multi_channel_string + + reg_single_channel_string + +// "interest_points_channel_" + channel_1 + "=" + reg_1_interest_points_channel + " " + +// "interest_points_channel_" + channel_2 + "=" + reg_2_interest_points_channel + " " + // Dual Channel + "reference=" + reference_timepoint + " " + + "consider_each_timepoint_as_rigid_unit " + + "transformation=" + transformation_model + " " + + "regularize_model " + + "model_to_regularize_with=" + model_to_regularize_with + " " + + "lamba=" + lambda + " " + + "allowed_error_for_ransac=" + allowed_error_for_ransac + " " + + "significance=" + significance + ""); + try { IJ.run("Register Dataset based on Interest Points", - "select_xml=" + xml_path + merged_xml + " " + - "process_angle=[" + process_angle + "] " + - "process_channel=[" + process_channel_timelapse + "] " + - "process_illumination=[" + process_illumination + "] " + + "select_xml=" + xml_path + merged_xml + " " + + "process_angle=[" + reg_process_angle + "] " + + "process_channel=[" + reg_process_channel + "] " + + "process_illumination=[" + reg_process_illumination + "] " + "process_timepoint=[" + timelapse_process_timepoints + "] " + "registration_algorithm=[" + registration_algorithm + "] " + "type_of_registration=[" + type_of_registration_timelapse + "] " + - "interest_points_channel_" + channel_1 + "=" + reg_1_interest_points_channel + " " + + reg_multi_channel_string + + reg_single_channel_string + +// "interest_points_channel_" + channel_1 + "=" + reg_1_interest_points_channel + " " + // "interest_points_channel_" + channel_2 + "=" + reg_2_interest_points_channel + " " + // Dual Channel "reference=" + reference_timepoint + " " + "consider_each_timepoint_as_rigid_unit " + @@ -94,11 +184,10 @@ IJ.run("Register Dataset based on Interest Points", } catch ( e ) { - print( "[deconvolution-GPU] caught exception: "+e ); + print( "[registration::timelapse] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); } - /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/tomancak_test_cluster.yaml b/spim_registration/timelapse/tomancak_test_cluster.yaml old mode 100644 new mode 100755 index fa7788278a9544938599cef4df97a171c7445811..77c76210cd21385a3cbff9cf250fd1a697657831 --- a/spim_registration/timelapse/tomancak_test_cluster.yaml +++ b/spim_registration/timelapse/tomancak_test_cluster.yaml @@ -1,110 +1,113 @@ -common: - { +common: { # directory that contains the bean shell scripts - bsh_directory: "/home/steinbac/development/schmied-snakemake-workflows/spim_registration/timelapse/", - directory_cuda: "/lustre/projects/hpcsupport/steinbac/unicore/christopher/unicore_jobs/Fiji.app.cuda_new/lib/", - fiji-app: "/projects/hpcsupport/steinbac/unicore/christopher/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64", + bsh_directory: "/projects/pilot_spim/Christopher/snakemake-workflows/spim_registration/timelapse/", + directory_cuda: "/sw/users/schmied/packages/2015-06-08_Fiji.app.cuda/lib/", + fiji-app: "/sw/users/schmied/packages/2015-06-08_Fiji.app.cuda/ImageJ-linux64", fiji-prefix: "/sw/bin/xvfb-run -a", first_xml_filename: "test_unicore", - fusion_switch: "deconvolution", hdf5_xml_filename: '"hdf5_test_unicore"', merged_xml: "hdf5_test_unicore_merge", - ntimepoints: 5 - } - -deconvolution: - { - Tikhonov_parameter: '0.0006', - bsh_file: "deconvolution_GPU.bsh", - compute: '"in 512x512x512 blocks"', - compute_on: '"GPU (Nvidia CUDA via JNA)"', - detections_to_extract_psf_for_channel_0: '"beads"', - detections_to_extract_psf_for_channel_1: '"beads"', - imglib2_container: '"ArrayImg"', - iterations: '5', - maximal_x: '509', - maximal_y: '970', - maximal_z: '243', - minimal_x: '95', - minimal_y: '-8', - minimal_z: '-174', - osem_acceleration: '"1 (balanced)"', - process_angle: '"All angles"', - process_channel: '"All channels"', - process_illumination: '"All illuminations"', - process_timepoint: '"Single Timepoint (Select from List)"', - psf_estimation: '"Extract from beads"', - psf_size_x: '19', - psf_size_y: '19', - psf_size_z: '25', - type_of_iteration: '"Efficient Bayesian - Optimization I (fast, precise)"' - } - -define_xml_czi: - { - angle_1: '0', - angle_2: '72', - angle_3: '144', - angle_4: '216', - angle_5: '288', - bsh_file: "define_czi.bsh", - channel_1: "green", - channel_2: "red", - first_czi: "2015-04-11_LZ2_Stock68_3.czi", - illumination_1: '0', + ntimepoints: 5, + angles: "0,72,144,216,288", + channels: "green", + illumination: "0", pixel_distance_x: '0.28590106964', pixel_distance_y: '0.28590106964', pixel_distance_z: '1.50000', pixel_unit: "um", - rotation_around: "X-Axis" + fusion_switch: "deconvolution" + # fusion_switch: "fusion" + } + +define_xml_czi: { + first_czi: "2015-04-11_LZ2_Stock68_3.czi", + rotation_around: "X-Axis", + bsh_file: "define_czi.bsh" } -define_xml_tif: - { - acquisition_angles: '0,72,144,216,288', - bsh_file: "define_tif_zip.bsh", - channels: '0', +define_xml_tif: { image_file_pattern: 'img_TL{{t}}_Angle{{a}}.tif', imglib_container: '"ArrayImg (faster)"', multiple_angles: '"YES (one file per angle)"', multiple_channels: '"NO (one channel)"', multiple_illumination_directions: '"NO (one illumination direction)"', multiple_timepoints: '"YES (one file per time-point)"', - pixel_distance_x: '0.28590106964', - pixel_distance_y: '0.28590106964', - pixel_distance_z: '1.50000', - pixel_unit: "um", - type_of_dataset: '"Image Stacks (ImageJ Opener)"' + type_of_dataset: '"Image Stacks (ImageJ Opener)"', + bsh_file: "define_tif_zip.bsh" + } + +resave_hdf5: { + hdf5_chunk_sizes: '"{{ {{32,32,4}}, {{32,32,4}}, {{16,16,16}}, {{16,16,16}} }}"', + resave_angle: '"All angles"', + resave_channel: '"All channels"', + resave_illumination: '"All illuminations"', + resave_timepoint: '"All Timepoints"', + setups_per_partition: '0', + subsampling_factors: '"{{ {{1,1,1}}, {{2,2,1}}, {{4,4,1}}, {{8,8,1}} }}"', + timepoints_per_partition: '1', + bsh_file: "export.bsh" } - -external_transform: - { - angle: '"All angles"', - apply_transformation: '"Current view transformations - (appends to current transforms)"', - bsh_file: "transform.bsh", - channel: '"All channels"', - define_mode_transform: '"Matrix"', - illumination: '"All illuminations"', - 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"', - timepoint: '"All Timepoints"', - transformation: '"Rigid"' +registration: { + # "Single Channel" is not a valid choice for "Process_channel" + reg_process_channel: '"All channels"', + reg_processing_channel: '"green"', + reg_interest_points_channel: '"beads"', + reg_radius_1: '2', + reg_radius_2: '3', + reg_threshold: '0.005', + initial_sigma: '1.8', + threshold_gaussian: '0.0080', + type_of_detection: '"Difference-of-Mean (Integral image based)"', + label_interest_points: '"beads"', + reg_process_timepoint: '"Single Timepoint (Select from List)"', + reg_process_angle: '"All angles"', + reg_process_illumination: '"All illuminations"', + subpixel_localization: '"3-dimensional quadratic fit"', + detection_min_max: "find_maxima", + type_of_registration: '"Register timepoints individually"', + algorithm: '"Fast 3d geometric hashing (rotation invariant)"', + transformation_model: "Affine", + allowed_error_for_ransac: '5', + significance: '10', + fix_tiles: '"Fix first tile"', + map_back_tiles: '"Map back to first tile using rigid model"', + model_to_regularize_with: "Rigid", + lambda: '0.10', + imglib_container: '"ArrayImg (faster)"', + bsh_file: "registration.bsh" + } + +xml_merge: { + bsh_file: "xml_merge.bsh" + } + +timelapse: { + reference_timepoint: '0', + type_of_registration_timelapse: '"Match against one reference timepoint (no global optimization)"', + timelapse_process_timepoints: '"All Timepoints"', + bsh_file: "timelapse_registration.bsh" + } + +Dublicate_transformations: { + source_dublication: "red", + target_dublication: "green", + bsh_file: "dublicate_channel.bsh" } fusion: { bsh_file: "fusion.bsh", - downsample: '1', + downsample: '4', fused_image: '"Append to current XML Project"', imglib2_container_fusion: '"ArrayImg"', imglib2_data_container: '"ArrayImg (faster)"', interpolation: '"Linear Interpolation"', - maximal_x: '1019', - maximal_y: '1941', - maximal_z: '486', minimal_x: '190', minimal_y: '-16', minimal_z: '-348', + maximal_x: '1019', + maximal_y: '1941', + maximal_z: '486', pixel_type: '"16-bit unsigned integer"', process_angle: '"All angles"', process_channel: '"All channels"', @@ -113,77 +116,71 @@ fusion: { process_views_in_paralell: '"All"', xml_output: '"Save every XML with user-provided unique id"' } + +external_transform: { + # channel setting: '"all_channels"' + channel_setting: '"green"', + transform_timepoint: '"All Timepoints"', + transform_angle: '"All angles"', + transform_channel: '"All channels"', + # illumination setting only one illumination side + transform_illumination: '"All illuminations"', + 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"', + transformation: '"Rigid"', + bsh_file: "transform.bsh" + } + +deconvolution: { + iterations: '1', + minimal_x_deco: '190', + minimal_y_deco: '-16', + minimal_z_deco: '-348', + maximal_x_deco: '1019', + maximal_y_deco: '1941', + maximal_z_deco: '486', + detections_to_extract_psf_for_channel: '"beads"', + process_timepoint: '"Single Timepoint (Select from List)"', + process_angle: '"All angles"', + process_channel: '"All channels"', + process_illumination: '"All illuminations"', + Tikhonov_parameter: '0.0006', + compute: '"in 512x512x512 blocks"', + compute_on: '"GPU (Nvidia CUDA via JNA)"', + imglib2_container: '"ArrayImg"', + osem_acceleration: '"1 (balanced)"', + psf_estimation: '"Extract from beads"', + psf_size_x: '19', + psf_size_y: '19', + psf_size_z: '25', + type_of_iteration: '"Efficient Bayesian - Optimization I (fast, precise)"', + bsh_file: "deconvolution_GPU.bsh" + } hdf5_output: { - bsh_file_define: "define_output.bsh", - bsh_file_hdf5: "export_output.bsh", - convert_32bit: '"[Use min/max of first image (might saturate intenities over time)]"', - output_channels: "green", - output_data_type: "32Bit", - output_hdf5_xml: '"hdf5_fused_Stock68"', - output_illumination_directions: '"NO (one illumination direction)"', - output_image_file_pattern: 'TP{{t}}_Ch{{c}}_Ill0_Ang0,72,144,216,288.tif', - output_imglib_container: '"ArrayImg (faster)"', - output_multiple_angles: '"NO (one angle)"', + output_image_file_pattern: 'TP{{t}}_Chgreen_Ill0_Ang0,72,144,216,288.tif', + output_xml: '"fused_Single_Channel"', + output_hdf5_xml: '"hdf5_fused_Single_Channel"', output_multiple_channels: '"NO (one channel)"', - output_multiple_timepoints: '"YES (one file per time-point)"', + output_timepoints: '0-4', output_pixel_distance_x: 0.5718, output_pixel_distance_y: 0.5718, output_pixel_distance_z: 0.5718, output_pixel_unit: 'um', - output_timepoints: '0-4', + output_channels: "green", + output_data_type: "32Bit", + convert_32bit: '"[Use min/max of first image (might saturate intenities over time)]"', output_type_of_dataset: '"Image Stacks (ImageJ Opener)"', - output_xml: '"fused_Dual_Channel"'} - -registration: { - algorithm: '"Fast 3d geometric hashing (rotation invariant)"', - allowed_error_for_ransac: '5', - angle: '"All angles"', - bsh_file: "registration.bsh", - channel: '"All channels"', - detection_min_max: "find_maxima", - fix_tiles: '"Fix first tile"', - illuminations: '"All illuminations"', - imglib_container: '"ArrayImg (faster)"', - initial_sigma: '1.8', - interest_points_channel_0: '"beads"', - interest_points_channel_1: '"beads"', - label_interest_points: '"beads"', - lambda: '0.10', - map_back_tiles: '"Map back to first tile using rigid model"', - model_to_regularize_with: "Rigid", - proc-ch: '"channel 0"', - radius_1: '2', - radius_2: '3', - significance: '10', - subpixel_localization: '"3-dimensional quadratic fit"', - threshold: '0.005', - threshold_gaussian: '0.0080', - timepoint: '"Single Timepoint (Select from List)"', - transformation_model: "Affine", - type_of_detection: '"Difference-of-Mean (Integral image based)"', - type_of_registration: '"Register timepoints individually"' - } - -resave_hdf5: { - bsh_file: "export.bsh", - hdf5_chunk_sizes: '"{{ {{32,32,4}}, {{32,32,4}}, {{16,16,16}}, {{16,16,16}} }}"', - resave_angle: '"All angles"', - resave_channel: '"All channels"', - resave_illumination: '"All illuminations"', - resave_timepoint: '"All Timepoints"', - setups_per_partition: '0', - subsampling_factors: '"{{ {{1,1,1}}, {{2,2,1}}, {{4,4,1}}, {{8,8,1}} }}"', - timepoints_per_partition: '1'} - -timelapse: { - bsh_file: "timelapse_registration.bsh", - reference_timepoint: '0', - timelapse_process_timepoints: '"All Timepoints"', - type_of_registration_timelapse: '"Match against one reference timepoint (no global optimization)"' - } - -xml_merge: { - bsh_file: "xml_merge.bsh" + output_multiple_timepoints: '"YES (one file per time-point)"', + output_multiple_angles: '"NO (one angle)"', + output_illumination_directions: '"NO (one illumination direction)"', + output_imglib_container: '"ArrayImg (faster)"', + subsampling_output: '"{{ {{1,1,1}}, {{2,2,2}}, {{4,4,4}}, {{8,8,8}} }}"', + chunk_sizes_output: '"{{ {{16,16,16}}, {{16,16,16}}, {{16,16,16}}, {{16,16,16}} }}"', + # subsampling_output: '"{{ {{1,1,1}}, {{2,2,2}} }}"', + # chunk_sizes_output: '"{{ {{16,16,16}}, {{16,16,16}} }}"', + bsh_file_define: "define_output.bsh", + bsh_file_hdf5: "export_output.bsh" } diff --git a/spim_registration/timelapse/transform.bsh b/spim_registration/timelapse/transform.bsh old mode 100644 new mode 100755 index 839a08521875b663810ef80a37742f9131c30a80..3e87082b23b8619a2efb4842681d3033e8b3bbf7 --- a/spim_registration/timelapse/transform.bsh +++ b/spim_registration/timelapse/transform.bsh @@ -1,3 +1,5 @@ +// is problematic needs to be adjusted for +// multi channel and multi illumination datasets import ij.IJ; import ij.ImagePlus; import java.lang.Runtime; @@ -11,13 +13,11 @@ System.out.println(runtime.availableProcessors() + " cores available for multi-t // Load Parameters form job file image_file_directory = System.getProperty( "image_file_directory" ); merged_xml = System.getProperty( "merged_xml" ); -if ( ! merged_xml.endsWith(".xml") ) - merged_xml = merged.xml + ".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" ); +channel_setting = System.getProperty( "channel_setting" ); transformation = System.getProperty( "transformation" ); apply_transformation = System.getProperty( "apply_transformation" ); define_mode_transform = System.getProperty( "define_mode_transform" ); @@ -26,15 +26,16 @@ 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 ); +System.out.println( "select_xml = " + image_file_directory + merged_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( "Channel_setting = " + channel_setting ); 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 ); +System.out.println( "all_timepoints_channel_" + channel_setting + "_illumination_0_all_angles = " + matrix_transform ); // Execute Fiji Plugin try { @@ -50,12 +51,11 @@ IJ.run("Apply Transformations", "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 + "]"); + "all_timepoints_channel_" + channel_setting + "_illumination_0_all_angles=[" + matrix_transform + "]"); } catch ( e ) { - print( "[transform] caught exception: "+e ); + print( "[external transformation] caught exception: "+e ); //important to fail the process if exception occurs runtime.exit(1); diff --git a/spim_registration/timelapse/xml_merge.bsh b/spim_registration/timelapse/xml_merge.bsh old mode 100644 new mode 100755 index a3ab7dab127d6d4fad3f9d841f029aaa65630d5b..74949e34558d49d5ea8d1dea815d5e183cd0e9fe --- a/spim_registration/timelapse/xml_merge.bsh +++ b/spim_registration/timelapse/xml_merge.bsh @@ -1,4 +1,6 @@ -import ij.IJ; +// Load Fiji dependencies +import ij.IJ; // calls imagej +import ij.Prefs; // calls imagej settings import ij.ImagePlus; import java.lang.Runtime; import java.io.File; @@ -7,16 +9,18 @@ import java.io.FilenameFilter; runtime = Runtime.getRuntime(); System.out.println(runtime.availableProcessors() + " cores available for multi-threading"); +Prefs.setThreads(1); // defines the number of threads allowed +print("Threads: "+Prefs.getThreads()); // prints thread setting in output System.out.println( "Load Parameters:"); - // Getting parameters from job file +// Getting parameters from job file image_file_directory = System.getProperty( "image_file_directory" ); merged_xml = System.getProperty( "merged_xml" ); if ( ! merged_xml.endsWith(".xml") ) merged_xml = merged.xml + ".xml"; - + // Printing parameters into output file System.out.println( "directory=" + image_file_directory ); System.out.println( "merged_xml=" + merged_xml ); @@ -31,7 +35,8 @@ IJ.run("Merge Cluster Jobs", "filename_contains=job_ " + "filename_also_contains=.xml " + "display " + - "merged_xml=" + merged_xml); +// "delete_xml's " + + "merged_xml=" + merged_xml + ""); } catch ( e ) {