Set up an Automated Workflow to Generate Required Model Resources
Note: This functionality uses pre-released Event Service capability in core XNAT.
XNAT can be configured to automatically run a workflow that generates resources needed by a model, triggered by the importing of ROI contours into a session. This workflow can only be configured on a single model in a project. If there are multiple models associated with this project, you must choose which one will have automatic processing enabled. These resources will be generated:
- The appropriate scan has one NIFTI file that contains the original pixel data, resampled to voxel size required by the model.
- The appropriate scan has a NIFTI file containing mask data, sampled at the voxel size of the original DICOM data. The mask will have each region-type appropriately labeled.
- The appropriate scan has a version of the original NIFTI mask file resampled to match voxel dimensions expected by the model.
This step requires detailed knowledge of the inputs for the model you have chosen. Examples of input requirements are:
- Which model is chosen, if there are multiple models on the project.
- The model has a region-to-mask-value file attached to the model.
- The voxel dimensions of the resampled data.
Add event subscription (Composite Mask Generation)
The OHIF Viewer is used to create labeled contours that are imported to XNAT as session-level image assessors in DICOM RTSTRUCT format. However, machine-learning models typically want the segmented regjons in NIFTI format. The RTSTRUCT contours are automatically converted into scan-level resources in NIFTI format by the Container Service Command named "rtstruct2nii-composite-assessor". To configure this automatic conversion for a Model in the Project, perform the following using an administrator account.
- Select "Administer → Event Service"
- Select "Event Subscriptions" in the left-hand sidebar.
- Click "Add New Event Subscription" to open the dialog.
- Enter an "Event Subscription Label". Choose something like "RTStruct to Composite Mask - <project-name>" where <project-name> is the name of your project.
- Event subscriptions can only be made for all projects or specific projects.
- One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
- Thus it is best practice to include the project name in the label since this action type may need to be created for multiple projects.
- Select Event Image Assessor Event – Updated.
- Select the project in the drop-down list.
- Select Action rtstruct2nii-composite-mask
- Click on "Set Attributes" This will open a dialog box with a text field labeled "project-asset".
- Enter the XNAT ID of the project's model to be used. It will be a string like "XNAT13_E00005". See "Install Pre-Trained Model" for steps on how to find this value.
- Click "OK".
- Enter the XNAT ID of the project's model to be used. It will be a string like "XNAT13_E00005". See "Install Pre-Trained Model" for steps on how to find this value.
- Enter (@.xsiType == 'icr:roiCollectionData' && 'RTSTRUCT' in @.resources[*].label && 'DICOM' in @.resources[?(@.label == 'RTSTRUCT')].files[*].format) for Event Payload Filter, with the parens.
- Perform Action As: Action is performed as the user who initiates the event
- Set Status to Enabled
- Click "OK".
NIFTI-formatted composite-mask images will now be created for scans automatically when ROI Contours are imported from the Viewer into the specified project.
Add event subscription (Resampled Mask)
- Select "Administer → Event Service"
- Select "Event Subscriptions" in the left-hand sidebar.
- Click "Add New Event Subscription" to open the dialog.
- Enter an "Event Subscription Label". Choose something like "Resample NIFTI Mask - <project-name>" where <project-name> is the name of your project.
- Event subscriptions can only be made for all projects or specific projects.
- One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
- Thus it is best practice to include the project name in the label since this action type may need to be created for multiple projects.
- Select Event Resource Event – Created.
- Select the project in the drop-down list.
- Select Action nvmdl-dataconvert-mask-resource-trigger
- Click on "Set Attributes" This will open a dialog box.
- Enter the XNAT ID of the project's model to be used. It will be a string like "XNAT13_E00005". See "Install Pre-Trained Model" for steps on how to find this value.
- Enter the output-resolution of the resampling needed for the model. Enter the output-resolution. Units are in millimeters. Values may be integer or float, e.g. 1 or 1.5. All three dimensions are the same if a single value is specified. Specify x,y,z values independently by separating them with a space, e.g "1.0 1.0 1.5".
- Leave the default nifti-filename "resampled_mask".
- Click "OK".
Enter the following Payload Filter, with the parens:
CODE(@.xsiType == 'xnat:resourceCatalog' && @.label == 'MASK')
- Perform Action As: Action is performed as the user who initiates the event
- Set Status to Enabled.
- Click "OK".
Add event subscription (Resampled DICOM)
- Select "Administer → Event Service"
- Select "Event Subscriptions" in the left-hand sidebar.
- Click "Add New Event Subscription" to open the dialog.
- Enter an "Event Subscription Label". Choose something like "Resample DICOM Scan - <project-name>" where <project-name> is the name of your project.
- Event subscriptions can only be made for all projects or specific projects.
- One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
- Thus it is best practice to include the project name in the label since this action type may need to be created for multiple projects.
- Select Event Resource Event – Created
- Select the project in the drop-down list.
- Select Action nvmdl-dataconvert-scan-resource-trigger
- Click on "Set Attributes" This will open a dialog box.
- Enter the XNAT ID of the project's model to be used. It will be a string like "XNAT13_E00005". See "Install Pre-Trained Model" for steps on how to find this value.
- Enter the output-resolution of the resampling needed for the model. Enter the output-resolution. Units are in millimeters. Values may be integer or float, e.g. 1 or 1.5. All three dimensions are the same if a single value is specified. Specify x,y,z values independently by separating them with a space, e.g "1.0 1.0 1.5".
- Leave the default nifti-filename "resampled".
- Click "OK".
Enter the following Event Payload Filter, with the parens:
CODE(@.xsiType == 'xnat:resourceCatalog' && @.label == 'MASK')
- Perform Action As: Action is performed as the user who initiates the event
- Set Status to Enabled
- Click "OK".