Step 3 of 8: Configure DICOM project routing
In this step, you will be creating a DICOM metadata parsing rule and saving it to your XNAT, to set up a stable project routing workflow.
The manual method of using Patient Comments for routing is great in a pinch, but that's not usually how data comes from the scanner. A lot of times, there is a way to extract the project id or alias from a DICOM field. XNAT supports this scenario by allowing you to use a regular expression to parse out your project id or alias from a DICOM tag. You can put this information to a configuration setting with the REST path /data/config/dicom/projectRules, and XNAT will use the information to attempt project routing if no routing was discovered in the first four passes as described in the previous section.
Let's go ahead and close and reopen DICOM Browser to clear out the tags from the previous exercise. Launch Dicom Browser again, then go to File, Open and open the files marked ##<filepath>##
Click on the session folder in the left panel to show the DICOM tags in the main part of the window. If you look closely, you'll see that one of our project aliases is embedded in the Study Description (0008,1030): XNAT^XNAT-2016.
It's not an exact match (because of the way Siemens scanners annotate protocols in the DICOM), however we can use a Regular Expression to match what we need. We need to extract just the "XNAT-2016" portion of the string. If you are sick enough to love writing regular expressions yourself, then we won't spoil it for you (it's using Java to do that pattern matching). Otherwise, please go here to get one version of an expression that will work.
To test that your regular expression is getting what you want, you can go here: Java Visual Regex Tester
Target text: XNAT^XNAT-2016
Regular expression: your expression here
You should find that when you enter these, that XNAT^XNAT-2016 appears below, with only the XNAT-2016 portion underlined.
Now that we have our tag and the regular expression to parse our project alias, we just need to PUT this projectRules configuration setting to XNAT. Go back to your vagrant ssh command prompt used in the Part 1 of this practical.
This expression is a configuration setting available through the XNAT REST API. XnatDataClient or curl are two reliable ways to interact with that API. Put the regular expression to your XNAT with either of the following commands:
With XDC
$ XnatDataClient -u admin -p admin -d "(0008,1030):(?:[^\^]+)\^((?:[a-zA-Z\d]+)[_\-](?:\d+))(.*?)" -m PUT --header "Content-Type: text/plain" -r "http://xnat-12.xnat.org/data/config/dicom/projectRules"
With curl
$ curl -u admin:admin -d '(0008,1030):(?:[^\^]+)\^((?:[a-zA-Z\d]+)[_\-](?:\d+))(.*?)' -X PUT -H 'Content-Type: text/plain' http://xnat-12.xnat.org/data/config/dicom/projectRules
Now, verify that the config has been successfully updated with either of these commands:
With XDC
$ XnatDataClient -u admin -p admin -m GET -r "http://xnat-12.xnat.org/data/config/dicom/projectRules"
With curl
$ curl -u admin:admin -X GET http://xnat-12.xnat.org/data/config/dicom/projectRules
Restart tomcat7:
$ sudo service tomcat7 restart
Let's send the DICOM to our XNAT:
- Close and relaunch Dicom Browser (otherwise having multiple sessions open gets a little complicated)
- Select File -> Open.
- Navigate to $YOURDIR/IGT_PROSTATE/case124 for your sample data and click "Open".
- Select File -> Send.
Remote host: xnat-12.xnat.org
Port: 8104
Remote AETitle: XNAT
Local AE Title: Anything you choose
Click Send.
Check the prearchive again. If Project = XNAT_2016, then you've done it correctly! Click the checkbox next to the session, then click the "Rebuild" button. Confirm, and refresh the page a few times until the session is in "Ready" status. Click the checkbox next to the session and then click "Archive". We're now ready to dive into XNAT's built in Anonymization features.
Complete
You have uploaded a session and automatically routed it to your project, via a DICOM configuration.
Go to Step 4: Write An Anonymization Script