CHAP.tomo package

Submodules

CHAP.tomo.models module

Tomography Pydantic model classes.

class Detector(*, prefix: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)], rows: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None], columns: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None], pixel_size: Annotated[list[Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=2)], lens_magnification: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 1.0)

Bases: CHAPBaseModel

Detector class to represent the detector used in the experiment. The image origin is assumed to be in the top-left corner, with rows down (-z in lab frame) and columns sideways (+x in lab frame).

Variables:
  • prefix – Prefix of the detector in the SPEC file.

  • rows – Number of pixel rows on the detector.

  • columns – Number of pixel columns on the detector.

  • pixel_size – Pixel size of the detector in mm.

  • lens_magnification – Lens magnification for the detector, defaults to 1.0.

columns: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]
lens_magnification: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

pixel_size: Annotated[list[Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=2)]
prefix: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)]
rows: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]
class TomoCombineConfig(*, x_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, y_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, z_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration for the combined tomography stacks processor.

Variables:
  • x_bounds – Combined image bounds in the x-direction.

  • y_bounds – Combined image bounds in the y-direction.

  • z_bounds – Combined image bounds in the z-direction.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

x_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
y_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
z_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
class TomoFindCenterConfig(*, center_stack_index: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None = None, center_rows: Annotated[list[Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, center_offsets: Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None = None, center_offset_min: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, center_offset_max: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, center_search_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=3)] | None = None, gaussian_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, ring_width: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration for the tomography center axis finding processor.

Variables:
  • center_stack_index – Stack index of the tomography set to find the center axis.

  • center_rows – Row indices for the center finding processor.

  • center_offsets – Centers at the center finding row indices in pixels.

  • center_offset_min – Minimum value of center_offset in center axis finding search in pixels.

  • center_offset_max – Maximum value of center_offset in center axis finding search in pixels.

  • gaussian_sigma – Standard deviation for the Gaussian filter applied to image reconstruction visualizations, defaults to no filtering performed.

  • ring_width – Maximum width of rings to be filtered in the image reconstruction in pixels, defaults to no filtering performed.

center_offset_max: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
center_offset_min: Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
center_offsets: Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=2, max_length=2)] | None
center_rows: Annotated[list[Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
center_search_range: Annotated[list[Annotated[float, None, Interval(gt=None, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=3)] | None
center_stack_index: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] | None
gaussian_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

ring_width: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
class TomoReconstructConfig(*, x_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, y_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, z_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, secondary_iters: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None] = 0, gaussian_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, remove_stripe_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, ring_width: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration for the tomography image reconstruction processor.

Variables:
  • x_bounds – Reconstructed image bounds in the x-direction.

  • y_bounds – Reconstructed image bounds in the y-direction.

  • z_bounds – Reconstructed image bounds in the z-direction.

  • secondary_iters – Number of secondary iterations in the tomopy image reconstruction algorithm, defaults to 0.

  • gaussian_sigma – Standard deviation for the Gaussian filter applied to image reconstruction visualizations, defaults to no filtering performed.

  • remove_stripe_sigma – Damping parameter in Fourier space in tomopy’s horizontal stripe removal tool, defaults to no correction performed.

  • ring_width – Maximum width of rings to be filtered in the image reconstruction in pixels, defaults to no filtering performed.

gaussian_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

remove_stripe_sigma: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
ring_width: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
secondary_iters: Annotated[int, None, Interval(gt=None, ge=0, lt=None, le=None), None]
x_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
y_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
z_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
class TomoReduceConfig(*, img_row_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None = None, delta_theta: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None)

Bases: CHAPBaseModel

Class representing the configuration for the tomography image reduction processor.

Variables:
  • img_row_bounds – Detector image bounds in the row-direction (ignored for id1a3 and id3a).

  • delta_theta – Rotation angle increment in image reduction in degrees.

delta_theta: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
img_row_bounds: Annotated[list[Annotated[int, None, Interval(gt=None, ge=-1, lt=None, le=None), None]], Len(min_length=2, max_length=2)] | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class TomoSimConfig(*, station: Literal['id1a3', 'id3a', 'id3b'], detector: Detector(lens_magnification=1.0), sample_type: Literal['square_rod', 'square_pipe', 'hollow_cube', 'hollow_brick', 'hollow_pyramid'], sample_size: Annotated[list[Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=3)], wall_thickness: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = None, mu: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 0.05, theta_step: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)], beam_intensity: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 1000000000.0, background_intensity: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 20, slit_size: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None = 1.0)

Bases: CHAPBaseModel

Class representing the configuration for the tomography simulator.

Variables:
  • station – The station name (in ‘idxx’ format).

  • detector – Detector used in the tomography experiment.

  • sample_type – Sample type for the tomography simulator.

  • sample_size – Size of each sample dimension in mm (internally converted to an integer number of pixels). Enter three values for sample_type == ‘hollow_pyramid’, the height and the side at the respective bottom and the top of the pyramid.

  • wall_thickness – Wall thickness for pipe, cube, and brick in mm (internally converted to an integer number of pixels).

  • mu – Linear attenuation coefficient in mm^-1, defaults to 0.05.

  • theta_step – Rotation angle increment in the tomography simulation in degrees.

  • beam_intensity – Initial beam intensity in counts, defaults to 1.e9.

  • background_intensity – Background intensity in counts, defaults to 20.

  • slit_size – Vertical beam height in mm, defaults to 1.0.

background_intensity: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
beam_intensity: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
detector: Detector(lens_magnification=1.0)
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mu: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
sample_size: Annotated[list[Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]], Len(min_length=1, max_length=3)]
sample_type: Literal['square_rod', 'square_pipe', 'hollow_cube', 'hollow_brick', 'hollow_pyramid']
slit_size: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None
station: Literal['id1a3', 'id3a', 'id3b']
theta_step: Annotated[float, None, Interval(gt=0, ge=None, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)]
wall_thickness: Annotated[float, None, Interval(gt=None, ge=0, lt=None, le=None), None, AllowInfNan(allow_inf_nan=False)] | None

CHAP.tomo.processor module

File : processor.py Author : Rolf Verberg <rolfverberg AT gmail dot com> Description: Module for Processors used only by tomography experiments

class SetNumexprThreads(num_core)

Bases: object

Class that sets and keeps track of the number of processors used by the code in general and by the num_expr package specifically.

class Tomo(metadata, num_core=-1, *, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, save_figures: bool | None = True)

Bases: Processor

Reconstruct a set of tomographic images.

Variables:

save_figures – Create Matplotlib figures that can be saved to file downstream in the workflow, defaults to True.

combine_data(nxroot, tool_config)

Combine the reconstructed tomography stacks.

Parameters:
  • nxroot – Data object containing the reconstructed data and metadata required to combine the tomography stacks.

  • tool_config (CHAP.tomo.models.TomoCombineConfig) – Tool configuration.

Raises:

ValueError – Invalid or missing input or configuration parameter.

Returns:

Combined reconstructed tomography data.

Return type:

nexusformat.nexus.NXroot

find_centers(nxroot, tool_config, calibrate_center_rows=False)

Find the calibrated center axis info

Parameters:
  • nxroot – Data object containing the reduced data and metadata required to find the calibrated center axis info.

  • tool_config (CHAP.tomo.models.TomoFindCenterConfig) – Tool configuration.

  • calibrate_center_rows (Union[bool, list[int, int]]) – Internal parameter only: used only to calibrate the rotation axis.

Raises:

ValueError – Invalid or missing input or configuration parameter.

Returns:

Calibrated center axis info.

Return type:

dict

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

reconstruct_data(nxroot, center_info, tool_config)

Reconstruct the tomography data.

Parameters:
Raises:

ValueError – Invalid or missing input or configuration parameter.

Returns:

Reconstructed tomography data.

Return type:

nexusformat.nexus.NXroot

reduce_data(nxroot, tool_config=None, calibrate_center_rows=False)

Reduced the tomography images.

Parameters:
  • nxroot (nexusformat.nexus.NXroot) – Data object containing the raw data info and metadata required for a tomography data reduction.

  • tool_config (CHAP.tomo.models.TomoReduceConfig, optional) – Tool configuration.

  • calibrate_center_rows (Union[bool, list[int, int]]) – Internal parameter only: used only to calibrate the rotation axis.

Raises:

ValueError – Invalid input or configuration parameter.

Returns:

Reduced tomography data and the center calibration rows (only if calibrate_center_rows is set).

Return type:

nexusformat.nexus.NXroot, Union[bool, list[int, int]]

save_figures: bool | None
class TomoBrightFieldProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, num_image: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 5)

Bases: Processor

A processor to create the bright field associated with a simulated tomography data set created by TomoSimProcessor.

Variables:

num_image – Number of bright field images, defaults to 5.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

num_image: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
process(data)

Process the input configuration and return a nexusformat.nexus.NXroot object with the simulated bright field detector images.

Parameters:

data (list[PipelineData]) – Input configuration for the simulation.

Raises:

ValueError – Missing or invalid input or configuration parameter.

Returns:

Simulated bright field images.

Return type:

nexusformat.nexus.NXroot

class TomoCHESSMapConverter(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None)

Bases: Processor

A processor to convert a CHESS style tomography map with dark and bright field configurations to an NeXus style input format.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

process(data)

Extract the contents of the input data, add a string to it, and return the amended value.

Parameters:

data – Input data.

Returns:

Processed data.

class TomoDarkFieldProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, num_image: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None = 5)

Bases: Processor

A processor to create the dark field associated with a simulated tomography data set created by TomoSimProcessor.

Variables:

num_image – Number of dark field images, defaults to 5.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

num_image: Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None] | None
process(data)

Process the input configuration and return a nexusformat.nexus.NXroot object with the simulated dark field detector images.

Parameters:

data (list[PipelineData]) – Input configuration for the simulation.

Raises:

ValueError – Missing or invalid input or configuration parameter.

Returns:

Simulated dark field images.

Return type:

nexusformat.nexus.NXroot

class TomoDataProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, reduce_data: bool | None = False, find_center: bool | None = False, calibrate_center: bool | None = False, reconstruct_data: bool | None = False, combine_data: bool | None = False, save_figures: bool | None = True)

Bases: Processor

A processor to reconstruct a set of tomographic images returning either a dictionary or a nexusformat.nexus.NXroot object containing the data after processing each individual step, an optional list of byte stream representions of Matplotlib figures, and the metadata associated with the workflow.

Variables:
  • reduce_data – Generate reduced tomography images, defaults to False.

  • find_center – Generate calibrated center axis info, defaults to False.

  • calibrate_center – Calibrate the rotation axis, defaults to False.

  • reconstruct_data – Reconstruct the tomography data, defaults to False.

  • combine_data – Combine the reconstructed tomography stacks, defaults to False.

  • save_figures – Create Matplotlib figures that can be saved to file downstream in the workflow, defaults to True.

calibrate_center: bool | None
combine_data: bool | None
find_center: bool | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

process(data, config=None)

Extract the contents of the input data, add a string to it, and return the amended value.

Parameters:

data – Input data.

Returns:

Processed data.

reconstruct_data: bool | None
reduce_data: bool | None
save_figures: bool | None
class TomoMetadataProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None)

Bases: Processor

A processor that takes data from the FOXDEN Data Discovery or Metadata service and extracts what’s available to create a CHAP.common.models.map.MapConfig object for a tomography experiment.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

process(data, config)

Process the meta data and return a dictionary with extracted data to create a MapConfig for the tomography experiment.

Parameters:
  • data (list[PipelineData]) – Input data.

  • config (dict) – Any additional input data required to create a MapConfig that is unavailable from the Metadata service.

Returns:

Metadata from the tomography experiment.

Return type:

CHAP.common.models.map.MapConfig

class TomoSimFieldProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None)

Bases: Processor

A processor to create a simulated tomography data set returning a nexusformat.nexus.NXroot object containing the simulated tomography detector images.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

process(data)

Process the input configuration and return a nexusformat.nexus.NXroot object with the simulated tomography detector images.

Parameters:

data (list[PipelineData]) – Input configuration for the simulation.

Raises:

ValueError – Invalid input or configuration parameter.

Returns:

Simulated tomographic images.

Return type:

nexusformat.nexus.NXroot

class TomoSpecProcessor(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, scan_numbers: Annotated[list[Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]], Len(min_length=1, max_length=None)] | None = None)

Bases: Processor

A processor to create a tomography SPEC file associated with a simulated tomography data set created by TomoSimProcessor.

Variables:

scan_numbers – List of SPEC scan numbers.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

process(data)

Process the input configuration and return a list of strings representing a plain text SPEC file.

Parameters:

data (list[PipelineData]) – Input configuration for the simulation.

Raises:

ValueError – Invalid input or configuration parameter.

Returns:

Simulated SPEC file.

Return type:

list[str]

scan_numbers: Annotated[list[Annotated[int, None, Interval(gt=0, ge=None, lt=None, le=None), None]], Len(min_length=1, max_length=None)] | None
classmethod validate_scan_numbers(scan_numbers)

Validate the specified list of scan numbers.

Parameters:

scan_numbers (Union(int, list[int], str)) – List of scan numbers.

Returns:

List of scan numbers.

Return type:

list[int]

CHAP.tomo.reader module

Tomography specific reader.

CHAP.tomo.writer module

Tomography command line writer.

class TomoWriter(*, root: Annotated[Path, PathType(path_type=dir)] | None = '/home/runner/work/ChessAnalysisPipeline/ChessAnalysisPipeline/docs', inputdir: Annotated[Path, PathType(path_type=dir)] | None = None, outputdir: Annotated[Path, PathType(path_type=dir)] | None = None, interactive: bool | None = False, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = 'INFO', logger: Logger | None = None, name: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, schema: Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=None)] | None = None, filename: str, force_overwrite: bool | None = False, remove: bool | None = False)

Bases: Writer

Writer for saving tomo data.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

write(data)

Write the results of the (partial) tomographic reconstruction and add provenance data to the data pipeline.

Parameters:

data (list[PipelineData]) – Input data.

Returns:

Output data.

Return type:

list[PipelineData]

Module contents

This subpackage contains PipelineItems unique to tomography data processing workflows.