I know this should be really easy to do, but for some reason, I’m struggling to convert my pre-processed data from .mif to .mat format.
I tried to use mrconvert to change from .mif to .nii first.
However, it doesn’t seem to save it correctly (not sure if that’s the issue. I am running: mrconvert data.mif data.nii -stride -2,3,4,1 (note the when I try to run “strides” as in the documentation it gives me the error: mrconvert: [ERROR] unknown option “-strides”. The .nii file, however, is still saved as -1 2 3 4. Do you know why that is and if that might be the issue?
When I then run mri_convert data.nii data.mat I get the following error:
$Id: mri_convert.c,v 1.226 2016/02/26 16:15:24 mreuter Exp $
reading from data.nii…
TR=1000.00, TE=0.00, TI=0.00, flip angle=0.00
i_ras = (-0.999879, 0, -0.0155339)
j_ras = (-0.00161745, 0.994521, 0.104527)
k_ras = (-0.0154488, -0.104539, 0.994401)
writing to data.mat…
MRIwriteType(data.mat): image files cannnot have depth > 1
No such file or directory
Is there a way to directly convert .mif to .mat format or do you know why it isn’t’ working?
Ok, first thing is I’m not sure what this .mat format is. Is that MATLAB storage format?
The -stride option was recently changed to -strides, but it is the same as before. You might be running a slightly older version.
Otherwise, the reason your NIfTI data don’t end up with the strides you specified is that NIfTI doesn’t support them*. So MRtrix3 transparently substitutes the nearest feasible strides. This should not have major adverse consequences: at worst, (slightly) reduced performance in downstream applications.
*It might support vector-valued data, but I have a feeling it’s not a widely-used feature.
I’m guessing this means mri_convert only supports writing 3D volumes for the .mat format. But that’s just a hunch, I’ve no experience with this (and like I mentioned above, I’m not even sure what the .mat format actually is…).
By the way, on the off-chance you’re trying to load your data into MATLAB, note there are MATLAB functions to do just that for the .mif format in the matlab/ folder of your MRtrix3 installation.
The read and write mrtrix functions in the matlab folder are exactly what I was after. I was worried I’d lose information or mess is up if I convert .mif to nifti and then into matlab, so this is perfect. Thank you!