pub struct InMemNiftiVolume { /* private fields */ }
Expand description

A data type for a NIFTI-1 volume contained in memory. Objects of this type contain raw image data, which is converted automatically when using reading methods or converting it to an ndarray (only with the ndarray_volumes feature).

Since NIfTI volumes are stored in disk in column major order (also called Fortran order), this data type will also retain this memory order.

Implementations§

source§

impl InMemNiftiVolume

source

pub fn from_raw_data(header: &NiftiHeader, raw_data: Vec<u8>) -> Result<Self>

Build an InMemNiftiVolume from a header and a buffer. The buffer length and the dimensions declared in the header are expected to fit.

source

pub fn from_raw_fields( raw_dim: [u16; 8], datatype: NiftiType, scl_slope: f32, scl_inter: f32, raw_data: Vec<u8>, endianness: Endianness ) -> Result<Self>

Build an InMemNiftiVolume from its raw set of attributes. The raw data is assumed to contain exactly enough bytes to contain the data elements of the volume in F-major order, with the byte order specified in endianness, as specified by the volume shape in raw_dim and data type in datatype.

source

pub fn from_reader<R: Read>(source: R, header: &NiftiHeader) -> Result<Self>

Read a NIFTI volume from a stream of data. The header and expected byte order of the volume’s data must be known in advance. It it also expected that the following bytes represent the first voxels of the volume (and not part of the extensions).

source

pub fn from_file<P: AsRef<Path>>(path: P, header: &NiftiHeader) -> Result<Self>

Read a NIFTI volume from an image file. NIFTI-1 volume files usually have the extension “.img” or “.img.gz”. In the latter case, the file is automatically decoded as a Gzip stream.

source

pub fn into_raw_data(self) -> Vec<u8>

Retrieve the raw data, consuming the volume.

source

pub fn raw_data(&self) -> &[u8]

Retrieve a reference to the raw data.

source

pub fn raw_data_mut(&mut self) -> &mut [u8]

Retrieve a mutable reference to the raw data.

source

pub fn into_nifti_typed_data<T>(self) -> Result<Vec<T>>where T: DataElement,

Retrieve the raw data, typed as specified in the volume’s header, consuming the volume

Trait Implementations§

source§

impl Clone for InMemNiftiVolume

source§

fn clone(&self) -> InMemNiftiVolume

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 Debug for InMemNiftiVolume

source§

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

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

impl<R> FromSource<R> for InMemNiftiVolumewhere R: Read,

source§

fn from_reader( reader: R, header: &NiftiHeader, (): Self::Options ) -> Result<Self>

Read a NIfTI volume from a stream of raw voxel data. The header and expected byte order of the volume’s data must be known in advance. It is also expected that the following bytes represent the first voxels of the volume (and not part of the extensions).
source§

impl FromSourceOptions for InMemNiftiVolume

§

type Options = ()

Set of additional options required (or useful) for constructing a volume.
source§

impl<'a> IntoNdArray for &'a InMemNiftiVolume

source§

fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>where T: DataElement,

Create an ndarray from the given volume.

source§

impl IntoNdArray for InMemNiftiVolume

source§

fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>where T: DataElement,

Consume the volume into an ndarray.

source§

impl<'a> NiftiVolume for &'a InMemNiftiVolume

source§

fn dim(&self) -> &[u16]

Get the dimensions of the volume. Unlike how NIFTI-1 stores dimensions, the returned slice does not include dim[0] and is clipped to the effective number of dimensions.
source§

fn dimensionality(&self) -> usize

Get the volume’s number of dimensions. In a fully compliant file, this is equivalent to the corresponding header’s dim[0] field (with byte swapping already applied).
source§

fn data_type(&self) -> NiftiType

Get this volume’s data type.
source§

impl NiftiVolume for InMemNiftiVolume

source§

fn dim(&self) -> &[u16]

Get the dimensions of the volume. Unlike how NIFTI-1 stores dimensions, the returned slice does not include dim[0] and is clipped to the effective number of dimensions.
source§

fn dimensionality(&self) -> usize

Get the volume’s number of dimensions. In a fully compliant file, this is equivalent to the corresponding header’s dim[0] field (with byte swapping already applied).
source§

fn data_type(&self) -> NiftiType

Get this volume’s data type.
source§

impl PartialEq<InMemNiftiVolume> for InMemNiftiVolume

source§

fn eq(&self, other: &InMemNiftiVolume) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> RandomAccessNiftiVolume for &'a InMemNiftiVolume

source§

fn get_f32(&self, coords: &[u16]) -> Result<f32>

Fetch a single voxel’s value in the given voxel index coordinates as a single precision floating point value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_f64(&self, coords: &[u16]) -> Result<f64>

Fetch a single voxel’s value in the given voxel index coordinates as a double precision floating point value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u8(&self, coords: &[u16]) -> Result<u8>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 8-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i8(&self, coords: &[u16]) -> Result<i8>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 8-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u16(&self, coords: &[u16]) -> Result<u16>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 16-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i16(&self, coords: &[u16]) -> Result<i16>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 16-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u32(&self, coords: &[u16]) -> Result<u32>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 32-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i32(&self, coords: &[u16]) -> Result<i32>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 32-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u64(&self, coords: &[u16]) -> Result<u64>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 64-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i64(&self, coords: &[u16]) -> Result<i64>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 64-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

impl RandomAccessNiftiVolume for InMemNiftiVolume

source§

fn get_f32(&self, coords: &[u16]) -> Result<f32>

Fetch a single voxel’s value in the given voxel index coordinates as a single precision floating point value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_f64(&self, coords: &[u16]) -> Result<f64>

Fetch a single voxel’s value in the given voxel index coordinates as a double precision floating point value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u8(&self, coords: &[u16]) -> Result<u8>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 8-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i8(&self, coords: &[u16]) -> Result<i8>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 8-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u16(&self, coords: &[u16]) -> Result<u16>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 16-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i16(&self, coords: &[u16]) -> Result<i16>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 16-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u32(&self, coords: &[u16]) -> Result<u32>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 32-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i32(&self, coords: &[u16]) -> Result<i32>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 32-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_u64(&self, coords: &[u16]) -> Result<u64>

Fetch a single voxel’s value in the given voxel index coordinates as an unsigned 64-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

fn get_i64(&self, coords: &[u16]) -> Result<i64>

Fetch a single voxel’s value in the given voxel index coordinates as a signed 64-bit value. All necessary conversions and transformations are made when reading the voxel, including scaling. Note that using this function continuously to traverse the volume is inefficient. Prefer using iterators or the ndarray API for volume traversal. Read more
source§

impl StructuralPartialEq for InMemNiftiVolume

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SPwhere 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 Twhere 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 Twhere 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 Twhere 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.
source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,