trk-io 0.6.3

TrackVis (*.trk) reader and writer
Documentation
extern crate docopt;
extern crate nifti;
extern crate trk_io;

use std::path::Path;
use std::str;

use docopt::Docopt;
use nifti::{InMemNiftiObject, NiftiObject};
use trk_io::affine::raw_affine_from_nifti;

static USAGE: &'static str = "
Print a Nifti (.nii | .nii.gz) header in a readable way

Usage:
  nifti_header <input> [options]
  nifti_header (-h | --help)
  nifti_header (-v | --version)

Options:
  -h --help     Show this screen.
  -v --version  Show version.
";

fn main() {
    let version = String::from(env!("CARGO_PKG_VERSION"));
    let args = Docopt::new(USAGE)
                      .and_then(|dopt| dopt.version(Some(version)).parse())
                      .unwrap_or_else(|e| e.exit());
    let input = Path::new(args.get_str("<input>"));
    if !input.exists() {
        panic!("Input trk '{:?}' doesn't exist.", input);
    }

    let nifti_object = InMemNiftiObject::from_file(input)
        .expect("The input file is unreadable.");
    let header = nifti_object.header();
    println!("{:?}", header);
    let affine = raw_affine_from_nifti(header);
    println!("tranform{}", affine);
    println!("inversed tranform{}", affine.try_inverse().unwrap());
}