Skip to main content
Skip table of contents

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.

  1. Select "Administer → Event Service"
  2. Select "Event Subscriptions" in the left-hand sidebar.
  3. Click "Add New Event Subscription" to open the dialog.
  4. Enter an "Event Subscription Label".  Choose something like "RTStruct to Composite Mask - <project-name>" where <project-name> is the name of your project.
    1. Event subscriptions can only be made for all projects or specific projects.
    2. One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
    3. 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.
  5. Select Event Image Assessor Event – Updated.
  6. Select the project in the drop-down list.
  7. Select Action rtstruct2nii-composite-mask
  8. Click on "Set Attributes" This will open a dialog box with a text field labeled "project-asset".
    1. 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.
    2. Click "OK".
  9. Enter (@.xsiType == 'icr:roiCollectionData' && 'RTSTRUCT' in @.resources[*].label && 'DICOM' in @.resources[?(@.label == 'RTSTRUCT')].files[*].format) for Event Payload Filter, with the parens.
  10. Perform Action As:  Action is performed as the user who initiates the event
  11. Set Status to Enabled
  12. 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)

  1. Select "Administer → Event Service"
  2. Select "Event Subscriptions" in the left-hand sidebar.
  3. Click "Add New Event Subscription" to open the dialog.
  4. Enter an "Event Subscription Label".  Choose something like "Resample NIFTI Mask - <project-name>" where <project-name> is the name of your project.
    1. Event subscriptions can only be made for all projects or specific projects.
    2. One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
    3. 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.
  5. Select Event Resource Event – Created.
  6. Select the project in the drop-down list.
  7. Select Action nvmdl-dataconvert-mask-resource-trigger
  8. Click on "Set Attributes" This will open a dialog box.
    1. 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.
    2. 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".
    3. Leave the default nifti-filename "resampled_mask".
    4. Click "OK".
  9. Enter the following Payload Filter, with the parens:

    CODE
    (@.xsiType == 'xnat:resourceCatalog' && @.label == 'MASK')
  10. Perform Action As:  Action is performed as the user who initiates the event
  11. Set Status to Enabled.
  12. Click "OK". 

Add event subscription (Resampled DICOM)

  1. Select "Administer → Event Service"
  2. Select "Event Subscriptions" in the left-hand sidebar.
  3. Click "Add New Event Subscription" to open the dialog.
  4. Enter an "Event Subscription Label".  Choose something like "Resample DICOM Scan - <project-name>" where <project-name> is the name of your project.
    1. Event subscriptions can only be made for all projects or specific projects.
    2. One would not select "All Projects" as it is unlikely you want to perform this step for all projects in your site.
    3. 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.
  5. Select Event Resource Event – Created
  6. Select the project in the drop-down list.
  7. Select Action nvmdl-dataconvert-scan-resource-trigger
  8. Click on "Set Attributes" This will open a dialog box.
    1. 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.
    2. 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".
    3. Leave the default nifti-filename "resampled".
    4. Click "OK".
  9. Enter the following Event Payload Filter, with the parens:

    CODE
    (@.xsiType == 'xnat:resourceCatalog' && @.label == 'MASK')
  10. Perform Action As:  Action is performed as the user who initiates the event
  11. Set Status to Enabled
  12. Click "OK". 
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.