How to convert freesurfer results to DICOM-SEG or DICOM-RT?

I would like to export the result (.mgz) of freesurfer to dicom-seg or dicom-RT.

What I’ve done so far is

(A) open mgz in the segmentation editor module, export it as the nifti format. But, all the segmentation labels have been messed up.

(B) open the mgz file, add the new study, export as DICOM and DICOM-RT. But I received the following error message

Segmentation object export failed.
‘None Type’ object has no attribute ‘GetAttribute’


DICOM RT structure set can only store simple contours, not such complex segmentations as a FreeSurfer brain segmentation.

DICOM Segmentation Object can store arbitrarily complex segmentation. However, it requires you to refer to a reference image and that reference image must have UIDs for each frame.

If you don’t have the input DICOM image anymore then you can create a dummy image by the following steps:

  • export the segmentation to a labelmap volume
  • convert the labelmap volume to scalar volume (using Volumes module → Volume Information → Convert to scalar volume)
  • export the volume to DICOM using scalar volume exporter (UIDs are generated during export), and loading that exported image
  • load the image from the DICOM database

We could certainly make things simpler by automatically generating dummy volumes, but since segmentation has limited use without a real referenced volume, there has not been many requests for this.

Nifti file format cannot store segment names in the file, therefore you need to use an external colormap file. If you use freesurfer then you can load the segmentation as a volume, then in Volumes module choose the freesurfer colormap, and then convert it to segmentation.

1 Like