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>

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>

Source

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

Source

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

Source

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

Source

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

Source

pub fn normalize_exposure(self) -> Self

Source

pub fn clamp_negative(self) -> Self

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

Source

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

Source

pub fn frame_len(&self) -> usize

Source

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

Source

pub fn preprocessing(&self) -> &PreprocessingConfig

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

Source

pub fn cached_byte_count(&self) -> usize

Source

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

Source

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

Source

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

Source

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

Source

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

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

Source§

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

Source§

fn frame_len(&self) -> usize

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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> 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> 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,