changeset 11:ec7c3e84d611 draft

"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 6d01e142af3a0daad7ab37d4ff02d0f1797057a7"
author rv43
date Fri, 08 Apr 2022 16:39:07 +0000
parents e3c8a96d2f67
children 27d4a36a8c4a
files __pycache__/msnc_tools.cpython-39.pyc __pycache__/tomo.cpython-39.pyc config_l_center.yaml run_tomo_find_center tomo.py tomo_find_center.xml
diffstat 6 files changed, 56 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
Binary file __pycache__/msnc_tools.cpython-39.pyc has changed
Binary file __pycache__/tomo.cpython-39.pyc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config_l_center.yaml	Fri Apr 08 16:39:07 2022 +0000
@@ -0,0 +1,36 @@
+bright_field:
+  data_path: /nfs/chess/scratch/user/rv43/2022-1/id3b/sobhani-3249-A/tomo7C/tomo7C_flat_ANDOR2_001.h5
+  img_offset: 1
+  img_start: 0
+  num: 20
+dark_field:
+  data_path: null
+  img_start: -1
+  num: 0
+data_filetype: h5
+detector:
+  columns: 1700
+  id: andor2
+  pixel_size: 0.0013
+  rows: 1436
+preprocess:
+  img_x_bounds:
+  - 0
+  - 1436
+  num_theta_skip: 0
+  zoom_perc: 100
+stack_info:
+  num: 1
+  stacks:
+  - data_path: /nfs/chess/scratch/user/rv43/2022-1/id3b/sobhani-3249-A/tomo7C/tomo7C_ANDOR2_001.h5
+    img_offset: 1
+    img_start: 0
+    index: 1
+    num: 354
+    preprocessed: true
+    ref_height: 0.0
+theta_range:
+  end: 180.0
+  num: 354
+  start: 0.0
+work_folder: /nfs/chess/scratch/user/rv43/2022-1/id3b/sobhani-3249-A
--- a/run_tomo_find_center	Fri Apr 08 15:06:16 2022 +0000
+++ b/run_tomo_find_center	Fri Apr 08 16:39:07 2022 +0000
@@ -1,3 +1,5 @@
 #!/bin/bash
 
-python tomo_find_center.py -i red_stacks.npz -c 'config_l_center.yaml' --row_bounds '620 950' --center_rows '670 890' --output_config 'output.yaml' --recon_center_low 'recon_center_low.png' --recon_center_upp 'recon_center_upp.png'
+#python tomo_find_center.py -i red_stacks.npz -c 'config_l_center.yaml' --row_bounds 620 950 --center_rows 670 890 --output_config 'output.yaml' --recon_center_low 'recon_center_low.png' --recon_center_upp 'recon_center_upp.png'
+python tomo_find_center.py -i red_stacks.npz -c 'config_l_center.yaml' --row_bounds 620 950 --center_rows 670 890 --output_config 'output.yaml' --recon_center_low 'recon_center_low.png' --recon_center_upp 'recon_center_upp.png' --center_type_selector 'vo' --set_range 2 --set_step 0.9
+#python tomo_find_center.py -i red_stacks.npz -c 'config_l_center.yaml' --row_bounds 620 950 --center_rows 670 890 --output_config 'output.yaml' --recon_center_low 'recon_center_low.png' --recon_center_upp 'recon_center_upp.png' --center_type_selector 'user' --set_center 10 --set_range 2 --set_step 0.9
--- a/tomo.py	Fri Apr 08 15:06:16 2022 +0000
+++ b/tomo.py	Fri Apr 08 16:39:07 2022 +0000
@@ -1149,18 +1149,20 @@
         logging.debug(f'filtering and removing ring artifact took {time()-t0:.2f} seconds!')
         return recon_clean
 
-    def _plotEdgesOnePlane(self, recon_plane, title, name=None, weight=0.001):
+    def _plotEdgesOnePlane(self, recon_plane, title, path=None, name=None, weight=0.001):
         # RV parameters for the denoise, gaussian, and ring removal will be different for different feature sizes
         edges = denoise_tv_chambolle(recon_plane, weight = weight)
         vmax = np.max(edges[0,:,:])
         vmin = -vmax
         if self.galaxy_flag:
-            msnc.quickImshow(edges[0,:,:], title, name=name, save_fig=True, save_only=True,
-                    cmap='gray', vmin=vmin, vmax=vmax)
+            msnc.quickImshow(edges[0,:,:], title, path=path, name=name, save_fig=True,
+                    save_only=True, cmap='gray', vmin=vmin, vmax=vmax)
         else:
-            msnc.quickImshow(edges[0,:,:], f'{title} coolwarm', path=self.output_folder,
+            if path is None:
+                path=self.output_folder
+            msnc.quickImshow(edges[0,:,:], f'{title} coolwarm', path=path,
                     save_fig=self.save_plots, save_only=self.save_plots_only, cmap='coolwarm')
-            msnc.quickImshow(edges[0,:,:], f'{title} gray', path=self.output_folder,
+            msnc.quickImshow(edges[0,:,:], f'{title} gray', path=path,
                     save_fig=self.save_plots, save_only=self.save_plots_only, cmap='gray',
                     vmin=vmin, vmax=vmax)
         del edges
@@ -1230,6 +1232,8 @@
                 return float(center_offset)
 
         # perform center finding search
+        if self.galaxy_flag and not os.path.exists('png_files'):
+            os.mkdir('png_files')
         while True:
             if self.galaxy_flag and galaxy_param and galaxy_param['center_type_selector']:
                 set_center = center_offset_vo
@@ -1266,7 +1270,10 @@
                 recon_plane = self._reconstructOnePlane(sinogram_T, center_offset+center,
                         thetas_deg, eff_pixel_size, cross_sectional_dim, False, num_core)
                 title = f'edges row{row} center_offset{center_offset:.2f}'
-                self._plotEdgesOnePlane(recon_plane, title)
+                if self.galaxy_flag:
+                    self._plotEdgesOnePlane(recon_plane, title, path='png_files')
+                else:
+                    self._plotEdgesOnePlane(recon_plane, title)
             if self.galaxy_flag or pyip.inputInt('\nContinue (0) or end the search (1): ',
                     min=0, max=1):
                 break
--- a/tomo_find_center.xml	Fri Apr 08 15:06:16 2022 +0000
+++ b/tomo_find_center.xml	Fri Apr 08 16:39:07 2022 +0000
@@ -5,6 +5,9 @@
     </macros>
     <expand macro="requirements" />
     <command detect_errors="exit_code"><![CDATA[
+        #if str( $set.set_selector ) == "yes"
+            mkdir png_files;
+        #end if
         $__tool_directory__/tomo_find_center.py
         -i '$red_stacks'
         -c '$config'
@@ -59,7 +62,7 @@
         <data name="recon_center_low" format="png" label="Recontructed slice lower center using Nghia Vo’s method" from_work_dir="recon_center_low.png"/>
         <data name="recon_center_upp" format="png" label="Recontructed slice upper center using Nghia Vo’s method" from_work_dir="recon_center_upp.png"/>
         <collection name="recon_center_set" type="list" label="Recontructed slices center position set">
-            <discover_datasets ext="png"/>
+            <discover_datasets pattern="__name_and_ext__" directory="png_files" visible="true"/>
         </collection>
     </outputs>
     <help><![CDATA[