/
Organising MRI data for your study

Attention: Confluence is not suitable for the storage of highly confidential data. Please ensure that any data classified as Highly Protected is stored using a more secure platform.
If you have any questions, please refer to the University's data classification guide or contact ict.askcyber@sydney.edu.au

Organising MRI data for your study

Frontier MRI data is saved in XNAT with subject IDs (unique 5-7 digits numbers) and session IDs (unique 4 digit numbers preceded by “FTD”). When you download data from XNAT it will have these identifiers. When carrying out a study it can be helpful to instead use a unique study ID, especially if you are carrying out a longitudinal study.

The easiest way to create your study IDs is to assign a number to each subject in your cohort and then create the ID made up of the group (eg CTR for control), underscore, the number you assigned (eg 001), underscore, followed by the timepoint (eg MR1 for the first timepoint. So the study ID for this example subject would be CTR_001_MR1.

If you are doing this in Excel you can create a separate column for each part of the ID and then join them with a formula like: =B2&"_"&C2&"_MR"&D2 where column B is the group, C is the number you assigned, and D is the visit number.

To download your files from XNAT, you can use a script like the following:

#!/bin/bash -v #PBS -P #PBS -N #PBS -l select=1:ncpus=1:mem=16GB #PBS -q dtq #PBS -l walltime=1:00:00 module load python/3.6.5 source ~/xnatutils.venv/bin/activate export FSLMETHOD=NONE ################################################################################################################# # DATA PREPARATION # # Add project name and job name to PBS script above # # Create a directory for your data and define the root path with this location # # # Comment out the lines for downloading T1 or DWI if you don't need them # # If you don't already have an xnatutils environment set up, enter the following # # module load python/3.6.5 # # python -m venv ~/xnatutils.venv # # source ~/xnatutils.venv/bin/activate # # pip install xnatutils # # Before submitting, do source ~/xnatutils.venv/bin/activate + run xnat-ls to pass in your login information # ################################################################################################################# ################################################################################################################# # CODE FOR TERMINAL # module load python/3.6.5 # # source ~/xnatutils.venv/bin/activate # # xnat-ls # # # subject_list='FTDXXXX FTDXXXX FTDXXXX FTDXXXX' # # for i in $subject_list ; do qsub -v sub=$i xnatget.pbs; done # ################################################################################################################# root_path=/scratch/Project/Folder/Data/ echo ${sub} #Download scans from XNAT #T1 - COMMENT OUT IF YOU DON'T NEED T1# xnat-get ${sub} --scan '.*T1a.*' '.*T1b.*' '.*T1c.*' --resource DICOM --target ${root_path} #DWI - COMMENT OUT IF YOU DON'T NEED DWI# xnat-get ${sub} --scan '.*DTI.*' --resource DICOM --target ${root_path}

Once you have downloaded your scans from XNAT. You can use the below method to rename all your folders easily. You want to do this before preprocessing, as all subsequent files and folders will be created with the same ID.

Move to the folder with your files in it, eg:

cd /scratch/projectname/DATA

From your cohort spreadsheet, copy the column with the current sessions IDs (the FTD numbers)

On the command line create a list with the pasted in IDs, eg:

list='FTDXXXX FTDXXXX FTDXXXX'

Then create a txt file containing the new IDs (copy and paste them in the same way) Make sure they remain in the same order as the other list of IDs.

vi newIDs.txt

Press insert to go into insert mode on the vim editor and paste in the IDs. Press Esc to leave insert mode and then enter :wq! to save the file.

Now copy the following code and press enter (make sure you’re still in the correct directory with all the folders and the txt file):

for oldID in $list; do IFS= read -r newID || break echo mv --no-clobber -- "$oldID" "$newID" done < newIDs.txt

check that the old and new IDs are matching up correctly and then delete “echo” from the code and enter it again.

You can then remove the newIDs.txt file as it’s no longer needed.

Related content