From 68bc626c36beccd1296b5979308c6301a22b5334 Mon Sep 17 00:00:00 2001
From: Peter Steinbach <steinbach@scionics.de>
Date: Mon, 18 May 2015 16:55:36 +0200
Subject: [PATCH] * updated beanshell file to throw away padded 0 in file_id *
 updated Snakefile accordingly

---
 spim_registration/timelapse/Snakefile        | 12 +++++------
 spim_registration/timelapse/registration.bsh | 21 ++++++++++++++++++--
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/spim_registration/timelapse/Snakefile b/spim_registration/timelapse/Snakefile
index 3edf065..cafc912 100644
--- a/spim_registration/timelapse/Snakefile
+++ b/spim_registration/timelapse/Snakefile
@@ -17,7 +17,7 @@ for ds in datasets:
    bn = os.path.basename(ds)
    bn_res = fre.search(bn)
    xml_base,file_id = bn_res.group('xml_base'),bn_res.group('file_id')
-   xml_merge_in.append("{xbase}.job_{fid}.xml".format(xbase=xml_base, fid=file_id))
+   xml_merge_in.append("{xbase}.job_{fid}.xml".format(xbase=xml_base, fid=int(file_id)))
    
 #TODO: this should go into a python module in this path
 def produce_string(_fstring, *args, **kwargs):
@@ -33,9 +33,9 @@ rule done:
     input: [ ds+"_deconvolved" for ds in datasets ]
 
 rule registration:
-    input: "{xml_base}-{file_id,\d+}-00.h5"
-    output: "{xml_base}.job_{file_id,\d+}.xml"
-    log: "{xml_base}-{file_id,\d+}-registration.log"
+    input: "{xml_base}-{file_id}-00.h5"
+    output: "{xml_base}-{file_id,\d+}-00.h5_registered", #"{xml_base}.job_{file_id,\d+}.xml"
+    log: "{xml_base}-{file_id}-registration.log"
     run:
         cmd_string = produce_string(
            """{fiji-prefix} {fiji-app} \
@@ -79,7 +79,7 @@ rule registration:
         #shell("touch {output}")
 
 rule xml_merge:
-    input: xml_merge_in
+    input: [ item+"_registered" for item in datasets ] #xml_merge_in 
     output: "{xml_base}_merge.xml"
     log: "{xml_base}_merge.log"
     run:
@@ -159,4 +159,4 @@ rule deconvolution:
         shell(cmd_string)
   
 rule distclean:
-    shell : "rm -rf *registered *tif "+str(" ".join(xml_merge_in))
+    shell : "rm -rf *registered *tif *log *_deconvolved *.xml~* interestpoints "+str(" ".join(xml_merge_in))
diff --git a/spim_registration/timelapse/registration.bsh b/spim_registration/timelapse/registration.bsh
index 4765129..f7c6b26 100644
--- a/spim_registration/timelapse/registration.bsh
+++ b/spim_registration/timelapse/registration.bsh
@@ -23,7 +23,7 @@ System.out.println( "selected_xml = " + xml_path + xml_filename + ".xml");
 System.out.println( "-------------------------------------------------------" );
 System.out.println( "General parameters: " );
 
-parallel_timepoints = System.getProperty( "parallel_timepoints" );
+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" );
@@ -101,13 +101,23 @@ System.out.println( "detection_min_max = " + detection_min_max );
 
 //activate cluster processing
 System.out.println( "=======================================================" );
+try {
 IJ.run("Toggle Cluster Processing", "display_cluster");
+}
+catch ( e ) { 
+
+    print( "[registration::activate_cluster_processing] caught exception: "+e );
+    //important to fail the process if exception occurs
+    runtime.exit(1);
+    
+}
 System.out.println( "Activated Cluster Processing" );
 
 
 //interest point detection
 System.out.println( "=======================================================" );
 System.out.println( "Starting Detection of Interest Points" );
+try {
 IJ.run("Detect Interest Points for Registration", 
 	"select_xml=" + xml_path + xml_filename + ".xml " +  
 	"unique_id=" + parallel_timepoints + " " +
@@ -127,7 +137,14 @@ IJ.run("Detect Interest Points for Registration",
 	"radius_2=" + radius_2 + " " + 
 	"threshold=" + threshold + " " +
 	"find_maxima");
+}
+catch ( e ) { 
 
+    print( "[registration::interest_points] caught exception: "+e );
+    //important to fail the process if exception occurs
+    runtime.exit(1);
+    
+}
 //registration based on interest point detection
 System.out.println( "=======================================================" );
 System.out.println( "Starting Registration" );
@@ -156,7 +173,7 @@ try {
 }
 catch ( e ) { 
 
-    print( "[registration] caught exception: "+e );
+    print( "[registration::based_on_interestpoints] caught exception: "+e );
     //important to fail the process if exception occurs
     runtime.exit(1);
     
-- 
GitLab