Skip to main content

MotionSeries

Struct MotionSeries 

Source
pub struct MotionSeries {
    pub reference: usize,
    pub volumes: Vec<VolumeMotion>,
}
Expand description

Where every volume of a series was, relative to the reference.

The output grid is the reference volume’s grid throughout: apply* resamples onto it, and VolumeMotion::bdir is expressed in it.

Fields§

§reference: usize

Index of the reference volume within the series.

§volumes: Vec<VolumeMotion>

One entry per input volume, in input order. The reference’s own entry is present and is the identity, so indices line up with the caller’s data and nothing has to be skipped.

Implementations§

Source§

impl MotionSeries

Source

pub fn len(&self) -> usize

Number of volumes in the series.

Source

pub fn is_empty(&self) -> bool

Whether the series is empty. Never true for a MotionSeries estimate_motion returned, which rejects an empty series.

Source

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

Dimensions of the output grid — the reference volume’s.

Source

pub fn affine(&self) -> [f64; 16]

Voxel→world affine of the output grid — the reference volume’s.

Source

pub fn bdirs(&self) -> Vec<(f64, f64, f64)>

Every volume’s B0 direction in the reference grid’s voxel frame, in input order — ready to hand to a multi-orientation inversion alongside the resampled field maps.

Source

pub fn max_displacement_mm(&self) -> f64

The largest tissue displacement anywhere in the series, in mm — the one number to compare against the voxel size when deciding whether the motion mattered. See VolumeMotion::max_displacement_mm.

Source

pub fn rotation_spread_deg(&self) -> f64

The largest angle between any two volumes’ recovered B0 directions, in degrees.

This, not the rotation relative to the reference, is what decides whether the series can be averaged: it is the spread of dipole-kernel orientations the average would be taken over. Zero for a series that only translated, however far it translated.

Source

pub fn suspect(&self) -> impl Iterator<Item = &VolumeMotion>

The volumes whose estimate looks untrustworthy. See VolumeMotion::suspect.

Source

pub fn apply(&self, t: usize, data: &[f64]) -> Option<Vec<f64>>

Resample volume t’s continuous data (magnitude, an unwrapped field map, χ) onto the reference grid.

Not for wrapped phase. Interpolating wrapped phase directly turns every wrap into a band of wrong values; use Self::apply_complex, which is why it exists.

Source

pub fn apply_complex( &self, t: usize, magnitude: &[f64], phase: &[f64], ) -> Option<(Vec<f64>, Vec<f64>)>

Resample volume t’s magnitude and wrapped phase onto the reference grid together, interpolating mag·e^{iφ} so the wraps survive. Returns (magnitude, phase).

Source

pub fn apply_mask(&self, t: usize, mask: &[u8]) -> Option<Vec<u8>>

Resample volume t’s binary mask or label volume onto the reference grid (nearest neighbour).

Source

pub fn coverage(&self, t: usize) -> Option<Vec<u8>>

Which reference voxels volume t reaches at all.

A rotated volume cannot fill the whole reference grid, and resampling leaves zeros where it does not reach. Those zeros are “no data”, not a zero measurement, and this is what tells them apart.

Source

pub fn common_coverage(&self) -> Option<Vec<u8>>

Reference voxels that every volume of the series reaches.

Source

pub fn average_complex<T: AsRef<[f64]>>( &self, magnitudes: &[T], phases: &[T], ) -> Option<MotionAverage>

Complex-average the series onto the reference grid: resample every volume’s magnitude/phase pair through its recovered transform, then take the complex mean over the volumes that reached each voxel.

The plain complex mean, not a magnitude-weighted one: for repeats with the same noise level that is the maximum-likelihood combination, and weighting by magnitude would bias the result toward whichever volume happened to be brightest.

Read MotionAverage before using this on a series that rotated.

Returns None if the number of magnitude or phase volumes disagrees with the series, or if any volume’s length disagrees with its own grid.

Trait Implementations§

Source§

impl Clone for MotionSeries

Source§

fn clone(&self) -> MotionSeries

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 MotionSeries

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> CloneAny for T
where T: Any + Clone,

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

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