How to crop nifti files


(Richard Joaquin Ortiz) #1

I know this may be a simple solution, but how does one crop a nifti file of a brain? I am trying to remove the skull and I’ve been stuck at this issue for quite some time. I have used segmentation wizard (or segmentation) module to highlight the regions I don’t want cropped, but cannot seem to figure out what module to use to actually cropt the rest out. I really appreciate all of the help!

(Murat Maga) #2

If you already done the segmentations of the regions that you want to remove, install the Segment Editor Extra Effects extension and use mask volume function to save a version of your volume with just the brain. Then you can use the Crop Volume if you still want to remove the empty background.

(Andras Lasso) #3

If you need to remove the skull from MRI images, then you can use SwissSkullStripper extension. It removes the skull from the image completely automatically.

(Richard Joaquin Ortiz) #4

I forgot to mention that I am using rodent images, and SwissSkullStripper is probably human-based, correct?

(Richard Joaquin Ortiz) #5

Will the outcome of this process still be in nifti? Your method was great for cropping out the desired stuff, but I cannot seem to save it back as a nifti file again.

(Andras Lasso) #6

The skull stripper should work for any species, just provide your own template (a single image volume and a corresponding brain segmentation).

The result can be save in many formats, including nifti (you can choose file format in the save dialog).

(Murat Maga) #7

You can save the masked volume in any format slicer supports (including Nifti). Just use the save as dialog box.

(Richard Joaquin Ortiz) #8


These files are multi-volume nifti and I am attaching a dropbox link of an example of my data.

So far, my steps include

1- MultiVolume Importer–>Select folder where .nii file in–>output node–>create new MRML MultiVolume–>click Import (Output node becomes a 200 frames NIfTI MultiVolume)
2. MultiVolume Explorer Module–>select input multivolume as 200 frames NIfTI MultiVolume (can click play)
3. Segment editor module w/ segment editor extra effects add-on installed–>segment portion I want
4. Mask Volume (within segment editor)–>save new dataset with only segmented region
5. Crop volume module–>apply (I am able to visualize the masked, cropped image exclusively.

The problem occurs because I cannot save the masked cropped image into a .nii file, as the only options are .nrrd or .nhdr format.

(Andrey Fedorov) #9

If you need to export multivolume as a .nii file, that functionality is not available. You can only save multivolumes as .nhdr/.nrrd.