DICOM to Nifti

Table of contents

  1. Converting T1 Scans from DICOM to NIFTI
  2. Automating Conversion to Nifti

DICOM is a useful format, but some of our downstream processing require the images to be in the NIfTI (Neuroimaging Informatics Technology Initiative) format. Nifti tends to be easier to work with during processing and analysis, in part because it strips away a lot of the metadata stored in DICOM that is not needed to do the processing. We’ll leverage the XNAT Container Service to convert our DICOMs to NIfTIs on the XNAT itself without having write our own processing pipelines.

Your objectives here:

  • Use the XNAT Container Service to convert your DICOM images to Nifti.
  • Automate conversion of DICOM to Nifti using the XNAT Event Service

Converting T1 Scans from DICOM to NIFTI

A simple bit of processing that we could make available to users is the ability to convert from DICOM to NIfTI. Instead of writing our own tool to do this from scratch we can leverage the fact that the well supported dcm2niix tool exists already. It has also already been dockerised and made XNAT compatible.

This means that it can easily be installed for use on the XNAT without needing to do any coding or configuration. We’ve done so on the XNAT, and it can be run from any scan.

We will need our T1 scans in NIfTI format for some future processing steps, so go ahead and run it on one of the T1 scans in a session now:

  1. Go to your project
  2. Go to “Project Settings” in the “Actions” menu
  3. Go to “Container Service -> Configure Commands”
  4. Enable the “Run dcm2niix on a Scan” command
  5. Go to an imaging session in your project
  6. Using the “Run” on the right hand side, convert any T1 scans
  7. You can monitor the processing from the “History” panel at the bottom of the imaging session page.
  8. Once complete, a Nifti Resource will be created at the scan level.

Automating Conversion to Nifti

It would be tedious, not to mention error prone, to do this by hand for each scan. Instead we can automate this action using the Event Service. To enable this:

  1. Ensure that the dcm2niix container is enabled in your project as per the previous instructions
  2. Select the “Event Service” in the “Actions” menu of your project
  3. Click “Add New Event Subscription” to create a new event subscription
  4. In the “Event Subscription Label”, enter “Dicom 2 Nifti”.
  5. Select “Scan Created” as the “Event”, then select “dcm2niix” as the “Action”
  6. In the “Event Payload Filter” enter @.scan-type=~ /(t1)/i to only select T1 scans.
  7. Enable the subscription and click OK

This will run dcm2niix on all scans in your project as they are archived. To test this, you’ll have to delete your data and re-upload it. (To speed things up, you could remove just the T1 scans, and re-upload only those.)

You can now upload the entire dataset, run it through your de-identification and once your T1 scans are archived into your project the Event Service will automatically run dcm2niix on them and generate the NIfTI resources.

With the metadata removed from the DICOM headers, and the prerequisite NIfTIs generated for the T1 scans, we can now use the data for our downstream analysis and other tasks.