Skip to content

nabu.stitching.config

source module nabu.stitching.config

Classes

Functions

source str_to_shifts(my_str: Optional[str])Union[str, tuple]

Raises

  • TypeError

source class NormalizationBySample()

source method NormalizationBySample.is_active()

source method NormalizationBySample.set_is_active(active: bool)

source property NormalizationBySample.method: Method

source property NormalizationBySample.margin: int

source property NormalizationBySample.side: SampleSide

source property NormalizationBySample.width: int

source staticmethod NormalizationBySample.from_dict(my_dict: dict)

source method NormalizationBySample.to_dict()dict

source dataclass SlurmConfig(partition: str = '', mem: str = '128', n_jobs: int = 1, other_options: str = '', preprocessing_command: str = '', modules_to_load: tuple = tuple(), clean_script: bool = '', n_tasks: int = 1, n_cpu_per_task: int = 4, job_name: str = '')

configuration for slurm jobs

Methods

source method SlurmConfig.to_dict()dict

dump configuration to dict

source staticmethod SlurmConfig.from_dict(config: dict)

source dataclass StitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True)

bass class to define stitching configuration

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

Methods

source property StitchingConfiguration.stitching_type

source staticmethod StitchingConfiguration.get_description_dict()dict

source method StitchingConfiguration.to_dict()

dump configuration to a dict. Must be serializable because might be dump to HDF5 file

source class SingleAxisConfigMetaClass()

Bases : type

Metaclass for single axis stitcher in order to aggregate dumper class and axis

warning: this class is used by tomwer as well

source dataclass SingleAxisStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant')

Bases : StitchingConfiguration

base class to define z-stitching parameters

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

Methods

source property SingleAxisStitchingConfiguration.axis: int

source method SingleAxisStitchingConfiguration.settle_inputs()None

source method SingleAxisStitchingConfiguration.settle_slices()tuple

Raises

  • ValueError

source method SingleAxisStitchingConfiguration.get_output_object()

Raises

  • ValueError

source method SingleAxisStitchingConfiguration.to_dict()

source dataclass PreProcessedSingleAxisStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant', input_scans: tuple = (), output_file_path: str = '', output_data_path: str = '', output_nexus_version: Optional[float] = None, pixel_size: Optional[float] = None)

Bases : SingleAxisStitchingConfiguration

base class to define z-stitching parameters

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

Methods

source property PreProcessedSingleAxisStitchingConfiguration.stitching_type: StitchingType

source method PreProcessedSingleAxisStitchingConfiguration.get_output_object()

source method PreProcessedSingleAxisStitchingConfiguration.settle_inputs()None

source method PreProcessedSingleAxisStitchingConfiguration.settle_input_scans()

source method PreProcessedSingleAxisStitchingConfiguration.slice_idx_from_str_to_int(index)

source method PreProcessedSingleAxisStitchingConfiguration.settle_slices()tuple

interpret the slices to be stitched if needed

Nore: if slices is an instance of slice will redefine start and stop to avoid having negative indexes

:return: (slices:[slice,Iterable], n_proj:int) :rtype: tuple

Raises

  • ValueError

  • TypeError

source method PreProcessedSingleAxisStitchingConfiguration.to_dict()

source staticmethod PreProcessedSingleAxisStitchingConfiguration.get_description_dict()dict

source classmethod PreProcessedSingleAxisStitchingConfiguration.from_dict(config: dict)

Raises

  • TypeError

source dataclass PostProcessedSingleAxisStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant', input_volumes: tuple = (), output_volume: Optional[VolumeIdentifier] = None, voxel_size: Optional[float] = None, alignment_axis_1: AlignmentAxis1 = AlignmentAxis1.CENTER)

Bases : SingleAxisStitchingConfiguration

base class to define z-stitching parameters

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

Methods

source property PostProcessedSingleAxisStitchingConfiguration.stitching_type: StitchingType

source method PostProcessedSingleAxisStitchingConfiguration.get_output_object()

source method PostProcessedSingleAxisStitchingConfiguration.settle_inputs()None

source method PostProcessedSingleAxisStitchingConfiguration.settle_input_volumes()

source method PostProcessedSingleAxisStitchingConfiguration.slice_idx_from_str_to_int(index)

source method PostProcessedSingleAxisStitchingConfiguration.settle_slices()tuple

interpret the slices to be stitched if needed

Nore: if slices is an instance of slice will redefine start and stop to avoid having negative indexes

:return: (slices:[slice,Iterable], n_proj:int) :rtype: tuple

Raises

  • ValueError

  • TypeError

source classmethod PostProcessedSingleAxisStitchingConfiguration.from_dict(config: dict)

Raises

  • TypeError

source method PostProcessedSingleAxisStitchingConfiguration.to_dict()

source staticmethod PostProcessedSingleAxisStitchingConfiguration.get_description_dict()dict

source identifiers_as_str_to_instances(list_identifiers_as_str: str)tuple

source dict_to_config_obj(config: dict)

Raises

  • TypeError

  • ValueError

  • NotImplementedError

source get_default_stitching_config(stitching_type: Optional[Union[StitchingType, str]])tuple

Return a default configuration for doing stitching.

:param stitching_type: if None then return a configuration were use can provide inputs for any of the stitching. Else return config dict dedicated to a particular stitching :return: (config, section comments)

Raises

  • NotImplementedError

source dataclass PreProcessedYStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant', input_scans: tuple = (), output_file_path: str = '', output_data_path: str = '', output_nexus_version: Optional[float] = None, pixel_size: Optional[float] = None)

Bases : PreProcessedSingleAxisStitchingConfiguration

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

source dataclass PreProcessedZStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant', input_scans: tuple = (), output_file_path: str = '', output_data_path: str = '', output_nexus_version: Optional[float] = None, pixel_size: Optional[float] = None)

Bases : PreProcessedSingleAxisStitchingConfiguration

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied

source dataclass PostProcessedZStitchingConfiguration(axis_0_pos_px: Union[tuple, str, None], axis_1_pos_px: Union[tuple, str, None], axis_2_pos_px: Union[tuple, str, None], axis_0_pos_mm: Union[tuple, str, None] = None, axis_1_pos_mm: Union[tuple, str, None] = None, axis_2_pos_mm: Union[tuple, str, None] = None, axis_0_params: dict = None, axis_1_params: dict = None, axis_2_params: dict = None, slurm_config: SlurmConfig = None, flip_lr: Union[tuple, bool] = False, flip_ud: Union[tuple, bool] = False, overwrite_results: bool = False, stitching_strategy: OverlapStitchingStrategy = OverlapStitchingStrategy.COSINUS_WEIGHTS, stitching_kernels_extra_params: dict = None, slice_for_cross_correlation: Union[str, int] = 'middle', rescale_frames: bool = False, rescale_params: dict = None, normalization_by_sample: NormalizationBySample = None, duplicate_data: bool = True, slices: Union[slice, tuple, None] = None, alignment_axis_2: AlignmentAxis2 = AlignmentAxis2.CENTER, pad_mode: str = 'constant', input_volumes: tuple = (), output_volume: Optional[VolumeIdentifier] = None, voxel_size: Optional[float] = None, alignment_axis_1: AlignmentAxis1 = AlignmentAxis1.CENTER)

Bases : PostProcessedSingleAxisStitchingConfiguration

Attributes

  • axis_0_pos_px : Union[tuple, str, None] px

  • axis_1_pos_px : Union[tuple, str, None] px

  • axis_2_pos_px : Union[tuple, str, None] px

  • axis_0_pos_mm : Union[tuple, str, None] mm

  • axis_1_pos_mm : Union[tuple, str, None] mm

  • axis_2_pos_mm : Union[tuple, str, None] mm

  • flip_lr : Union[tuple, bool] flip frame left-right. For scan this will be append to the NXtransformations of the detector

  • flip_ud : Union[tuple, bool] flip frame up-down. For scan this will be append to the NXtransformations of the detector

  • duplicate_data : bool when possible (for HDF5) avoid duplicating data as-much-much-as-possible. Overlaping region between two frames will be duplicated. Remaining will be 'raw_data' for volume. For projection flat field will be applied