Creating cuboid ROI with arbitrary orientation

Dear experts,

I am searching for a simple way how to calculate some statistics from the image using cuboid ROI with arbitrary size and orientation (MR spectroscopic voxel measured in the same session, arbitrary positioned and rotated).

It is possible to define arbitrary ROI (for example using position of the corner, row, col vectors and size along each dimension) using current mrtrix tools?

Thank you in advance.

Hey Antonin,

This is not currently possible, but is precisely the sort of functionality that I would expect to go into the mredit command. Currently this command has only limited options, as I only put enough effort into it to support the functionality that I myself needed at the time. But for editing image values based on command-line input of geometry, this is where the capability belongs. I would therefore suggest creating a GitHub issue for the feature request, describing the requirements as accurately as you can.

Cheers
Rob

Well, there is a slightly awkward solution that might do the trick. The idea would be to create a single-voxel image using the *.mih format (the one with the standalone text-only header so you can edit it yourself), then use mrtransform to regrid that to your target space.

So the header would look like this:

mrtrix image
dim: 1,1,1        # single voxel
vox: 10,20,30     # whatever the actual size of the ROI is, in mm.
layout: +0,+1,+2
datatype: UInt8
transform: 0.999171, 0.0407114, 0.000431757, 0.2342
transform: -0.0407124, 0.999167, 0.00267015, 1.2342    
transform: -0.000322792, -0.00268555, 0.999996, -9.577
file: ROI.dat

And what you need to worry about is the vox entry (that’ll set the size of the ROI), and the transform, which sets the direction vectors (first 3 columns) and position of the centre of the ROI (4th column). Note the direction vectors need to be unit normalised and orthogonal.

You can generate the data file with a command like this (make sure the name matches what’s in the header, under the file: entry):

$ printf '\001' > ROI.dat

That should already give you an image that you can display in MRView using the ROI editor, e.g.:

$ mrview yourimage.mif -roi.load ROI.mih

At this point, you can simply regrid onto your target space:

$ mrtransform ROI.mih -template yourimage.mif ROI_regrid.mif

Not sure that’ll meet your needs, but to be honest I don’t think we could make it all that much simpler - the hard part is getting the transform right, and specifying it is always going to be somewhat awkward…

2 Likes