[−][src]Struct nifti::header::NiftiHeader
The NIFTI-1 header data type. All fields are public and named after the specification's header file. The type of each field was adjusted according to their use and array limitations.
Examples
use nifti::{NiftiHeader, Endianness}; let hdr1 = NiftiHeader::from_file("0000.hdr")?; let hdr2 = NiftiHeader::from_file("0001.hdr.gz")?; let hdr3 = NiftiHeader::from_file("4321.nii.gz")?;
Or to build one yourself:
let mut hdr = NiftiHeader::default(); hdr.cal_min = 0.; hdr.cal_max = 128.; hdr.datatype = 4; assert_eq!(hdr.cal_min, 0.); assert_eq!(hdr.cal_max, 128.); assert_eq!(hdr.data_type().unwrap(), NiftiType::Int16);
Fields
sizeof_hdr: i32
Header size, must be 348
data_type: [u8; 10]
Unused in NIFTI-1
db_name: [u8; 18]
Unused in NIFTI-1
extents: i32
Unused in NIFTI-1
session_error: i16
Unused in NIFTI-1
regular: u8
Unused in NIFTI-1
dim_info: u8
MRI slice ordering
dim: [u16; 8]
Data array dimensions
intent_p1: f32
1st intent parameter
intent_p2: f32
2nd intent parameter
intent_p3: f32
3rd intent parameter
intent_code: i16
NIFTI_INTENT_* code
datatype: i16
Defines the data type!
bitpix: i16
Number of bits per voxel
slice_start: i16
First slice index
pixdim: [f32; 8]
Grid spacings
vox_offset: f32
Offset into .nii file to reach the volume
scl_slope: f32
Data scaling: slope
scl_inter: f32
Data scaling: offset
slice_end: i16
Last slice index
slice_code: u8
Slice timing order
xyzt_units: u8
Units of pixdim[1..4]
cal_max: f32
Max display intensity
cal_min: f32
Min display intensity
slice_duration: f32
Time for 1 slice
toffset: f32
Time axis shift
glmax: i32
Unused in NIFTI-1
glmin: i32
Unused in NIFTI-1
descrip: Vec<u8>
Any text you like
aux_file: [u8; 24]
Auxiliary filename
qform_code: i16
NIFTI_XFORM_* code
sform_code: i16
NIFTI_XFORM_* code
quatern_b: f32
Quaternion b param
quatern_c: f32
Quaternion c param
quatern_d: f32
Quaternion d param
quatern_x: f32
Quaternion x shift
quatern_y: f32
Quaternion y shift
quatern_z: f32
Quaternion z shift
srow_x: [f32; 4]
1st row affine transform
srow_y: [f32; 4]
2nd row affine transform
srow_z: [f32; 4]
3rd row affine transform
intent_name: [u8; 16]
'name' or meaning of data
magic: [u8; 4]
Magic code. Must be b"ni1\0"
or b"ni+\0"
endianness: Endianness
Original data Endianness
Methods
impl NiftiHeader
[src]
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<NiftiHeader>
[src]
Retrieve a NIFTI header, along with its byte order, from a file in the file system. If the file's name ends with ".gz", the file is assumed to need GZip decoding.
pub fn from_stream<S: Read>(input: S) -> Result<NiftiHeader>
[src]
use from_reader
instead
Read a NIfTI-1 header, along with its byte order, from the given byte stream. It is assumed that the input is currently at the start of the NIFTI header.
pub fn from_reader<S>(input: S) -> Result<NiftiHeader> where
S: Read,
[src]
S: Read,
Read a NIfTI-1 header, along with its byte order, from the given byte stream. It is assumed that the input is currently at the start of the NIFTI header.
pub fn dim(&self) -> Result<&[u16]>
[src]
Retrieve and validate 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.
Error
NiftiError::InconsistentDim
if dim[0]
does not represent a valid
dimensionality, or any of the real dimensions are zero.
pub fn dimensionality(&self) -> Result<usize>
[src]
Retrieve and validate the number of dimensions of the volume. This is
dim[0]
after the necessary byte order conversions.
Error
NiftiError::
if dim[0]
does not represent a valid dimensionality
(it must be positive and not higher than 7).
pub fn data_type(&self) -> Result<NiftiType>
[src]
Get the data type as a validated enum.
pub fn xyzt_to_space(&self) -> Result<Unit>
[src]
Get the spatial units type as a validated unit enum.
pub fn xyzt_to_time(&self) -> Result<Unit>
[src]
Get the time units type as a validated unit enum.
pub fn xyzt_units(&self) -> Result<(Unit, Unit)>
[src]
Get the xyzt units type as a validated pair of space and time unit enum.
pub fn slice_order(&self) -> Result<SliceOrder>
[src]
Get the slice order as a validated enum.
pub fn intent(&self) -> Result<Intent>
[src]
Get the intent as a validated enum.
pub fn qform(&self) -> Result<XForm>
[src]
Get the qform coordinate mapping method as a validated enum.
pub fn sform(&self) -> Result<XForm>
[src]
Get the sform coordinate mapping method as a validated enum.
pub fn validate_description(&mut self) -> Result<()>
[src]
Ensure that the current descrip
field is valid and is exactly equal to 80 bytes.
Descriptions shorter than 80 bytes will be extended with trailing zeros.
pub fn set_description<D>(&mut self, description: D) -> Result<()> where
D: Into<Vec<u8>>,
D: Deref<Target = [u8]>,
[src]
D: Into<Vec<u8>>,
D: Deref<Target = [u8]>,
Safely set the descrip
field using a buffer.
pub fn set_description_str<T>(&mut self, description: T) -> Result<()> where
T: Into<String>,
[src]
T: Into<String>,
Safely set the descrip
field using a &str.
Trait Implementations
impl PartialEq<NiftiHeader> for NiftiHeader
[src]
fn eq(&self, other: &NiftiHeader) -> bool
[src]
fn ne(&self, other: &NiftiHeader) -> bool
[src]
impl Clone for NiftiHeader
[src]
fn clone(&self) -> NiftiHeader
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for NiftiHeader
[src]
fn default() -> NiftiHeader
[src]
impl Debug for NiftiHeader
[src]
Auto Trait Implementations
impl Send for NiftiHeader
impl Unpin for NiftiHeader
impl Sync for NiftiHeader
impl RefUnwindSafe for NiftiHeader
impl UnwindSafe for NiftiHeader
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,