From 1cad3b4eb15b73d4aac3f3d29b070c9a00af94f2 Mon Sep 17 00:00:00 2001 From: Peter Steinbach <steinbach@scionics.de> Date: Mon, 18 May 2015 13:49:04 +0200 Subject: [PATCH] added try-catch block to beanshell script, so that they return exit status != 0 if exception is thrown --- .../timelapse/deconvolution_CPU.bsh | 17 +++++-- .../timelapse/deconvolution_GPU.bsh | 18 +++++-- spim_registration/timelapse/registration.bsh | 50 +++++++++++-------- spim_registration/timelapse/transform.bsh | 15 +++++- spim_registration/timelapse/xml_merge.bsh | 19 +++++-- 5 files changed, 86 insertions(+), 33 deletions(-) diff --git a/spim_registration/timelapse/deconvolution_CPU.bsh b/spim_registration/timelapse/deconvolution_CPU.bsh index b2ba8ab..e38a7bc 100644 --- a/spim_registration/timelapse/deconvolution_CPU.bsh +++ b/spim_registration/timelapse/deconvolution_CPU.bsh @@ -13,10 +13,12 @@ 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 + ".xml"); +System.out.println( "selected_xml = " + image_file_directory + merged_xml); // Load general Parameters parallel_timepoints = System.getProperty( "parallel_timepoints" ); @@ -97,8 +99,9 @@ System.out.println( "psf_size_z = " + psf_size_z ); System.out.println( "=======================================================" ); System.out.println( "Starting Deconvolution" ); +try { IJ.run("Fuse/Deconvolve Dataset", - "select_xml=" + image_file_directory + merged_xml + ".xml " + + "select_xml=" + image_file_directory + merged_xml + " " + "process_angle=[All angles] " + "process_channel=[All channels] " + "process_illumination=[All illuminations] " + @@ -130,6 +133,14 @@ IJ.run("Fuse/Deconvolve Dataset", "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 index f06b777..7ffb45b 100644 --- a/spim_registration/timelapse/deconvolution_GPU.bsh +++ b/spim_registration/timelapse/deconvolution_GPU.bsh @@ -13,10 +13,12 @@ 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 + ".xml"); +System.out.println( "selected_xml = " + image_file_directory + merged_xml); // Load general Parameters parallel_timepoints = System.getProperty( "parallel_timepoints" ); @@ -98,8 +100,9 @@ System.out.println( "psf_size_z = " + psf_size_z ); System.out.println( "=======================================================" ); System.out.println( "Starting Deconvolution" ); +try { IJ.run("Fuse/Deconvolve Dataset", - "select_xml=" + image_file_directory + merged_xml + ".xml " + + "select_xml=" + image_file_directory + merged_xml + " " + "process_angle=[All angles] " + "process_channel=[All channels] " + "process_illumination=[All illuminations] " + @@ -137,7 +140,14 @@ IJ.run("Fuse/Deconvolve Dataset", "psf_size_x=" + psf_size_x + " " + "psf_size_y=" + psf_size_y + " " + "psf_size_z=" + psf_size_z + ""); - +} +catch ( e ) { + + print( "[deconvolution-GPU] 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 index ab21bba..4765129 100644 --- a/spim_registration/timelapse/registration.bsh +++ b/spim_registration/timelapse/registration.bsh @@ -131,26 +131,36 @@ IJ.run("Detect Interest Points for Registration", //registration based on interest point detection System.out.println( "=======================================================" ); System.out.println( "Starting Registration" ); -IJ.run("Register Dataset based on Interest Points", - "select_xml=" + xml_path + xml_filename + ".job_" + parallel_timepoints + ".xml " + - "process_angle=[" + process_angle + "] " + - "process_channel=[" + process_channel + "] " + - "process_illumination=[" + process_illumination + "] " + - "process_timepoint=[" + process_timepoint + "] " + - "xml_output=[Do not process on cluster] " + - "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + - "registration_algorithm=[" + registration_algorithm + "] " + - "type_of_registration=[" + type_of_registration + "] " + - "interest_points_channel_0=" + interest_points_channel_0 + " " + -// check? "interest_points_channel_0=[[DO NOT register this channel]] " + -// "interest_points_channel_1=" + interest_points_channel_1 + " " + // Dual Channel - "fix_tiles=[" + fix_tiles + "] " + - "map_back_tiles=[" + map_back_tiles + "] " + - "transformation=" + transformation_model + " " + - "regularize_model " + - "model_to_regularize_with=" + model_to_regularize_with + " " + - "lamba=" + lambda + " " + - "allowed_error_for_ransac=" + allowed_error_for_ransac); + +try { + IJ.run("Register Dataset based on Interest Points", + "select_xml=" + xml_path + xml_filename + ".job_" + parallel_timepoints + ".xml " + + "process_angle=[" + process_angle + "] " + + "process_channel=[" + process_channel + "] " + + "process_illumination=[" + process_illumination + "] " + + "process_timepoint=[" + process_timepoint + "] " + + "xml_output=[Do not process on cluster] " + + "processing_timepoint=[Timepoint " + parallel_timepoints + "] " + + "registration_algorithm=[" + registration_algorithm + "] " + + "type_of_registration=[" + type_of_registration + "] " + + "interest_points_channel_0=" + interest_points_channel_0 + " " + + // check? "interest_points_channel_0=[[DO NOT register this channel]] " + + // "interest_points_channel_1=" + interest_points_channel_1 + " " + // Dual Channel + "fix_tiles=[" + fix_tiles + "] " + + "map_back_tiles=[" + map_back_tiles + "] " + + "transformation=" + transformation_model + " " + + "regularize_model " + + "model_to_regularize_with=" + model_to_regularize_with + " " + + "lamba=" + lambda + " " + + "allowed_error_for_ransac=" + allowed_error_for_ransac); +} +catch ( e ) { + + print( "[registration] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/transform.bsh b/spim_registration/timelapse/transform.bsh index 3a1cb2e..839a085 100644 --- a/spim_registration/timelapse/transform.bsh +++ b/spim_registration/timelapse/transform.bsh @@ -11,6 +11,9 @@ 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" ); @@ -23,7 +26,7 @@ matrix_transform = System.getProperty( "matrix_transform" ); // Print Parameters into output file System.out.println( "browse = " + image_file_directory ); -System.out.println( "select_xml = " + image_file_directory + merged_xml + ".xml" ); +System.out.println( "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 ); @@ -34,9 +37,10 @@ System.out.println( "define = " + define_mode_transform ); System.out.println( "all_timepoints_channel_0_illumination_0_all_angles = " + matrix_transform ); // Execute Fiji Plugin +try { IJ.run("Apply Transformations", "browse=" + image_file_directory + " " + - "select_xml=" + image_file_directory + merged_xml + ".xml " + + "select_xml=" + image_file_directory + merged_xml + " " + "apply_to_angle=[" + transform_angle + "] " + "apply_to_channel=[" + transform_channel + "] " + "apply_to_illumination=[" + transform_illumination + "] " + @@ -48,7 +52,14 @@ IJ.run("Apply Transformations", "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 + "]"); +} +catch ( e ) { + print( "[transform] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} /* shutdown */ runtime.exit(0); diff --git a/spim_registration/timelapse/xml_merge.bsh b/spim_registration/timelapse/xml_merge.bsh index 99925e7..a3ab7da 100644 --- a/spim_registration/timelapse/xml_merge.bsh +++ b/spim_registration/timelapse/xml_merge.bsh @@ -12,8 +12,11 @@ System.out.println( "Load Parameters:"); // Getting parameters from job file image_file_directory = System.getProperty( "image_file_directory" ); -merged_xml = System.getProperty( "merged_xml" ); +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 ); @@ -22,13 +25,21 @@ System.out.println( "=======================================================" ); System.out.println( "Start to merge .xml files" ); // Executing Fiji plugin +try { IJ.run("Merge Cluster Jobs", "directory=" + image_file_directory + " " + "filename_contains=job_ " + "filename_also_contains=.xml " + "display " + -// "delete_xml's " + - "merged_xml=" + merged_xml + ".xml"); - + "merged_xml=" + merged_xml); +} +catch ( e ) { + + print( "[xml_merge] caught exception: "+e ); + //important to fail the process if exception occurs + runtime.exit(1); + +} + /* shutdown */ runtime.exit(0); -- GitLab