Container service: launch container on ROI Collection

82 views
Skip to first unread message

dr.ka...@gmail.com

unread,
Nov 22, 2021, 2:33:42 PM11/22/21
to xnat_discussion
I'm trying to set up a container command that operates on the DICOM segmentation file associated with an ROI Collection object, created when a mask is exported with the OHIF plugin. When run manually, the container is run with:

docker run MY_IMAGE:TAG -p <XNAT-PROJECT-ID> </PATH/TO/DICOM-SEG.dcm>

My command.json is loaded successfully, but I'm not seeing an option to run the container in the Action Box when viewing an ROI Collection. Am I setting up my command correctly, both to:

1. get it to appear in the icr:roiCollectionData context, and
2. correctly parse the project-id and dicom segmentation file path?

I need the command to run on the "SEG_***.dcm" file, in the ROI Collection's files:

(base) SESSION [11:26:41]$ tree ASSESSORS/
ASSESSORS/
├── SEG_20211028_121740_525
│   └── SEG
│       ├── SEG_20211028_121740_525.dcm
│       └── SEG_catalog.xml

(command.json below)

Thanks for the help,
James

{
    "name": "i2c2-xnat-volume-calculator",
    "description": "Calculate and upload volume of dicom segmentation object.",
    "version": "1.0",
    "schema-version": "1.0",
    "image": "MYREGISTRY/i2c2-xnat-volume-calculator:v1.0",
    "type": "docker",
    "override-entrypoint": false,
    "command-line": "[PROJECT_ID] /segmentation/[DICOM_SEG_FILE_NAME]",
    "mounts": [
        {
            "name": "segmentation-in",
            "writable": "false",
            "path": "/segmentation"
        }
    ],
    "inputs": [
        {
            "name": "dicom-seg-file-name",
            "description": "DICOM segmentation file to process",
            "type": "string",
            "required": true,
            "replacement-key": "[DICOM_SEG_FILE_NAME]"
        },
        {
            "name": "project-id",
            "description": "Project ID to export results to",
            "type": "string",
            "required": true,
            "replacement-key": "[PROJECT_ID]",
            "command-line-flag": "-p"
        }
    ],
    "outputs": [
    ],
    "xnat": [
        {
            "name": "calculate-segmentation-volume",
            "description": "Calculates and uploads the ROI volume/s from a dicom segmentation object.",
            "contexts": ["icr:roiCollectionData"],
            "external-inputs": [
                {
                    "name": "segmentation",
                    "type": "Assessor",
                    "required": true,
                    "matcher": "'SEG' in @.resources[*].label",
                    "load-children": true
                }
            ],
            "derived-inputs": [
                {
                    "name": "session",
                    "type": "Session",
                    "derived-from-wrapper-input": "segmentation",
                    "required": true,
                    "load-children": true
                },
                {
                    "name": "project",
                    "type": "string",
                    "derived-from-wrapper-input": "session",
                    "derived-from-xnat-object-property": "project-id",
                    "provides-value-for-command-input": "project-id"
                },
                {
                    "name": "segmentation-dicom",
                    "type": "Resource",
                    "derived-from-wrapper-input": "segmentation",
                    "matcher": "@.label == 'SEG'",
                    "provides-files-for-command-mount": "dicom-in"
                },
                {
                    "name": "segmentation-dicom-file",
                    "type": "File",
                    "derived-from-wrapper-input": "segmentation-dicom"
                },
                {
                    "name": "segmentation-dicom-file-name",
                    "type": "string",
                    "derived-from-wrapper-input": "segmentation-dicom-file",
                    "derived-from-xnat-object-property": "name",
                    "provides-value-for-command-input": "dicom-seg-file-name",
                }
            ],
            "output-handlers": [
            ]
        }
    ]
}

Moore, Charlie

unread,
Nov 22, 2021, 3:27:12 PM11/22/21
to xnat_di...@googlegroups.com
Hi James,

I had to make a change to your command.json to get it imported in my XNAT. This line has a trailing comma that some JSON parsers won't accept:
                    "provides-value-for-command-input": "dicom-seg-file-name",


After changing that though, I could see your command on an ROI collection in my XNAT. To double check, did you do the following?
  1. From Administer > Plugin Settings > Command Configurations, have you enabled your command?
  2. After doing (1), have you enabled the command in the project that owns your ROI collection? That's done from (project report page) > Project Settings > Configure Commands.
Thanks,
Charlie

From: xnat_di...@googlegroups.com <xnat_di...@googlegroups.com> on behalf of dr.ka...@gmail.com <dr.ka...@gmail.com>
Sent: Monday, November 22, 2021 1:33 PM
To: xnat_discussion <xnat_di...@googlegroups.com>
Subject: [XNAT Discussion] Container service: launch container on ROI Collection
 

* External Email - Caution *

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/7c88e531-d439-4533-8918-30d62565e538n%40googlegroups.com.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

dr.ka...@gmail.com

unread,
Nov 22, 2021, 4:00:05 PM11/22/21
to xnat_discussion
It was step number 2, enabling the command in the project, that did it. I must have glossed over this in the documentation. Thanks for the quick response!

dr.ka...@gmail.com

unread,
Nov 22, 2021, 5:04:30 PM11/22/21
to xnat_discussion
Is there a way to auto-launch a container on the saving of an Assessor? I can see in "project settings" -> "command automation" that the available events are on scan/session archiving. 

kel...@wustl.edu

unread,
Nov 22, 2021, 5:11:05 PM11/22/21
to xnat_discussion
Hi James,
Yes! Assuming you are using XNAT 1.8.3 and Container Service 3.1, you can use the Event Service to automate the launching of your container. See Using the Event Service for Details and Enabling Automated Commands via the Event Service for details.

One small update to your command would be needed for this to work: 


 "external-inputs": [
                {
                    "name": "segmentation",
                    "type": "Assessor",
                    "required": true,
                    "matcher": "'SEG' in @.resources[*].label",
                    "load-children": true
                }

will need to be:

 "external-inputs": [
                {
                    "name": "assessor",
                    "type": "Assessor",
                    "required": true,
                    "matcher": "'SEG' in @.resources[*].label",
                    "load-children": true
                }


Best,
Matt

James Hawkins

unread,
Nov 22, 2021, 6:08:08 PM11/22/21
to xnat_di...@googlegroups.com
Worked like a charm, using the JSONPath filter (@.xsiType == "icr:roiCollectionData" && @.resources.length() > 0 && "SEG" in @.resources[*].label). Thanks again!

You received this message because you are subscribed to a topic in the Google Groups "xnat_discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xnat_discussion/X3ci7L4-8JA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xnat_discussi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xnat_discussion/74540462-4124-45a5-8688-ef0bf5bd88fen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages