comparison workflow/run_tomo.py @ 24:0891477bcb16 draft

planemo upload for repository https://github.com/rolfverberg/galaxytools commit f8c4bdb31c20c468045ad5e6eb255a293244bc6c-dirty
author rv43
date Tue, 21 Mar 2023 17:40:36 +0000
parents c7a1d5d1471c
children 7d9cf7592ad1
comparison
equal deleted inserted replaced
23:fbbd82938303 24:0891477bcb16
515 if self.test_mode: 515 if self.test_mode:
516 x_bounds = self.test_config.get('x_bounds') 516 x_bounds = self.test_config.get('x_bounds')
517 y_bounds = self.test_config.get('y_bounds') 517 y_bounds = self.test_config.get('y_bounds')
518 z_bounds = None 518 z_bounds = None
519 elif self.galaxy_flag: 519 elif self.galaxy_flag:
520 if x_bounds is not None and not is_int_pair(x_bounds, ge=0, 520 if x_bounds is not None and not is_int_pair(x_bounds, ge=-1,
521 lt=tomo_recon_stacks[0].shape[1]): 521 lt=tomo_recon_stacks[0].shape[1]):
522 raise ValueError(f'Invalid parameter x_bounds ({x_bounds})') 522 raise ValueError(f'Invalid parameter x_bounds ({x_bounds})')
523 if y_bounds is not None and not is_int_pair(y_bounds, ge=0, 523 if y_bounds is not None and not is_int_pair(y_bounds, ge=-1,
524 lt=tomo_recon_stacks[0].shape[1]): 524 lt=tomo_recon_stacks[0].shape[1]):
525 raise ValueError(f'Invalid parameter y_bounds ({y_bounds})') 525 raise ValueError(f'Invalid parameter y_bounds ({y_bounds})')
526 z_bounds = None 526 z_bounds = None
527 else: 527 else:
528 x_bounds, y_bounds, z_bounds = self._resize_reconstructed_data(tomo_recon_stacks) 528 x_bounds, y_bounds, z_bounds = self._resize_reconstructed_data(tomo_recon_stacks)
885 num_tomo_stacks = len(tomo_fields.scan_numbers) 885 num_tomo_stacks = len(tomo_fields.scan_numbers)
886 theta = tomo_fields.theta_range['start'] 886 theta = tomo_fields.theta_range['start']
887 887
888 # Select image bounds 888 # Select image bounds
889 title = f'tomography image at theta={round(theta, 2)+0}' 889 title = f'tomography image at theta={round(theta, 2)+0}'
890 if img_x_bounds is not None:
891 if is_int_pair(img_x_bounds) and img_x_bounds[0] == -1 and img_x_bounds[1] == -1:
892 img_x_bounds = None
893 elif not is_index_range(img_x_bounds, ge=0, le=first_image.shape[0]):
894 raise ValueError(f'Invalid parameter img_x_bounds ({img_x_bounds})')
895 if nxentry.instrument.source.attrs['station'] in ('id1a3', 'id3a'): 890 if nxentry.instrument.source.attrs['station'] in ('id1a3', 'id3a'):
896 pixel_size = nxentry.instrument.detector.x_pixel_size 891 pixel_size = nxentry.instrument.detector.x_pixel_size
897 # Try to get a fit from the bright field 892 # Try to get a fit from the bright field
898 tbf = np.asarray(reduced_data.data.bright_field) 893 tbf = np.asarray(reduced_data.data.bright_field)
899 tbf_shape = tbf.shape 894 tbf_shape = tbf.shape
991 x_sum_min = x_sum.min() 986 x_sum_min = x_sum.min()
992 x_sum_max = x_sum.max() 987 x_sum_max = x_sum.max()
993 if self.galaxy_flag: 988 if self.galaxy_flag:
994 if img_x_bounds is None: 989 if img_x_bounds is None:
995 img_x_bounds = (0, first_image.shape[0]) 990 img_x_bounds = (0, first_image.shape[0])
991 elif not is_index_range(img_x_bounds, ge=0, le=first_image.shape[0]):
992 raise ValueError(f'Invalid parameter img_x_bounds ({img_x_bounds})')
996 else: 993 else:
997 quick_imshow(first_image, title=title) 994 quick_imshow(first_image, title=title)
998 print('Select vertical data reduction range from first tomography image') 995 print('Select vertical data reduction range from first tomography image')
999 img_x_bounds = select_image_bounds(first_image, 0, title=title) 996 img_x_bounds = select_image_bounds(first_image, 0, title=title)
1000 clear_imshow(title) 997 clear_imshow(title)