C or C++ routine to read *.mif

Hi MRTrix Fans,

is there a C or C++ routine to read and write MRTrix format? I guess …yes :slight_smile: !
Is it in the formats folder and an extra file like the nifti analyze and dicom stuff?

The background is that we have a small tool in VTK and C to make a small histogram analyze and would like to read in the *.mif files.

Thanks,

Ralf

The code handling the mif format is in the lib/formats/mrtrix_utils.h and corresponding cpp file, along with the lib/formats/mrtrix.cpp and lib/formats/mrtrix_gz.cpp files that make use of that functionality for *.mif/mih and *.mif.gz respectively. The format itself is documented here for reference. Hope that’s enough for you to get started…?

Just a word of warning though: it’ll probably be very difficult to extract the functionality from that file, given how tightly embedded it is within the whole MRtrix3 backend. My guess is you’ll need to copy the bits you need and modify them extensively to get them to work outside of MRtrix3

The background is that we have a small tool in VTK and C to make a small histogram analyze and would like to read in the *.mif files.

The other option is to skip the .mif handling and generate the histogram using MRtrix3 instead? Currently that’s handled using mrstats -histogram; in the coming update there’s a new command mrhistogram that comes with a couple of additional options, and will also by default use a better heuristic for calculating an appropriate number of bins for the histogram.

You could of course also mrconvert them first to NIfTI; I’m pretty sure VTK can handle those…?

Thanks for the answers,

I try all of them. We will see whats happens. :slight_smile:

Thanks,

Ill keep you up to date.

Ralf