Selecting volumes in a .mif 4D image?

Hi all,

basically I would like to select certain volumes out of a 4D mif.

Given a 4D mif, e.g. dMRI data with 70 directions, I would like to exclude one (or more) direction(s).

I wanted to use mrcrop & mrcat for this. To exclude direction “d”, I would crop the 4D mif from 1:d-1 and once more from d+1:end, and then cat them together.

However, mrcrop only works on the x,y,z of the 4D datastack, and not on 4th dimension? See:

Treanus-MBP:DICOM_DTI stefan$ mrcrop -axis 3 1 150 ./DTI_mif/S_002_016_orig.mif ./DTI_mif/S_002_016.mif
mrcrop: [ERROR] value supplied for option “axis” is out of bounds (valid range: 0 to 2, value supplied: 3)

There’s probably a simple mrtrix command for this?

Thx in advance,

Stefan.

Try mrconvert with the -coord option:

mrconvert in.mif -coord 3 150 out.mif

Couple that with number sequences if you need to select a subset:

mrconvert in.mif -coord 3 4,12,30:40 out.mif
1 Like

I was also facing similar problem a while ago. The hassle was to create sequence of indices I want to retain from the sequence of indices I want to exclude. I would appreciate that mrconvert could accept explicit indices which I want to exclude (like e.g. in R where negative value of indices can be specified to exclude specific index).

Thank you Donald,

exactly what I needed.

I had looked at the man page of mrconvert/mrcrop (and webpage) but could not figure out the correct syntax. (And if mrconvert accepted 4D axes definition unlike mrcrop).

I understand this may clutter the man page and webpage(s), but I advocate to add more explanation, details, examples to them.
Also, one should be aware that mrtrix (as fsl) starts counting (4D volumes) from 0 (not 1), thus in my case: mrconvert DTI_mif/S_002_016_orig.mif -coord 3 0:149 DTI_mif/test.mif -force (to get rid of the last volume; if one uses 1:150, the first volume is discarded). I know, it’s a hassle to keep everything up to date and fully documented. If I can help, let me know…

Greatly appreciating your - awesome - fast response (and of the mrtrix community)…

Thx, S.

I understand this may clutter the man page and webpage(s), but I advocate to add more explanation, details, examples to them.

This is one area where users can most definitely contribute. Additional documentation is more likely to be actually useful to users if it addresses those misunderstandings or absent information encountered by other users; if we simply bloat the documentation based on our narrow-minded developer brains, the extra information may not actually be relevant to what users need.

One little tweak I made recently was to define separate “Synopsis” and “Description” fields for each command. The “Synopsis” is a one-sentence description of the command that appears right at the top of the help page, whereas “Description” can contain any number of paragraphs giving additional details; so the latter is ideal for providing extra information that may be useful to some users, but can also easily be “skipped over” when examining the help pages. Moreover, information that is relevant to multiple commands can be defined in a single location, and repeated verbatim in the help pages of those commands; this might be appropriate for explaining the zero-based numbering in relevant commands, for instance.