diff tomo.py @ 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 845270a96464
children 40395e60d2be
line wrap: on
line diff
--- 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