XNAT is an open source imaging informatics platform developed by the Neuroinformatics Research Group at Washington University. XNAT was originally developed in the Buckner Lab at Washington University, now at Harvard University. It facilitates common management, productivity, and quality assurance tasks for imaging and associated data. Thanks to its extensibility, XNAT can be used to support a wide range of imaging-based projects.
There are several projects that currently use XNAT to manage a vast number of datasets.
For a more complete list of XNAT implementations around the world you can click here.
You can install Rxnat
from github with:
XNAT projects can be public or private. In order to access a private repository a set of credentials are required. To obtain a user name and password combo you will need to visit:
Rxnat
packageThe Rxnat
package will accept credentials provided in the function call or read from the system environment.
To establish a connection using the credentials as function parameters we can call the xnat_connect
function:
To use system environment variables we need to add them to the .Renviron
file located in the user’s home folder. Use Sys.getenv("HOME")
to get the path (for unix/osx users the location can be easily accessed with ~, eg. vi ~/.Renviron
). The Rxnat
package will be able to automatically read / use a system environment variable provided the following format is used: XXXX_Rxnat_USER
and XXXX_Rxnat_PASS
. XXXX
is provided as an argument when an XNAT connection is initiated.
As an example NITRC
is used as argument and the system environment variables names should be NITRC_Rxnat_USER
, and NITRC_Rxnat_PASS
.
NITRC has some public image repositories, a username and password are not required to connect/query them. To create a connection to the public NITRC resources we call the xnat_connect
function.
Once a connection is established using the xnat_connect
function a list of available projects can be easily retrieved by using the class internal function projects
:
A full list of subjects for each XNAT connection can be retrieved using the subjects
function:
nitrc_subjects <- nitrc$subjects()
head(nitrc_subjects)
#> project ID label gender handedness yob education ses
#> 1 cs_schizbull08 xnat_S02582 BPDwPsy_065 M R NA NA NA
#> 2 cs_schizbull08 xnat_S02583 BPDwPsy_066 F L NA NA NA
#> 3 cs_schizbull08 xnat_S02584 BPDwPsy_067 M R NA NA NA
#> 4 cs_schizbull08 xnat_S02585 BPDwPsy_068 M R NA NA NA
#> 5 cs_schizbull08 xnat_S02586 BPDwPsy_069 F R NA NA NA
#> 6 cs_schizbull08 xnat_S02587 BPDwPsy_070 M R NA NA NA
#> group race ethnicity
#> 1 Bipolar Disorder: With Psychosis NA NA
#> 2 Bipolar Disorder: With Psychosis NA NA
#> 3 Bipolar Disorder: With Psychosis NA NA
#> 4 Bipolar Disorder: With Psychosis NA NA
#> 5 Bipolar Disorder: With Psychosis NA NA
#> 6 Bipolar Disorder: With Psychosis NA NA
To obtain a full list of experiments the experiments
function will be used:
nitrc_experiments <- nitrc$experiments()
head(nitrc_experiments)
#> project subject ID type label age
#> 1 cs_schizbull08 BPDwPsy_065 xnat_E02577 xnat:mrSessionData BPDwPsy_065_MR 7
#> 2 cs_schizbull08 BPDwPsy_066 xnat_E02579 xnat:mrSessionData BPDwPsy_066_MR 11
#> 3 cs_schizbull08 BPDwPsy_067 xnat_E02581 xnat:mrSessionData BPDwPsy_067_MR 8
#> 4 cs_schizbull08 BPDwPsy_068 xnat_E02583 xnat:mrSessionData BPDwPsy_068_MR 7
#> 5 cs_schizbull08 BPDwPsy_069 xnat_E02585 xnat:mrSessionData BPDwPsy_069_MR 16
#> 6 cs_schizbull08 BPDwPsy_070 xnat_E02587 xnat:mrSessionData BPDwPsy_070_MR 13
The scan resources for an experiment can be retrieved using the get_xnat_experiment_resources
function:
xnat_E00026_resources <- nitrc$get_xnat_experiment_resources('xnat_E00026')
head(xnat_E00026_resources[c('Name','URI')])
#> Name
#> 1 scan_rest.nii.gz
#> 2 scan_rest.nii.gz
#> 3 scan_mprage_skullstripped.nii.gz
#> 4 scan_mprage_skullstripped.nii.gz
#> 5 scan_mprage_anonymized.nii.gz
#> 6 scan_mprage_anonymized.nii.gz
#> URI
#> 1 /data/experiments/xnat_E00026/scans/func_rest/resources/11987/files/scan_rest.nii.gz
#> 2 /data/experiments/xnat_E00026/scans/func_rest/resources/3969/files/scan_rest.nii.gz
#> 3 /data/experiments/xnat_E00026/scans/anat_mprage_skullstripped/resources/11986/files/scan_mprage_skullstripped.nii.gz
#> 4 /data/experiments/xnat_E00026/scans/anat_mprage_skullstripped/resources/3968/files/scan_mprage_skullstripped.nii.gz
#> 5 /data/experiments/xnat_E00026/scans/anat_mprage_anonymized/resources/11985/files/scan_mprage_anonymized.nii.gz
#> 6 /data/experiments/xnat_E00026/scans/anat_mprage_anonymized/resources/3967/files/scan_mprage_anonymized.nii.gz
If you are interested just in a subset of subjects/experiments that match a certain criteria you can use the query_scan_resources
function. Accepted query parameters are:
To retrieve a list of all subject IDs and associated experiment IDs we can use the query_scan_resources
function. In the example below, we are querying the HCP XNAT database for all subjects belonging the the HCP_500 project with scans taken at age 26.
nitrc_age_26 <- query_scan_resources(nitrc,age='26')
head(nitrc_age_26[c("subject_ID","experiment_ID", "Project", "Age")])
#> subject_ID experiment_ID Project Age
#> 1 NITRC_IR_S05244 NITRC_IR_E10507 ixi 26
#> 2 NITRC_IR_S05267 NITRC_IR_E10530 ixi 26
#> 3 NITRC_IR_S05270 NITRC_IR_E10533 ixi 26
#> 4 NITRC_IR_S05278 NITRC_IR_E10541 ixi 26
#> 5 NITRC_IR_S05394 NITRC_IR_E10657 ixi 26
#> 6 NITRC_IR_S05427 NITRC_IR_E10690 ixi 26
To download a single file we will use the download_file
function. Using the first experiment_ID
from the above example, we will get all scan resources associated with it first.
To download the resource file (100307_3T_BIAS_BC.nii.gz) we will do:
To download all the T1 type images from experiment ConnectomeDB_E03657 we will use the download_xnat_dir
function.