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
impl LazyMeasurementStack
Sourcepub fn from_image_files<P: AsRef<Path>>(
paths: &[P],
frame_metadata: Vec<FrameMetadata>,
) -> Result<Self>
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.
Sourcepub fn from_tiff_stack(
path: impl AsRef<Path>,
frame_metadata: Vec<FrameMetadata>,
) -> Result<Self>
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.
Sourcepub fn from_manifest(path: impl AsRef<Path>) -> Result<Self>
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.
Sourcepub fn from_manifest_definition(
manifest: MeasurementSpec,
base_directory: impl AsRef<Path>,
) -> Result<Self>
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.
Sourcepub fn with_dark_frame(self, dark: Vec<f64>) -> Result<Self>
pub fn with_dark_frame(self, dark: Vec<f64>) -> Result<Self>
Stores one finite row-major dark frame and enables subtraction during decoding.
Sourcepub fn with_flat_field(self, flat: Vec<f64>) -> Result<Self>
pub fn with_flat_field(self, flat: Vec<f64>) -> Result<Self>
Stores one positive finite row-major flat field and enables division during decoding.
Sourcepub fn with_background(self, background: Vec<f64>) -> Result<Self>
pub fn with_background(self, background: Vec<f64>) -> Result<Self>
Stores a finite broadcast frame or full (frame, row, column) background stack.
Sourcepub fn with_masks(self, masks: Vec<u8>) -> Result<Self>
pub fn with_masks(self, masks: Vec<u8>) -> Result<Self>
Stores a binary broadcast mask or full row-major (frame, row, column) mask stack.
Sourcepub fn normalize_exposure(self) -> Self
pub fn normalize_exposure(self) -> Self
Enables division by each frame’s positive exposure time during decoding.
Sourcepub fn clamp_negative(self) -> Self
pub fn clamp_negative(self) -> Self
Enables clamping corrected negative intensities to zero during decoding.
Sourcepub fn with_preprocessing(
self,
preprocessing: PreprocessingConfig,
) -> Result<Self>
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.
Sourcepub fn with_cache_capacity(self, capacity: usize) -> Result<Self>
pub fn with_cache_capacity(self, capacity: usize) -> Result<Self>
Sets the maximum decoded frames retained in memory. The default is one.
Sourcepub fn with_cache_byte_capacity(self, capacity: usize) -> Result<Self>
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.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Returns the acquisition-frame count.
Sourcepub fn image_shape(&self) -> (usize, usize)
pub fn image_shape(&self) -> (usize, usize)
Returns low-resolution frame shape as (height, width).
Sourcepub fn frame_metadata(&self) -> &[FrameMetadata]
pub fn frame_metadata(&self) -> &[FrameMetadata]
Borrows metadata in acquisition-frame order.
Sourcepub fn preprocessing(&self) -> &PreprocessingConfig
pub fn preprocessing(&self) -> &PreprocessingConfig
Borrows corrections applied when an uncached frame is decoded.
Sourcepub fn paths(&self) -> &[PathBuf]
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.
Sourcepub fn cached_frame_count(&self) -> usize
pub fn cached_frame_count(&self) -> usize
Returns the decoded-frame count, or zero if the cache lock is poisoned.
Sourcepub fn cached_byte_count(&self) -> usize
pub fn cached_byte_count(&self) -> usize
Returns bytes occupied by decoded f64 frames, or zero after lock poisoning.
Sourcepub fn frame(&self, index: usize) -> Result<Arc<Vec<f64>>>
pub fn frame(&self, index: usize) -> Result<Arc<Vec<f64>>>
Returns a shared row-major decoded intensity frame, loading and caching on a miss.
Sourcepub fn frame_weight(&self, index: usize) -> Result<f64>
pub fn frame_weight(&self, index: usize) -> Result<f64>
Returns a frame’s non-negative reconstruction weight.
Sourcepub fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>
pub fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>
Borrows a frame’s binary row-major mask, including a broadcast mask.
Sourcepub fn materialize(&self) -> Result<MeasurementStack>
pub fn materialize(&self) -> Result<MeasurementStack>
Decodes every frame into a new resident MeasurementStack.
Trait Implementations§
Source§impl Clone for LazyMeasurementStack
impl Clone for LazyMeasurementStack
Source§impl Debug for LazyMeasurementStack
impl Debug for LazyMeasurementStack
Source§impl MeasurementRead for LazyMeasurementStack
impl MeasurementRead for LazyMeasurementStack
Source§fn frame_count(&self) -> usize
fn frame_count(&self) -> usize
Source§fn image_shape(&self) -> (usize, usize)
fn image_shape(&self) -> (usize, usize)
(height, width).Source§fn frame_len(&self) -> usize
fn frame_len(&self) -> usize
height * width, the row-major element count of one frame.Source§fn frame(&self, index: usize) -> Result<impl Deref<Target = [f64]> + '_>
fn frame(&self, index: usize) -> Result<impl Deref<Target = [f64]> + '_>
Source§fn frame_weight(&self, index: usize) -> Result<f64>
fn frame_weight(&self, index: usize) -> Result<f64>
Source§fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>
fn frame_mask(&self, index: usize) -> Result<Option<&[u8]>>
Source§fn frame_metadata(&self) -> &[FrameMetadata]
fn frame_metadata(&self) -> &[FrameMetadata]
Auto Trait Implementations§
impl !Freeze for LazyMeasurementStack
impl RefUnwindSafe for LazyMeasurementStack
impl Send for LazyMeasurementStack
impl Sync for LazyMeasurementStack
impl Unpin for LazyMeasurementStack
impl UnsafeUnpin for LazyMeasurementStack
impl UnwindSafe for LazyMeasurementStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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