fMRI Distortion Correction
So essentially, a button in CSPM that just says "distortion correction?", which, when selected in preprocessing causes a series of steps to occur immediately following t1 coregistration in our standard processing pipeline.
Both steps require an initial search in the fMRI preprocess folder for a particular participant for an image series + mean file with the prefix "xt1..." then;
if xt1 series + mean is found, perform normalization using this series as normal
if xt1 series + mean is not found - do these steps and then error out of preprocessing:
create subfolder in fMRI preprocess for that participant called "distortion correction"
copy t1... image series for that participant into this created folder
convert the copied t1 image series to int16 using the "CSPM-change type" function
convert the int16 images to a 4D image using the "CSPM-convert 3D to 4D" function
convert the 4D.nii to .nii.gz using the "CSPM convert .nii to .gz" function
then error preprocessing once looped through all participants in a given set, allowing us to run our distortion correction script in linux.
If 2. is for example run, then we would manually do the steps to populate the "xt1..." image series back into the fMRI preprocess folder for participants in a set, and then rerun preprocessing which will now satisfy condition 1. instead of 2., and lead to normalization being run and the set to completion.
This option allows for external distortion correction in the preprocessing.
Fernando today and went through what in an ideal world this implementation would look like - much the same with the button integrated into CSPM, however if possible the workflow would look something like:
CSPM looks for an image series “XT1v1….” for a given participant
If no series found, create folder in fMRI preprocess “DISTORTION CORRECTION”
3, Copy t1v1 image series - just the series without the mean image - into DISTORTION CORRECTION folder
Change type of all images in DISTORTION CORRECTION folder to 16 bit int
Convert 3D to 4D nifti on all images in DISTORTION CORRECTION folder
Force crash preprocessing with some sort of message saying “you have selected distortion correction, please run distortion correction using images in DISTORTION CORRECTION folder”
Where it gets tricky is that we would then run Fernandos script, and the output of this would be a 4D nifti file, with distortion correction run and renamed to “xt1v1…”
Once we have that we would ideally like to be able to put that image back into the fMRI preprocess folder, go to rerun preprocessing and have CSPM be able to identify that there exists a 4D nifti with the “xt1v1” prefix in a given folder, convert that 4D back to a series of 3D nifti files and create a mean image and then continue preprocessing.