Struct mzsignal::average::SignalAverager

source ·
pub struct SignalAverager<'lifespan> {
    pub mz_grid: Vec<f64>,
    pub mz_start: f64,
    pub mz_end: f64,
    pub dx: f64,
    pub array_pairs: VecDeque<ArrayPair<'lifespan>>,
}
Expand description

A linear interpolation spectrum intensity averager over a shared m/z axis.

Fields§

§mz_grid: Vec<f64>

The evenly spaced m/z axis over which spectra are averaged.

§mz_start: f64

The lowest m/z in the spectrum. If an input spectrum has lower m/z values, they will be ignored.

§mz_end: f64

The highest m/z in the spectrum. If an input spectrum has higher m/z values, they will be ignored.

§dx: f64

The spacing between m/z values in mz_grid. This value should be chosen relative to the sharpness of the peak shape of the mass analyzer used, but the smaller it is, the more computationally intensive the averaging process is, and the more memory it consumes.

§array_pairs: VecDeque<ArrayPair<'lifespan>>

The current set of spectra to be averaged together. This uses a deque because the usecase of pushing spectra into an averaging window while removing them from the other side fits with the way one might average spectra over time.

Implementations§

source§

impl<'a, 'b: 'a> SignalAverager<'a>

source

pub fn new(mz_start: f64, mz_end: f64, dx: f64) -> SignalAverager<'a>

source

pub fn push(&mut self, pair: ArrayPair<'b>)

Put pair into the queue of arrays being averaged together.

source

pub fn pop(&mut self) -> Option<ArrayPair<'a>>

Remove the least recently added array pair from the queue.

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn interpolate_point( &self, mz_j: f64, mz_x: f64, mz_j1: f64, inten_j: f64, inten_j1: f64 ) -> f64

Linear interpolation between two control points to find the intensity at a third point between them.

§Arguments
  • mz_j - The first control point’s m/z
  • mz_x - The interpolated m/z
  • mz_j1 - The second control point’s m/z
  • inten_j - The first control point’s intensity
  • inten_j1 - The second control point’s intensity
source

pub fn interpolate_into( &self, out: &mut [f32], start_mz: f64, end_mz: f64 ) -> usize

A linear interpolation across all spectra between start_mz and end_mz, with their intensities written into out.

source

pub fn interpolate_chunks(&self, n_chunks: usize) -> Vec<f32>

source

pub fn interpolate(&'a self) -> Vec<f32>

Allocate a new intensity array, interpolate_into it, and return it.

Trait Implementations§

source§

impl<'lifespan> Clone for SignalAverager<'lifespan>

source§

fn clone(&self) -> SignalAverager<'lifespan>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'lifespan> Debug for SignalAverager<'lifespan>

source§

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

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

impl<'lifespan> Default for SignalAverager<'lifespan>

source§

fn default() -> SignalAverager<'lifespan>

Returns the “default value” for a type. Read more
source§

impl<'lifespan> Extend<ArrayPair<'lifespan>> for SignalAverager<'lifespan>

source§

fn extend<T: IntoIterator<Item = ArrayPair<'lifespan>>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'lifespan> MZGrid for SignalAverager<'lifespan>

source§

fn mz_grid(&self) -> &[f64]

source§

fn create_intensity_array(&self) -> Vec<f32>

source§

fn create_intensity_array_of_size(&self, size: usize) -> Vec<f32>

source§

fn find_offset(&self, mz: f64) -> usize

source§

fn points_between(&self, start_mz: f64, end_mz: f64) -> usize

source§

fn copy_mz_array(&self) -> Vec<f64>

Auto Trait Implementations§

§

impl<'lifespan> Freeze for SignalAverager<'lifespan>

§

impl<'lifespan> RefUnwindSafe for SignalAverager<'lifespan>

§

impl<'lifespan> Send for SignalAverager<'lifespan>

§

impl<'lifespan> Sync for SignalAverager<'lifespan>

§

impl<'lifespan> Unpin for SignalAverager<'lifespan>

§

impl<'lifespan> UnwindSafe for SignalAverager<'lifespan>

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> 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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

§

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

§

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.