===== UNI PROCESSING PIPELINE ===== /* echos {{.:pasted:20260416-110230.png}} */ {{.:pasted:20260416-110315.png}} 1. Run ''Hera/Projects/SPA/scripts/mri/preproc/00_bids-t1-only.bash'' to link Hera/Raw/BIDS/SPA/sub-$/ses-$/anat/*UNIT1* to Hera/Projects/SPA/scripts/mri/fs/bids-t1only 2. Run ''Hera/Projects/SPA/scripts/mri/preproc/01_denoise_unicort.bash'' to denoise and UNICORT correct the UNIT1. The output is Hera/Projects/SPA/scripts/mri/fs/bids-t1only/sub-$/ses-$/anat/msub-$_ses-$_DEN-10.nii * The denoising script called here is Hera/Projects/SPA/scripts/mri/preproc/denoise.m , which sets regularization=10 (unless another value given as environment variable) * SPM UNICORT is run with default parameters. The unicort script called is Hera/Projects/SPA/scripts/mri/preproc/spm_unicort.m 3. Run ''Hera/Projects/SPA/scripts/mri/preproc/02_fs.bash'' to run freesurfer on denoised and unicort corrected UNI images. The output is Hera/Projects/SPA/scripts/mri/fs/7.4.1-denunicort-hires * Freesurfer is run via docker container. We are using freesurfer version 7.4.1 with the -hires flag and running cross-sectional (not longitudinal) recon-all. The main recon-all call is recon-all -hires -all -i "$f" -s "$sub". Note: some segmentations are very bad with 7.4.1 when the cerebellum is cut off. We are testing freesurfer 8 (with syntheseg) to see if this improves it * Input to freesurfer is the denoised and unicort-corrected UNI from above (msub-$_ses-$_DEN-10.nii) (INPUTS=(../fs/bids-t1only/sub-/ses-/anat/msub-_ses-_DEN-10.nii) || 4. Run ''Hera/Projects/SPA/scripts/mri/preproc/02.2_fs-hcseg_fs.bash'' to perform amygdala-hippocampal segmentation via freesurfer. The output is in each subject's fs output \\ **At any point, to check how many scans have undergone each processing step above, run ''Hera/Projects/SPA/scripts/mri/preproc/counts.bash''! This provides the number of scans that have been linked from BIDS to bids-t1only, denoised, unicort corrected, and processed with freesurfer recon-all and freesurfer segmentHA_T1.sh.** * To check who is missing from a specific step, you can do e.g.: bids_anat() { find Hera/Raw/BIDS/SPA/sub-*/ses-*/anat -iname '*UNIT1*'; } ls_reconlog(){ ls Hera/Projects/SPA/scripts/mri/fs/7.4.1-denunicort-hires/ses-*/sub-*/scripts/recon-all.done; } comm -23 \ <(bids_anat | sed -E 's|.*/(sub-[^_]+_ses-[^_]+)_.*|\1|' | sort -u) \ <(ls_reconlog | sed -E 's|.*/(ses-[^/]+)/(sub-[^/]+)/.*|\2_\1|' | sort -u) ===== R1 PROCESSING PIPELINE ===== 1. Run ''Hera/Projects/SPA/scripts/mri/preproc/04_qT1_R1.bash'' to generate raw and UNICORT-corrected R1 maps from raw UNI data. The output is Hera/Projects/SPA/scripts/mri/R1/sub-$/ses-$/sub-$_ses-$_R1map.nii.gz * This calls the script T1R1maps.m.This requires setting MP2RAGE parameters - MP2RAGE.B0 = 7 . This is the # of Teslas - MP2RAGE.TR = 6 . This is the typical repetition time, stored in RepetitionTime in the json sidecars. It is 6 for all scans - MP2RAGE.TRFLASH = 6.3e-3 . This is the TR of the GRE readout aka TR of underlying 3D GRE readout train used to sample k-space after each inversion. This was obtained from the Siemens protocol PDFs (same pre and post update) from "Echo Spacing". Confirmed the Echo spacing is the correct parameter with Chan - MP2RAGE.TIs = [800e-3 2700e-3] . This is the inversion times for INV1 and INV2 images. This is the InversionTime in the json sidecars. It is 0.8 / 2.7 s for all scans - MP2RAGE.FlipDegrees=[4 5] . This is the flip angle for INV1 and INV2. It is FlipAngle in the json sidecars. It is 4 / 5 for all scans - MP2RAGE.NZslices is equal to the number of slices reported in the z-direction in the data, adjusted for oversampling. The equation is round(nz * (1 + oversample/100)); where nz = slices in z direction ("nk"), oversample is obtained from the scanner PDF or the siemens private header CSA value for 'sKSpace.dSliceOversamplingForDialog' * Input is raw (off the scanner) UNI data that is not denoised and not B1+ bias corrected * After setting the MP2RAGE parameters as above, this script uses T1estimateMP2RAGE (https://github.com/JosePMarques/MP2RAGE-related-scripts/blob/master/func/T1estimateMP2RAGE.m) to calculate T1/R1 maps from the UNI data. It saves the raw R1 map and then uses SPM unicort to bias field correct it, and says the corrected R1 map as output as well