Mercurial > repos > rv43 > tomo
comparison tomo.py @ 28:c7211931fc99 draft
"planemo upload for repository https://github.com/rolfverberg/galaxytools commit 99f399daf512578b317aca74314e0246faa65cec"
author | rv43 |
---|---|
date | Mon, 18 Apr 2022 21:26:01 +0000 |
parents | 9d631a5e118f |
children | 59c5c0b53579 |
comparison
equal
deleted
inserted
replaced
27:9d631a5e118f | 28:c7211931fc99 |
---|---|
1181 # need index order column,theta for iradon, so take transpose | 1181 # need index order column,theta for iradon, so take transpose |
1182 sinogram_T = sinogram.T | 1182 sinogram_T = sinogram.T |
1183 center = sinogram.shape[1]/2 | 1183 center = sinogram.shape[1]/2 |
1184 | 1184 |
1185 # try automatic center finding routines for initial value | 1185 # try automatic center finding routines for initial value |
1186 num_core=1 | 1186 #num_core=1 |
1187 #tomo_center = tomopy.find_center_vo(sinogram, ncore=1) | |
1188 tomo_center = tomopy.find_center_vo(sinogram, ncore=num_core) | 1187 tomo_center = tomopy.find_center_vo(sinogram, ncore=num_core) |
1189 center_offset_vo = tomo_center-center | 1188 center_offset_vo = tomo_center-center |
1190 if self.test_mode: | 1189 if self.test_mode: |
1191 logging.info(f'Center at row {row} using Nghia Vo’s method = {center_offset_vo:.2f}') | 1190 logging.info(f'Center at row {row} using Nghia Vo’s method = {center_offset_vo:.2f}') |
1192 del sinogram_T | 1191 del sinogram_T |
1971 if self.tomo_stacks[i].size: | 1970 if self.tomo_stacks[i].size: |
1972 self.tomo_stacks[i] = np.array([]) | 1971 self.tomo_stacks[i] = np.array([]) |
1973 assert(stack.get('preprocessed', False) == True) | 1972 assert(stack.get('preprocessed', False) == True) |
1974 assert(stack.get('reconstructed', False) == True) | 1973 assert(stack.get('reconstructed', False) == True) |
1975 continue | 1974 continue |
1976 print(f'OK4 {i} b') | 1975 print(f'OK4 {i} b size = {self.tomo_stacks[i].size}') |
1977 stack['reconstructed'] = False | 1976 stack['reconstructed'] = False |
1978 if not self.tomo_stacks[i].size: | 1977 if not self.tomo_stacks[i].size: |
1979 self.tomo_stacks[i], available = self._loadTomo('red stack', index, | 1978 self.tomo_stacks[i], available = self._loadTomo('red stack', index, |
1980 required=True) | 1979 required=True) |
1981 if not self.tomo_stacks[i].size: | 1980 if not self.tomo_stacks[i].size: |
1982 logging.error(f'Unable to load tomography stack {index} for reconstruction') | 1981 logging.error(f'Unable to load tomography stack {index} for reconstruction') |
1983 stack[i]['preprocessed'] = False | 1982 stack[i]['preprocessed'] = False |
1984 load_error = True | 1983 load_error = True |
1985 continue | 1984 continue |
1985 print(f'lower_row = {lower_row} upper_row = {upper_row} self.tomo_stacks[i].shape[0] = {self.tomo_stacks[i].shape[0]}') | |
1986 assert(0 <= lower_row < upper_row < self.tomo_stacks[i].shape[0]) | 1986 assert(0 <= lower_row < upper_row < self.tomo_stacks[i].shape[0]) |
1987 print(f'OK4 {i} c') | |
1987 center_offsets = [lower_center_offset-lower_row*center_slope, | 1988 center_offsets = [lower_center_offset-lower_row*center_slope, |
1988 upper_center_offset+(self.tomo_stacks[i].shape[0]-1-upper_row)*center_slope] | 1989 upper_center_offset+(self.tomo_stacks[i].shape[0]-1-upper_row)*center_slope] |
1989 t0 = time() | 1990 t0 = time() |
1990 self.tomo_recon_stacks[i]= self._reconstructOneTomoStack(self.tomo_stacks[i], | 1991 self.tomo_recon_stacks[i]= self._reconstructOneTomoStack(self.tomo_stacks[i], |
1991 thetas, center_offsets=center_offsets, sigma=0.1, num_core=num_core, | 1992 thetas, center_offsets=center_offsets, sigma=0.1, num_core=num_core, |
1992 algorithm='gridrec', run_secondary_sirt=True, secondary_iter=25) | 1993 algorithm='gridrec', run_secondary_sirt=True, secondary_iter=25) |
1993 logging.info(f'Reconstruction of stack {index} took {time()-t0:.2f} seconds!') | 1994 logging.info(f'Reconstruction of stack {index} took {time()-t0:.2f} seconds!') |
1994 print(f'OK4 {i} c') | 1995 print(f'OK4 {i} d') |
1995 if self.galaxy_flag: | 1996 if self.galaxy_flag: |
1996 x_slice = int(self.tomo_stacks[i].shape[0]/2) | 1997 x_slice = int(self.tomo_stacks[i].shape[0]/2) |
1997 title = f'{basetitle} {index} xslice{x_slice}' | 1998 title = f'{basetitle} {index} xslice{x_slice}' |
1998 msnc.quickImshow(self.tomo_recon_stacks[i][x_slice,:,:], title=title, | 1999 msnc.quickImshow(self.tomo_recon_stacks[i][x_slice,:,:], title=title, |
1999 path='center_slice_pngs', save_fig=True, save_only=True) | 2000 path='center_slice_pngs', save_fig=True, save_only=True) |
2023 stack['reconstructed'] = True | 2024 stack['reconstructed'] = True |
2024 combine_stacks = self.config.get('combine_stacks') | 2025 combine_stacks = self.config.get('combine_stacks') |
2025 if combine_stacks and index in combine_stacks.get('stacks', []): | 2026 if combine_stacks and index in combine_stacks.get('stacks', []): |
2026 combine_stacks['stacks'].remove(index) | 2027 combine_stacks['stacks'].remove(index) |
2027 self.cf.saveFile(self.config_out) | 2028 self.cf.saveFile(self.config_out) |
2028 print(f'OK4 {i} d') | 2029 print(f'OK4 {i} e') |
2029 | 2030 |
2030 # Save reconstructed tomography stack to file | 2031 # Save reconstructed tomography stack to file |
2031 print('OK5') | 2032 print('OK5') |
2032 if self.galaxy_flag: | 2033 if self.galaxy_flag: |
2033 t0 = time() | 2034 t0 = time() |