run dcm2niix on a session

318 views
Skip to first unread message

Daniel Drucker

unread,
Sep 23, 2021, 9:58:22 AM9/23/21
to xnat_discussion
Another container question, as I'm still having trouble wrapping my head around the json.

I have https://github.com/NrgXnat/docker-images/tree/master/dcm2niix working, which provides a container command to run dcm2niix on a scan.

I'd like the same thing, but at the session level instead. How would I go about doing that?

Daniel

kel...@wustl.edu

unread,
Sep 23, 2021, 11:16:15 AM9/23/21
to xnat_discussion
Hi Daniel,
Do you want to run dcm2niix on one of the scans under a session or all of the scans? 

Assuming that you want to run your dcm2niix container at the session level, but process only one of the underlying scans, you can modify the context, external-input, and derived-inputs from:

            "contexts": ["xnat:imageScanData"],
            "external-inputs": [
                {
                    "name": "scan",
                    "description": "Input scan",
                    "type": "Scan",
                    "required": true,
                    "matcher": "'DICOM' in @.resources[*].label"
                }
            ],
            "derived-inputs": [
                {


to

            "contexts": ["xnat:imageSessionData"],
            "external-inputs": [
                {
                    "name": "session",
                    "description": "Input session",
                    "type": "Session",
                    "required": true,
                    "matcher": "'DICOM' in @.scans[*].resources[*].label"
                }
            ],
            "derived-inputs": [
                {
                    "name": "scan",
                    "description": "Input scan",
                    "type": "Scan",
                    "derived-from-wrapper-input": "session",
                    "required": true,
                    "matcher": "'DICOM' in @.resources[*].label"


This tells XNAT to look for an "xnat:imageSessionData" datatype, resolve the Session that matches the JSONPath filter: "'DICOM' in @.scans[*].resources[*].label" and derive a child scan element that matches  "'DICOM' in @.resources[*].label".  If there are multiple scans under the session that match the 'DICOM' in @.resources[*].label  filter (i.e. contain DICOM resources), the UI will prompt your user to select one of those scans.

See attached for the full command JSON.

Best,
Matt
dcm2niix-session.json

Daniel Drucker

unread,
Sep 23, 2021, 11:24:27 AM9/23/21
to xnat_discussion
Maybe I'm missing something important here. To me, the sensible thing to want to do at the MR Session level is run a command which converts all the dicoms in that session to nifti, so the user can download all the niftis instead of all the dicoms.

I can't actually imagine what the purpose of converting only a single dicom at a time would be.

kel...@wustl.edu

unread,
Sep 23, 2021, 12:13:50 PM9/23/21
to xnat_discussion
Hi Daniel,

You can certainly do that, but the base "xnat/dcm2niix" container is designed to convert one DICOM scan and return one NIFTI output. This design is based on knowing the output context at container launch, i.e. XNAT needs to know under which scan to store the output resource (NIFTI, in this case). 

If you want to run this conversion across all scans in a session, you might use the Bulk Action (which operates across scans in a session):

Screen Shot 2021-09-23 at 10.54.17 AM.png
Screen Shot 2021-09-23 at 10.56.06 AM.png


If you want to run this operation across all scans in your project, you might use functionality in the Batch Launch plugin to run processing at the scan level. Note that you will need to have the appropriate Scan Level datatype enabled.

Screen Shot 2021-09-23 at 11.01.14 AM.png


Screen Shot 2021-09-23 at 11.02.00 AM.png


Both of these methods will still run one container for each scan, but support launching multiple jobs in parallel.

If you'd rather run a single container to process multiple DICOM scans, you would need some custom scripting in the container to process multiple DICOM folders and direct the corresponding NIFTI output to the appropriate place in XNAT (via REST API).

Daniel Drucker

unread,
Sep 23, 2021, 3:48:29 PM9/23/21
to xnat_discussion
Thanks. I'll look into the Batch Launch thing!
Reply all
Reply to author
Forward
0 new messages