Mercurial > repos > rv43 > tomo
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 10:e3c8a96d2f67 | 11:ec7c3e84d611 |
|---|---|
| 1147 del recon_sinogram | 1147 del recon_sinogram |
| 1148 recon_clean = tomopy.misc.corr.remove_ring(recon_clean, rwidth=17, ncore=num_core) | 1148 recon_clean = tomopy.misc.corr.remove_ring(recon_clean, rwidth=17, ncore=num_core) |
| 1149 logging.debug(f'filtering and removing ring artifact took {time()-t0:.2f} seconds!') | 1149 logging.debug(f'filtering and removing ring artifact took {time()-t0:.2f} seconds!') |
| 1150 return recon_clean | 1150 return recon_clean |
| 1151 | 1151 |
| 1152 def _plotEdgesOnePlane(self, recon_plane, title, name=None, weight=0.001): | 1152 def _plotEdgesOnePlane(self, recon_plane, title, path=None, name=None, weight=0.001): |
| 1153 # RV parameters for the denoise, gaussian, and ring removal will be different for different feature sizes | 1153 # RV parameters for the denoise, gaussian, and ring removal will be different for different feature sizes |
| 1154 edges = denoise_tv_chambolle(recon_plane, weight = weight) | 1154 edges = denoise_tv_chambolle(recon_plane, weight = weight) |
| 1155 vmax = np.max(edges[0,:,:]) | 1155 vmax = np.max(edges[0,:,:]) |
| 1156 vmin = -vmax | 1156 vmin = -vmax |
| 1157 if self.galaxy_flag: | 1157 if self.galaxy_flag: |
| 1158 msnc.quickImshow(edges[0,:,:], title, name=name, save_fig=True, save_only=True, | 1158 msnc.quickImshow(edges[0,:,:], title, path=path, name=name, save_fig=True, |
| 1159 cmap='gray', vmin=vmin, vmax=vmax) | 1159 save_only=True, cmap='gray', vmin=vmin, vmax=vmax) |
| 1160 else: | 1160 else: |
| 1161 msnc.quickImshow(edges[0,:,:], f'{title} coolwarm', path=self.output_folder, | 1161 if path is None: |
| 1162 path=self.output_folder | |
| 1163 msnc.quickImshow(edges[0,:,:], f'{title} coolwarm', path=path, | |
| 1162 save_fig=self.save_plots, save_only=self.save_plots_only, cmap='coolwarm') | 1164 save_fig=self.save_plots, save_only=self.save_plots_only, cmap='coolwarm') |
| 1163 msnc.quickImshow(edges[0,:,:], f'{title} gray', path=self.output_folder, | 1165 msnc.quickImshow(edges[0,:,:], f'{title} gray', path=path, |
| 1164 save_fig=self.save_plots, save_only=self.save_plots_only, cmap='gray', | 1166 save_fig=self.save_plots, save_only=self.save_plots_only, cmap='gray', |
| 1165 vmin=vmin, vmax=vmax) | 1167 vmin=vmin, vmax=vmax) |
| 1166 del edges | 1168 del edges |
| 1167 | 1169 |
| 1168 def _findCenterOnePlane(self, sinogram, row, thetas_deg, eff_pixel_size, cross_sectional_dim, | 1170 def _findCenterOnePlane(self, sinogram, row, thetas_deg, eff_pixel_size, cross_sectional_dim, |
| 1228 del sinogram_T | 1230 del sinogram_T |
| 1229 del recon_plane | 1231 del recon_plane |
| 1230 return float(center_offset) | 1232 return float(center_offset) |
| 1231 | 1233 |
| 1232 # perform center finding search | 1234 # perform center finding search |
| 1235 if self.galaxy_flag and not os.path.exists('png_files'): | |
| 1236 os.mkdir('png_files') | |
| 1233 while True: | 1237 while True: |
| 1234 if self.galaxy_flag and galaxy_param and galaxy_param['center_type_selector']: | 1238 if self.galaxy_flag and galaxy_param and galaxy_param['center_type_selector']: |
| 1235 set_center = center_offset_vo | 1239 set_center = center_offset_vo |
| 1236 if galaxy_param['center_type_selector'] == 'user': | 1240 if galaxy_param['center_type_selector'] == 'user': |
| 1237 set_center = galaxy_param['set_center'] | 1241 set_center = galaxy_param['set_center'] |
| 1264 continue | 1268 continue |
| 1265 logging.info(f'center_offset = {center_offset:.2f}') | 1269 logging.info(f'center_offset = {center_offset:.2f}') |
| 1266 recon_plane = self._reconstructOnePlane(sinogram_T, center_offset+center, | 1270 recon_plane = self._reconstructOnePlane(sinogram_T, center_offset+center, |
| 1267 thetas_deg, eff_pixel_size, cross_sectional_dim, False, num_core) | 1271 thetas_deg, eff_pixel_size, cross_sectional_dim, False, num_core) |
| 1268 title = f'edges row{row} center_offset{center_offset:.2f}' | 1272 title = f'edges row{row} center_offset{center_offset:.2f}' |
| 1269 self._plotEdgesOnePlane(recon_plane, title) | 1273 if self.galaxy_flag: |
| 1274 self._plotEdgesOnePlane(recon_plane, title, path='png_files') | |
| 1275 else: | |
| 1276 self._plotEdgesOnePlane(recon_plane, title) | |
| 1270 if self.galaxy_flag or pyip.inputInt('\nContinue (0) or end the search (1): ', | 1277 if self.galaxy_flag or pyip.inputInt('\nContinue (0) or end the search (1): ', |
| 1271 min=0, max=1): | 1278 min=0, max=1): |
| 1272 break | 1279 break |
| 1273 | 1280 |
| 1274 del sinogram_T | 1281 del sinogram_T |
