trk-io
implements a TrackVis
(.trk) reader and writer.
Highlights
- Can read and write
TrackVis
files. Handles affine transformation asnibabel.streamlines
andMI-Brain
would. - Reading and writing is tested as much as in
nibabel.streamlines
. Reader
can read all streamlines at once or can be used as a generator. Handles endianness.- Write all at once or streamline per streamline.
- Follows
nibabel.streamlines
architecture (all 3D points are in a singleVec![Point3D]
). Currently, this is only useful for performance, but it may lead to easier changes when and if we support BLAS. - Handles endianness.
Examples
// Read complete streamlines to memory
let streamlines = new.read_all;
for streamline in &streamlines
// Simple read/write. Using a generator (read one streamline at a time)
let reader = new;
let mut writer = new;
for streamline in reader.into_iter
// The new file will be completed only at the end of the scope. The
// 'n_count' field is written in the destructor because we don't
// know how many streamlines the user will write.