mantidimaging.core.data.imagestack module#

class mantidimaging.core.data.imagestack.ImageStack(data: ndarray | SharedArray, filenames: list[Path] | None = None, indices: list[int] | Indices | None = None, metadata: dict[str, Any] | None = None, sinograms: bool = False, name: str | None = None)[source]#

Bases: object

clear_proj180deg() None[source]#
copy(flip_axes: bool = False) ImageStack[source]#
copy_roi(roi: SensibleROI) ImageStack[source]#
count() int[source]#
counts() Counts | None[source]#
static create_empty_image_stack(shape: tuple[int, ...], dtype: npt.DTypeLike, metadata: dict[str, Any]) ImageStack[source]#
property data: ndarray#
property dtype: dtype#
property filenames: list[Path] | None#
geometry: Geometry | None = None#
property h_middle: float#

Returns the horizontal middle (middle column) of the projections

has_proj180deg() bool[source]#
property height: int#
property id: UUID#
property is_processed: bool#
Returns:

True if any of the data has been processed, False otherwise.

property is_sinograms: bool#
load_metadata(f: TextIO) None[source]#

Load metadata json without overwriting existing values

property log_file: InstrumentLog | None#
make_name_unique(existing_names: list[str]) None[source]#
name: str#
property num_images: int#
property num_projections: int#
property num_sinograms: int#
property pixel_size: float#
property proj180deg: ImageStack | None#
proj_180_degree_shape_matches_images() bool[source]#
projection(projection_idx: int) ndarray[source]#
projection_angles(max_angle: float = 360.0) ProjectionAngles[source]#

Return projection angles, in priority order: - From a log - From the manually loaded file with a list of angles - Automatically generated with equidistant step

Parameters:

max_angle – The maximum angle up to which the angles will be generated. Only used when the angles are generated, if they are provided via a log or a file the argument will be ignored.

property projections: ndarray#
real_projection_angles() ProjectionAngles | None[source]#

Return projection angles from actual data sources (log files or manually loaded files).

This method returns angles that were either:
  • Explicitly set via projection_angles setter

  • Read from a log file during data loading

Returns:

Real projection angles if they were found, None otherwise.

record_operation(func_name: str, display_name: str, *args, **kwargs) None[source]#
save_metadata(f: TextIO, rescale_params: dict[str, str | float] | None = None) None[source]#
set_geometry() None[source]#

Creates an AcquisitionGeometry belonging to the ImageStack.

set_geometry_angles() None[source]#

Updates the geometry’s angle data based on its parent ImageStack’s projection angles if both geometry and projection angles are present.

Side effects:

Modifies self.geometry by updating its angle configuration.

set_geometry_panels() None[source]#

Updates the geometry’s panel data based on its parent ImageStack’s array data if both geometry and array data are present.

Set the number of pixels and the pixel size for the geometry panel based on the current width and height of the image stack.

Side effects:

Modifies self.geometry by updating its panel configuration.

set_projection_angles(angles: ProjectionAngles) None[source]#

Assigns a set of projection angles to the image stack and updates the associated geometry.

This method validates that the number of provided angles matches the number of images in the stack. If the geometry object is present, it updates its angles accordingly.

Parameters:

angles – An object containing the projection angles to assign, in radians.

Raises:

RuntimeError – If the number of angles does not match the number of images in the stack.

Side effects:

Updates the internal projection angles and, if available, updates the geometry’s angles.

property shared_array: SharedArray#
property shutter_count_file: ShutterCount | None#
sino(slice_idx: int) ndarray[source]#
sino_as_image_stack(index: int) ImageStack[source]#

A single sinogram slice as an ImageStack in projection ordering

property sinograms: ndarray#
slice_as_array(index: int) ndarray[source]#
slice_as_image_stack(index: int) ImageStack[source]#

A slice, either projection or sinogram depending on current ordering

property uses_shared_memory: bool#
property width: int#
exception mantidimaging.core.data.imagestack.StackNotFoundError(message: str, log_level: int = 40)[source]#

Bases: RuntimeError