pub struct Tractogram { /* private fields */ }Expand description
Neutral in-memory streamline representation used for cross-format conversion.
Positions are stored in world/RASMM-style coordinates as f32 triplets.
dps (data-per-streamline) and dpv (data-per-vertex) ride along
unchanged through any operation that doesn’t reorder streamlines or
vertices — including crate::transform::apply_transform_in_place,
which only mutates the positions buffer.
Implementations§
Source§impl Tractogram
impl Tractogram
Sourcepub fn with_header(header: Header) -> Self
pub fn with_header(header: Header) -> Self
Create an empty tractogram with a caller-provided header.
Sourcepub fn from_trx<P: TrxScalar>(trx: &TrxFile<P>) -> Self
pub fn from_trx<P: TrxScalar>(trx: &TrxFile<P>) -> Self
Build a tractogram by copying streamline geometry from a typed TRX file.
Sourcepub fn from_any_trx(trx: &AnyTrxFile) -> Self
pub fn from_any_trx(trx: &AnyTrxFile) -> Self
Build a tractogram by copying streamline geometry from a dtype-erased TRX file.
pub fn header(&self) -> &Header
pub fn set_spatial_metadata( &mut self, voxel_to_rasmm: [[f64; 4]; 4], dimensions: [u64; 3], )
pub fn set_header(&mut self, header: Header)
pub fn extra(&self) -> &HashMap<String, Value>
pub fn extra_mut(&mut self) -> &mut HashMap<String, Value>
pub fn positions(&self) -> &[[f32; 3]]
Sourcepub fn positions_mut(&mut self) -> &mut [[f32; 3]]
pub fn positions_mut(&mut self) -> &mut [[f32; 3]]
Mutable view of the contiguous positions buffer.
Useful for in-place spatial transforms (see crate::transform).
Streamline boundaries (offsets) are unaffected by point edits, so
callers may mutate the slice freely without invalidating any
metadata.
pub fn offsets(&self) -> &[u32]
pub fn group_names(&self) -> impl Iterator<Item = &str>
pub fn group(&self, name: &str) -> Option<&[u32]>
pub fn groups(&self) -> &HashMap<String, Vec<u32>>
pub fn insert_group(&mut self, name: impl Into<String>, members: Vec<u32>)
pub fn insert_dpg( &mut self, group: impl Into<String>, name: impl Into<String>, data: DataArray, )
pub fn dpg(&self) -> &DataPerGroup
pub fn dps_arrays(&self) -> &HashMap<String, DataArray>
pub fn dpv_arrays(&self) -> &HashMap<String, DataArray>
pub fn dps_names(&self) -> impl Iterator<Item = &str>
pub fn dpv_names(&self) -> impl Iterator<Item = &str>
Sourcepub fn insert_dps(&mut self, name: impl Into<String>, data: DataArray)
pub fn insert_dps(&mut self, name: impl Into<String>, data: DataArray)
Insert (or replace) a DPS field. The data array’s row count must equal the current streamline count.
Sourcepub fn insert_dpv(&mut self, name: impl Into<String>, data: DataArray)
pub fn insert_dpv(&mut self, name: impl Into<String>, data: DataArray)
Insert (or replace) a DPV field. The data array’s row count must equal the current vertex count.
pub fn subset_streamlines(&self, indices: &[usize]) -> Result<Self>
Sourcepub fn push_streamline(&mut self, points: &[[f32; 3]]) -> Result<()>
pub fn push_streamline(&mut self, points: &[[f32; 3]]) -> Result<()>
Add a streamline to the tractogram.
Sourcepub fn nb_streamlines(&self) -> usize
pub fn nb_streamlines(&self) -> usize
Number of streamlines.
Sourcepub fn nb_vertices(&self) -> usize
pub fn nb_vertices(&self) -> usize
Number of vertices.
Sourcepub fn streamline(&self, index: usize) -> &[[f32; 3]]
pub fn streamline(&self, index: usize) -> &[[f32; 3]]
Borrow a single streamline as a position slice.
Sourcepub fn streamlines(&self) -> impl Iterator<Item = &[[f32; 3]]>
pub fn streamlines(&self) -> impl Iterator<Item = &[[f32; 3]]>
Iterate over streamlines.
Sourcepub fn to_trx(&self, dtype: DType) -> Result<AnyTrxFile>
pub fn to_trx(&self, dtype: DType) -> Result<AnyTrxFile>
Materialize a TRX file using the requested positions dtype.
Trait Implementations§
Source§impl Clone for Tractogram
impl Clone for Tractogram
Source§impl Debug for Tractogram
impl Debug for Tractogram
Source§impl Default for Tractogram
impl Default for Tractogram
Source§impl From<&AnyTrxFile> for Tractogram
impl From<&AnyTrxFile> for Tractogram
Source§fn from(value: &AnyTrxFile) -> Self
fn from(value: &AnyTrxFile) -> Self
Auto Trait Implementations§
impl Freeze for Tractogram
impl RefUnwindSafe for Tractogram
impl Send for Tractogram
impl Sync for Tractogram
impl Unpin for Tractogram
impl UnsafeUnpin for Tractogram
impl UnwindSafe for Tractogram
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.