Creating masked nifti from ROI

Software version: 3D Slicer 4.10.2

I would like to draw an ROI on a ACPC transformed dataset, then create a binary mask of that ROI whee everything inside has a value of 1 and zeroes outside, and to have the same dimensions as the original nifti T1 dataset i.e. possibly requiring an invert transform. So I can take this nifti mask out of 3D slicer and use it in our current mrtrix3 processing pipeline.

I’m having a few issues doing this and following previous similar threads and online tutorials have not managed to figure this out.

My workflow currently:

  • load in data & create models
  • perform ACPC transform to data
  • draw an ROI (that measures 4x4x6 mm3 in the ACPC transformed plane)

Then I get stuck. I have tried using the crop volume module and the mask scalar volume modules but I cannot seem to get what I am after.

Any help appreciated, many thanks,
Joely

You can draw ROI on an image using Segment Editor module (for example, using scissors or paint effects,or any of the automated tools), convert it to labelmap (by right-clicking on the segmentation in Data module), and save the labelmap as nifti.

If you want to draw an ROI with a specific shape and size then you can write a very simple scripted module, which takes markup points/lines as inputs to position a model node, then on the click of a button, it converts it to segmentation node, and then exports it as a labelmap. The module can also launch mrtrix3 processing and visualize the results in Slicer - all by a single click. The programming effort is probably a few hours for someone who is already familiar Slicer programming and maybe a few days for someone who is familiar with VTK, Python, and Qt but does not know anything about Slicer yet. See this tutorial to get started - and feel free to ask here if you have any questions.

Thank you for getting back to me !

I struggled to get it to work following the segmentation editor module. But I did figure out a way to do what I needed, so here it is if this helps future visitors:

I drew my ROI, in whichever way would work for you, as mine is based off of distances from landmarks and specific measurements (in mm) I found it easiest using the ‘Annotations’ module and using the ruler, fudicial and ROI tools.

Then to convert this to a model I used the ‘Markups to Model’ module.

This was possible as my ROI was a simple cuboid. I could locate the base slice, use the fudicial tool to mark out each corner of the ROI, scroll to the top slice of the ROI and draw fudicials on the 4 corners again.

Then I opened the ‘Data’ module, right clicked on the new ROI model and saved the model as a nii file.

Then checking the result in ImageJ I could see that even though I had performed an ACPC transform on the data in Slicer, it wasn’t ‘hardened’ and therefore the ROI was in the correct (original) space and I did not need to perform an invert transform.

Thanks for the tips on automation. This is something I will look into and go through the tutorial as this will really streamline my process.

Many thanks for the help,
Joely

2 Likes