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>
impl<'a, 'b: 'a> SignalAverager<'a>
pub fn new(mz_start: f64, mz_end: f64, dx: f64) -> SignalAverager<'a>
sourcepub fn push(&mut self, pair: ArrayPair<'b>)
pub fn push(&mut self, pair: ArrayPair<'b>)
Put pair
into the queue of arrays being averaged together.
sourcepub fn pop(&mut self) -> Option<ArrayPair<'a>>
pub fn pop(&mut self) -> Option<ArrayPair<'a>>
Remove the least recently added array pair from the queue.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
sourcepub fn interpolate_point(
&self,
mz_j: f64,
mz_x: f64,
mz_j1: f64,
inten_j: f64,
inten_j1: f64
) -> f64
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/zmz_x
- The interpolated m/zmz_j1
- The second control point’s m/zinten_j
- The first control point’s intensityinten_j1
- The second control point’s intensity
sourcepub fn interpolate_into(
&self,
out: &mut [f32],
start_mz: f64,
end_mz: f64
) -> usize
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
.
pub fn interpolate_chunks(&self, n_chunks: usize) -> Vec<f32>
sourcepub fn interpolate(&'a self) -> Vec<f32>
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>
impl<'lifespan> Clone for SignalAverager<'lifespan>
source§fn clone(&self) -> SignalAverager<'lifespan>
fn clone(&self) -> SignalAverager<'lifespan>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'lifespan> Debug for SignalAverager<'lifespan>
impl<'lifespan> Debug for SignalAverager<'lifespan>
source§impl<'lifespan> Default for SignalAverager<'lifespan>
impl<'lifespan> Default for SignalAverager<'lifespan>
source§fn default() -> SignalAverager<'lifespan>
fn default() -> SignalAverager<'lifespan>
source§impl<'lifespan> Extend<ArrayPair<'lifespan>> for SignalAverager<'lifespan>
impl<'lifespan> Extend<ArrayPair<'lifespan>> for SignalAverager<'lifespan>
source§fn extend<T: IntoIterator<Item = ArrayPair<'lifespan>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = ArrayPair<'lifespan>>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<'lifespan> MZGrid for SignalAverager<'lifespan>
impl<'lifespan> MZGrid for SignalAverager<'lifespan>
fn mz_grid(&self) -> &[f64]
fn create_intensity_array(&self) -> Vec<f32>
fn create_intensity_array_of_size(&self, size: usize) -> Vec<f32>
fn find_offset(&self, mz: f64) -> usize
fn points_between(&self, start_mz: f64, end_mz: f64) -> usize
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> 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> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.