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

cleanup() 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]#
create_geometry(angles: ProjectionAngles, geom_type: GeometryType = GeometryType.PARALLEL3D) None[source]#

Creates a Geometry of given type belonging to the ImageStack Angles should be given in radians

create_geometry_from_cil_acq(acquisition_geometry: AcquisitionGeometry) None[source]#

Creates a Geometry belong to the ImageStack from a CIL AcquisitionGeometry object.

property data: ndarray#

Get a reference to the internal numpy array holding the image data

Note

Do not hold on to this reference longer than the lifetime of the ImageStack. ImageStack use the operating system’s shared memory, which will be freed when the ImageStack has no remaining references. A reference to this array will not keep that shared memory alive.

property dtype: dtype#
property filenames: list[Path] | None#
find_image_from_angle(target_angle: float, tol: float | None = None) int[source]#
property full_stack_shape: tuple[int, ...] | None#

The original shape of the stack irrespective of preview subsetting. For preview subsets: Returns the full shape instead of the sliced shape.

Property should be set when preview is updated, allowing operations to validate against the stacks full shape instead of the preview subset shape.

Returns:

The full shape of the stack as a tuple of ints (z, y, x) or None if not set.

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#
is_temporary: bool = False#
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 ndim: int#
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() 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.

property projections: ndarray#
record_operation(func_name: str, display_name: str, *args, **kwargs) None[source]#
reorder_images_by_index(index: ndarray) None[source]#
save_metadata(f: TextIO, rescale_params: dict[str, str | float] | None = None) None[source]#
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 shape: tuple[int, ...]#
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#
property size: int#
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