Skip to main content

LazyMeasurementStack

Struct LazyMeasurementStack 

Source
pub struct LazyMeasurementStack { /* private fields */ }
Expand description

File-backed measurement frames decoded, preprocessed, and cached on access.

Construction reads image headers to validate grayscale type and dimensions, but does not decode measurement pixel buffers. A bounded thread-safe LRU cache keeps the working set out of core while returned shared frame handles remain stable. Cache byte accounting covers frame pixel buffers retained by the cache, not handles that callers keep alive after eviction.

Frame decoding occurs without holding the cache mutex, so callers can read different uncached frames concurrently; a second lookup makes concurrent reads of the same frame converge on one cached handle. A poisoned cache is treated as corrupted state: Self::frame returns an error rather than reusing it. The infallible cache-statistics accessors report zero after poisoning because they cannot expose that error; rebuild the stack before using it again.

Implementations§

Source§

impl LazyMeasurementStack

Source

pub fn from_image_files<P: AsRef<Path>>( paths: &[P], frame_metadata: Vec<FrameMetadata>, ) -> Result<Self>

Opens same-shaped grayscale files without decoding their pixels until requested.

Source

pub fn from_tiff_stack( path: impl AsRef<Path>, frame_metadata: Vec<FrameMetadata>, ) -> Result<Self>

Opens a multipage TIFF lazily. Page headers are validated up front, but each page’s pixels are decoded only when that frame is requested.

Source

pub fn from_manifest(path: impl AsRef<Path>) -> Result<Self>

Loads a manifest while leaving measurement frames file-backed. Small shared correction images and optional per-frame backgrounds/masks are loaded once; configured corrections are applied during frame decoding.

Source

pub fn from_manifest_definition( manifest: MeasurementSpec, base_directory: impl AsRef<Path>, ) -> Result<Self>

Opens a manifest value lazily, resolving relative paths beneath base_directory.

Source

pub fn with_dark_frame(self, dark: Vec<f64>) -> Result<Self>

Stores one finite row-major dark frame and enables subtraction during decoding.

Source

pub fn with_flat_field(self, flat: Vec<f64>) -> Result<Self>

Stores one positive finite row-major flat field and enables division during decoding.

Source

pub fn with_background(self, background: Vec<f64>) -> Result<Self>

Stores a finite broadcast frame or full (frame, row, column) background stack.

Source

pub fn with_masks(self, masks: Vec<u8>) -> Result<Self>

Stores a binary broadcast mask or full row-major (frame, row, column) mask stack.

Source

pub fn normalize_exposure(self) -> Self

Enables division by each frame’s positive exposure time during decoding.

Source

pub fn clamp_negative(self) -> Self

Enables clamping corrected negative intensities to zero during decoding.

Source

pub fn with_preprocessing( self, preprocessing: PreprocessingConfig, ) -> Result<Self>

Replaces the preprocessing flags. Required correction arrays must have already been supplied through the corresponding builder.

Source

pub fn with_cache_capacity(self, capacity: usize) -> Result<Self>

Sets the maximum decoded frames retained in memory. The default is one.

Source

pub fn with_cache_byte_capacity(self, capacity: usize) -> Result<Self>

Sets a second cache limit in bytes. It must fit at least one decoded f64 frame. Count and byte limits are enforced simultaneously.

Source

pub fn frame_count(&self) -> usize

Returns the acquisition-frame count.

Source

pub fn image_shape(&self) -> (usize, usize)

Returns low-resolution frame shape as (height, width).

Source

pub fn frame_len(&self) -> usize

Returns the row-major element count of one decoded frame.

Source

pub fn frame_metadata(&self) -> &[FrameMetadata]

Borrows metadata in acquisition-frame order.

Source

pub fn preprocessing(&self) -> &PreprocessingConfig

Borrows corrections applied when an uncached frame is decoded.

Source

pub fn paths(&self) -> &[PathBuf]

Returns one path per frame. Multipage TIFF frames therefore repeat the stack path and can be distinguished by their metadata labels.

Source

pub fn cached_frame_count(&self) -> usize

Returns the decoded-frame count, or zero if the cache lock is poisoned.

Source

pub fn cached_byte_count(&self) -> usize

Returns bytes occupied by decoded f64 frames, or zero after lock poisoning.

Source

pub fn frame(&self, index: usize) -> Result<Arc<Vec<f64>>>

Returns a shared row-major decoded intensity frame, loading and caching on a miss.

Source

pub fn frame_weight(&self, index: usize) -> Result<f64>

Returns a frame’s non-negative reconstruction weight.

Source

pub fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>

Borrows a frame’s binary row-major mask, including a broadcast mask.

Source

pub fn materialize(&self) -> Result<MeasurementStack>

Decodes every frame into a new resident MeasurementStack.

Source

pub fn validate(&self) -> Result<()>

Checks paths/page indices/metadata counts, shape and cache capacities, metadata, required correction buffers, background and mask lengths, and finite values.

Trait Implementations§

Source§

impl Clone for LazyMeasurementStack

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LazyMeasurementStack

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MeasurementRead for LazyMeasurementStack

Source§

fn frame_count(&self) -> usize

Returns the number of acquisition frames.
Source§

fn image_shape(&self) -> (usize, usize)

Returns low-resolution image shape as (height, width).
Source§

fn frame_len(&self) -> usize

Returns height * width, the row-major element count of one frame.
Source§

fn frame(&self, index: usize) -> Result<impl Deref<Target = [f64]> + '_>

Borrows or shares a row-major intensity frame by zero-based acquisition index.
Source§

fn frame_weight(&self, index: usize) -> Result<f64>

Returns a frame’s non-negative reconstruction weight.
Source§

fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>

Borrows an optional row-major binary validity mask for one frame.
Source§

fn frame_metadata(&self) -> &[FrameMetadata]

Borrows metadata in acquisition-frame order.
Source§

fn validate(&self) -> Result<()>

Checks shapes, counts, finite intensities, metadata, weights, and masks.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Key for T
where T: Clone,

§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
§

fn size(&self) -> usize

The size of the key in bytes.
§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,