diff --git a/spim_registration/timelapse/Snakefile b/spim_registration/timelapse/Snakefile old mode 100644 new mode 100755 index 7d20dad47afc6e667ccf51e711464dd3cdd4bed9..7f7804b17d1d1c868355faae5c309f9b0f7d9be5 --- 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}" @@ -34,20 +34,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 +63,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} \ diff --git a/spim_registration/timelapse/define_czi.bsh b/spim_registration/timelapse/define_czi.bsh old mode 100644 new mode 100755 index 74afeb13157ffa770376eed588bc2f6681682238..6432e33bceaf9895d442df2539d977470c9e4829 --- 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,29 @@ 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 + ""); + 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 + " " + 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..37f129b732c30616f6a8ff7cbbad92bf0b078716 --- 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,6 +122,26 @@ 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:"); @@ -72,8 +155,9 @@ 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 + " " + 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..975904f3ff5e851da35dec321762d84fb969f732 --- a/spim_registration/timelapse/tomancak_test_cluster.yaml +++ b/spim_registration/timelapse/tomancak_test_cluster.yaml @@ -1,95 +1,91 @@ -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/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" + } + +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: { + 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' } - -external_transform: - { +registration: { + algorithm: '"Fast 3d geometric hashing (rotation invariant)"', + allowed_error_for_ransac: '5', angle: '"All angles"', - apply_transformation: '"Current view transformations - (appends to current transforms)"', - bsh_file: "transform.bsh", + bsh_file: "registration.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"' + 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"' + } + +xml_merge: { + bsh_file: "xml_merge.bsh" + } + +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)"' } fusion: { @@ -113,6 +109,46 @@ fusion: { process_views_in_paralell: '"All"', xml_output: '"Save every XML with user-provided unique id"' } + +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"' + } + +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)"' + } hdf5_output: { bsh_file_define: "define_output.bsh", @@ -133,57 +169,6 @@ hdf5_output: { output_pixel_unit: 'um', output_timepoints: '0-4', 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_xml: '"fused_Dual_Channel"' }