trk-io   Latest Version Build Status dependency status

trk-io implements a TrackVis (.trk) reader and writer.

Highlights

Examples

rust // Read complete streamlines to memory let tractogram = Reader::new("bundle.trk").unwrap().read_all(); for streamline in &tractogram.streamlines { println!("Nb points: {}", streamline.len()); for point in streamline { println!("{}", point); } } rust // Simple read/write. Using a generator, so it will load only // one streamline in memory. let reader = Reader::new("full_brain.trk").unwrap(); let mut writer = Writer::new( "copy.trk", Some(reader.header.clone())); for tractogram_item in reader.into_iter() { // tractogram_item is a TractogramItem, which is a tuple of // (streamline, scalars, properties). writer.write(tractogram_item); } // 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.

Roadmap

There's still a lot of work to do but it should work perfectly for simple use cases. In particular, future versions should be able to:

Your help is much appreciated. Consider filing an issue in case something is missing for your use case to work. Pull requests are also welcome.