Struct nifti::volume::inmem::InMemNiftiVolume
source · 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
impl InMemNiftiVolume
sourcepub fn from_raw_data(header: &NiftiHeader, raw_data: Vec<u8>) -> Result<Self>
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.
sourcepub fn from_raw_fields(
raw_dim: [u16; 8],
datatype: NiftiType,
scl_slope: f32,
scl_inter: f32,
raw_data: Vec<u8>,
endianness: Endianness
) -> Result<Self>
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
.
sourcepub fn from_reader<R: Read>(source: R, header: &NiftiHeader) -> Result<Self>
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).
sourcepub fn from_file<P: AsRef<Path>>(path: P, header: &NiftiHeader) -> Result<Self>
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.
sourcepub fn into_raw_data(self) -> Vec<u8>
pub fn into_raw_data(self) -> Vec<u8>
Retrieve the raw data, consuming the volume.
sourcepub fn raw_data_mut(&mut self) -> &mut [u8] ⓘ
pub fn raw_data_mut(&mut self) -> &mut [u8] ⓘ
Retrieve a mutable reference to the raw data.
sourcepub fn into_nifti_typed_data<T>(self) -> Result<Vec<T>>where
T: DataElement,
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
impl Clone for InMemNiftiVolume
source§fn clone(&self) -> InMemNiftiVolume
fn clone(&self) -> InMemNiftiVolume
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InMemNiftiVolume
impl Debug for InMemNiftiVolume
source§impl<R> FromSource<R> for InMemNiftiVolumewhere
R: Read,
impl<R> FromSource<R> for InMemNiftiVolumewhere R: Read,
source§fn from_reader(
reader: R,
header: &NiftiHeader,
(): Self::Options
) -> Result<Self>
fn from_reader( reader: R, header: &NiftiHeader, (): Self::Options ) -> Result<Self>
source§impl FromSourceOptions for InMemNiftiVolume
impl FromSourceOptions for InMemNiftiVolume
source§impl<'a> IntoNdArray for &'a InMemNiftiVolume
impl<'a> IntoNdArray for &'a InMemNiftiVolume
source§fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>where
T: DataElement,
fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>where T: DataElement,
Create an ndarray from the given volume.
source§impl IntoNdArray for InMemNiftiVolume
impl IntoNdArray for InMemNiftiVolume
source§fn into_ndarray<T>(self) -> Result<Array<T, IxDyn>>where
T: DataElement,
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
impl<'a> NiftiVolume for &'a InMemNiftiVolume
source§fn dim(&self) -> &[u16]
fn dim(&self) -> &[u16]
dim[0]
and is clipped to the effective number of dimensions.source§fn dimensionality(&self) -> usize
fn dimensionality(&self) -> usize
dim[0]
field
(with byte swapping already applied).source§impl NiftiVolume for InMemNiftiVolume
impl NiftiVolume for InMemNiftiVolume
source§fn dim(&self) -> &[u16]
fn dim(&self) -> &[u16]
dim[0]
and is clipped to the effective number of dimensions.source§fn dimensionality(&self) -> usize
fn dimensionality(&self) -> usize
dim[0]
field
(with byte swapping already applied).source§impl PartialEq<InMemNiftiVolume> for InMemNiftiVolume
impl PartialEq<InMemNiftiVolume> for InMemNiftiVolume
source§fn eq(&self, other: &InMemNiftiVolume) -> bool
fn eq(&self, other: &InMemNiftiVolume) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'a> RandomAccessNiftiVolume for &'a InMemNiftiVolume
impl<'a> RandomAccessNiftiVolume for &'a InMemNiftiVolume
source§fn get_f32(&self, coords: &[u16]) -> Result<f32>
fn get_f32(&self, coords: &[u16]) -> Result<f32>
ndarray
API for volume traversal. Read moresource§fn get_f64(&self, coords: &[u16]) -> Result<f64>
fn get_f64(&self, coords: &[u16]) -> Result<f64>
ndarray
API for volume traversal. Read moresource§fn get_u8(&self, coords: &[u16]) -> Result<u8>
fn get_u8(&self, coords: &[u16]) -> Result<u8>
ndarray
API for volume traversal. Read moresource§fn get_i8(&self, coords: &[u16]) -> Result<i8>
fn get_i8(&self, coords: &[u16]) -> Result<i8>
ndarray
API for volume traversal. Read moresource§fn get_u16(&self, coords: &[u16]) -> Result<u16>
fn get_u16(&self, coords: &[u16]) -> Result<u16>
ndarray
API for volume traversal. Read moresource§fn get_i16(&self, coords: &[u16]) -> Result<i16>
fn get_i16(&self, coords: &[u16]) -> Result<i16>
ndarray
API for volume traversal. Read moresource§fn get_u32(&self, coords: &[u16]) -> Result<u32>
fn get_u32(&self, coords: &[u16]) -> Result<u32>
ndarray
API for volume traversal. Read moresource§fn get_i32(&self, coords: &[u16]) -> Result<i32>
fn get_i32(&self, coords: &[u16]) -> Result<i32>
ndarray
API for volume traversal. Read moresource§fn get_u64(&self, coords: &[u16]) -> Result<u64>
fn get_u64(&self, coords: &[u16]) -> Result<u64>
ndarray
API for volume traversal. Read moresource§fn get_i64(&self, coords: &[u16]) -> Result<i64>
fn get_i64(&self, coords: &[u16]) -> Result<i64>
ndarray
API for volume traversal. Read moresource§impl RandomAccessNiftiVolume for InMemNiftiVolume
impl RandomAccessNiftiVolume for InMemNiftiVolume
source§fn get_f32(&self, coords: &[u16]) -> Result<f32>
fn get_f32(&self, coords: &[u16]) -> Result<f32>
ndarray
API for volume traversal. Read moresource§fn get_f64(&self, coords: &[u16]) -> Result<f64>
fn get_f64(&self, coords: &[u16]) -> Result<f64>
ndarray
API for volume traversal. Read moresource§fn get_u8(&self, coords: &[u16]) -> Result<u8>
fn get_u8(&self, coords: &[u16]) -> Result<u8>
ndarray
API for volume traversal. Read moresource§fn get_i8(&self, coords: &[u16]) -> Result<i8>
fn get_i8(&self, coords: &[u16]) -> Result<i8>
ndarray
API for volume traversal. Read moresource§fn get_u16(&self, coords: &[u16]) -> Result<u16>
fn get_u16(&self, coords: &[u16]) -> Result<u16>
ndarray
API for volume traversal. Read moresource§fn get_i16(&self, coords: &[u16]) -> Result<i16>
fn get_i16(&self, coords: &[u16]) -> Result<i16>
ndarray
API for volume traversal. Read moresource§fn get_u32(&self, coords: &[u16]) -> Result<u32>
fn get_u32(&self, coords: &[u16]) -> Result<u32>
ndarray
API for volume traversal. Read moresource§fn get_i32(&self, coords: &[u16]) -> Result<i32>
fn get_i32(&self, coords: &[u16]) -> Result<i32>
ndarray
API for volume traversal. Read moresource§fn get_u64(&self, coords: &[u16]) -> Result<u64>
fn get_u64(&self, coords: &[u16]) -> Result<u64>
ndarray
API for volume traversal. Read moresource§fn get_i64(&self, coords: &[u16]) -> Result<i64>
fn get_i64(&self, coords: &[u16]) -> Result<i64>
ndarray
API for volume traversal. Read moreimpl StructuralPartialEq for InMemNiftiVolume
Auto Trait Implementations§
impl RefUnwindSafe for InMemNiftiVolume
impl Send for InMemNiftiVolume
impl Sync for InMemNiftiVolume
impl Unpin for InMemNiftiVolume
impl UnwindSafe for InMemNiftiVolume
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<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.