A collection of data management scripts for the STAR study.
- Installation
- Set scan tags
- Audit existing tags
- Set scan types
- Manually set scan metadata fields
- Send or resend DICOM files
- Upload task data
You can install realta
using pip
pip install git+https://github.com/harvard-nrg/realta.git
However, it is recommended to install realta
within a virtual environment
which will give you full control over installed dependencies
python3 -m venv realta
source realta/bin/activate
(realta) pip install git+https://github.com/harvard-nrg/realta.git
star_set_tags.py
will tag all scans for a given STAR session on XNAT
star_set_tags.py --session 230101_STAR_1234_01 --do-updates
To inspect the tags before they are set, omit --do-updates
and specify an
output file
star_set_tags.py --session 230101_STAR_1234_01 -o tags.json
In this example, the specified output file tags.json
will contain any tags
that would have been set by the script.
star_tag_audit.py
will sweep over all sessions within STAR and check if the
tags that are currently set appear to be correct
star_tag_audit.py
This will output a CSV file to standard output with the Expected
tags and the
Actual
tags that were found.
star_tag_audit.py
issues a ton of HTTP requests to XNAT and will take a
while to finish. If you stop and restart this script, it will start over from
the beginning. You can use caching to speed things up.
Warning Make sure you protect the cache file generated when using the
--cache
argument. This file will contain a lot of sensitve information.
Passing --cache
will record previously executed HTTP requests and their
responses to a small sqlite database within your current working directory
named cache.sqlite3
. The next time you run star_tag_audit.py
with the
--cache
argument, the script will read previously recorded responses from
that file rather than sending a request to the server and waiting for a
response. This is far less time consuming and will give you a noticable
performance boost.
star_set_types.py
will set the scan types for a given STAR session on XNAT
star_set_types.py --session 230101_STAR_1234_01 --do-updates
Remove --do-updates
to show the output from this script without actually
changing anything in XNAT.
xnat_set.py
will allow you to arbitrarily set scan metadata fields from the
command line.
To set the scan type
for a given STAR session
xnat_set.py --session 230101_STAR_1234_01 --scan 1 --field type --value BOLD
To set the scan note
for a given STAR session
xnat_set.py --session 230101_STAR_1234_01 --scan 1 --field note --value "too much motion"
To set the scan quality
(i.e., usability) for a given STAR session
Note Scan
quality
can only be set tousable
,unusable
, orquestionable
.
xnat_set.py --session 230101_STAR_1234_01 --scan 1 --field quality --value unusable
xnat_dicom_send.py
will allow you to send, or resend, your DICOM files to XNAT and
have those files auto-archive into a given Project, Subject, and MR Session.
In the example below, /path/to/dicom/files
should contain the DICOM files you
want to send to XNAT.
Note In this example, the
PatientComments
header for each DICOM file will be overwritten with the stringProject:STAR_Study,Subject:STAR_1234,Session:230101_STAR_1234_01 AA:true
xnat_dicom_send.py --project STAR_Study --subject STAR_1234 --session 230101_STAR_1234_01 /path/to/dicom/files
If your DICOM files have already been uploaded to XNAT, but were archived under
the wrong Project|Subject|Session, xnat_dicom_send.py
can download those
files and resend them under the correct Project|Subject|Session
Note In this example, your DICOM files will be downloaded and saved into the directory
/path/to/dicom/files
xnat_dicom_send.py --project STAR_Study --subject STAR_1234 --session 230101_STAR_1234_01 --download-session 230101_STAR_1234_02 /path/to/dicom/files
xnat_file_upload.py
will allow you to upload behavioral task data to a folder
named behavioral_task_data
and assign the file a custom resource name
Note In the following example, the local file
/path/to/task/data.csv
will be uploaded to the folderbehavioral_task_data
and the XNAT file resource will be assigned the nameTask_run1
xnat_file_upload.py --project STAR_Study --subject STAR_1234 --session 230101_STAR_1234_01 --name Task_run1 /path/to/task/data.csv
If you omit --name
, the XNAT resource will be assigned a name that is
identical to the uploaded local file.