logo

We dowloaded the UKBiobank MRI images by batches of 500 (maximum number of download using ukbfetch).
Each batch is numbered and stored in a separate folder called batchXX. Processing by batch reduces the pressure on the cluster and speeds up the data creation.

2 Processing of T1 and T2 images

  • FreeSurfer 6.0 recon-all processing
    T1w and T2 FLAIR are processed together if both are available, otherwise T1w are processed by themselves.

  • .mgh surface files are then converted into .asc readable text files

  • ENIGMA-shape processing is performed to extract subcortical structure

  • Save all useful files in the ENIGMAshapeResults and FSresults folders

If space or number of files is a limitation, you can delete all intermediate FreeSurfer files at the end of the processing by adding the extra command: ‘rm -r “${wd}"/FS/batch"${batch}”/${ID}’
This leaves you with the contents of FS/ENIGMAshapeResults and FS/FSresults only, which contain everything you need for the analyses.


for batch in {1..5}
do
${bind}/qsubshcom " echo \${TASK_ID}.\$(sed -n \"\${TASK_ID}{p;q}\" "${medici}"/T1/raw/batch"${batch}"/T1_fetch_batch"${batch}".lis) |;
file=\$(sed -n \"\${TASK_ID}{p;q}\" "${medici}"/T1/raw/batch"${batch}"/T1_fetch_batch"${batch}".lis) |;
ID=\${file:0:7} |;
echo \${file} |;
echo \${ID} |;
mkdir -p "${wd}"/FS/batch"${batch}" |;
mkdir -p "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/ |;
mkdir -p "${wd}"/FS/ENIGMAshapeResults/batch"${batch}"/\${ID}/ |;
SUBJECTS_DIR=\"/working/directory/FS/batch"${batch}"/\" |;
if [ -e "${wd}"/T2/unzip/batch"${batch}"/\${ID}/T2_FLAIR/T2_FLAIR_unbiased_brain.nii.gz ] |;
then |;
"${fsdir}"/bin/recon-all -subject \${ID} -i "${wd}"/T1/unzip/batch"${batch}"/\${ID}/T1/T1_orig_defaced.nii.gz -T2 "${wd}"/T2/unzip/batch"${batch}"/\${ID}/T2_FLAIR/T2_FLAIR_orig_defaced.nii.gz -T2pial -all -qcache  |;
else |;
"${fsdir}"/bin/recon-all -subject \${ID} -i "${wd}"/T1/unzip/batch"${batch}"/\${ID}/T1/T1_orig_defaced.nii.gz  -all -qcache   |;
fi |;
"${fsdir}"/bin/mris_convert -c "${wd}"/FS/batch"${batch}"/\${ID}/surf/lh.area.fwhm0.fsaverage.mgh "${fsdir}"/subjects/fsaverage/surf/lh.orig "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/lh.area.fwhm0.fsaverage.asc |;
"${fsdir}"/bin/mris_convert -c "${wd}"/FS/batch"${batch}"/\${ID}/surf/rh.area.fwhm0.fsaverage.mgh "${fsdir}"/subjects/fsaverage/surf/rh.orig "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/rh.area.fwhm0.fsaverage.asc |;
"${fsdir}"/bin/mris_convert -c "${wd}"/FS/batch"${batch}"/\${ID}/surf/lh.thickness.fwhm0.fsaverage.mgh "${fsdir}"/subjects/fsaverage/surf/lh.orig "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/lh.thickness.fwhm0.fsaverage.asc |;
"${fsdir}"/bin/mris_convert -c "${wd}"/FS/batch"${batch}"/\${ID}/surf/rh.thickness.fwhm0.fsaverage.mgh "${fsdir}"/subjects/fsaverage/surf/rh.orig "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/rh.thickness.fwhm0.fsaverage.asc |;
perl "${bind}"/ENIGMA_shape/MedialDemonsShared/bin/Medial_Demons_shared.pl "${wd}"/FS/batch"${batch}"/\${ID}/mri/aseg.mgz 10 11 12 13 17 18 26 49 50 51 52 53 54 58 "${wd}"/FS/batch"${batch}"/\${ID}/ENIGMA_shape/ "${bind}"/ENIGMA_shape/MedialDemonsShared "${fsdir}"/bin |;
rsync -r "${wd}"/FS/batch"${batch}"/\${ID}/ENIGMA_shape/* "${wd}"/FS/ENIGMAshapeResults/batch"${batch}"/\${ID}/ |; 
rsync -r "${wd}"/FS/batch"${batch}"/\${ID}/stats/* "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/ |;
rsync -r "${wd}"/FS/batch"${batch}"/\${ID}/surf/*.mgh "${wd}"/FS/FSresults/batch"${batch}"/\${ID}/ |;
" 1 4G MRI_processing_batch${batch} 48:00:00 "-array=1-500 -acct=UQ-IMB-CNSG" 
done
 




A work by by [Baptiste Couvy-Duchesne] - 23 April 2020