I am running an mriglm on bunch of small time series for my subjects, but I am getting an error when I run the for loop. I think its the for loop and not the command, because I have run this command without the for loop before. I also want to be able to run this on more than one subject if possible, but whenever I try to run for file in $SUBJECT_DATA_DIR; do if [[ "${file}" == "racsleep04_b" ]] with more than one subject it doesn't run.
so the two questions I have are:
- am I nesting the two for loops correctly?
- how would I apply this to more than one subject?
any help would be very much appreciated!
export SUBJECT_DATA_DIR=/path/to/subject/data/dir/*
export time=('15' '30') #each time series name
for i in ${time[*]}; do
for file in $SUBJECT_DATA_DIR; do if [[ "${file}" == *"racsleep04_b"* ]]
export MRTM=$SUBJECT_DATA_DIR/"$(basename $file)"/kinetic_modelling_intervals_all
export OUTPUT=caudate
export TIME=$SUBJECT_DATA_DIR/time
#running mrtm1 analysis:
mri_glmfit --y $MRTM/$OUTPUT/gtm${i}.nii --mrtm1 $MRTM/$OUTPUT/km.ref.tac${i}.dat $MRTM/$OUTPUT/frame.time${i}.dat --o $MRTM/mrtm1_${i} --no-est-fwhm --nii.gz
fi
done
done
when I run the script below I get this error:
/share/pkg.7/freesurfer/6.0/install/bin/mri_glmfit: line 3: 26183 Segmentation fault mri_glmfit.bin "$@"
I also wanted to do this for multiple subjects, e.g. sub01, sub02, sub03 on other similar scripts that work, only the first subject runs, but not the other two:
for i in ${time[*]}; do
for file in $SUBJECT_DATA_DIR; do if [[ "${file}" == "sub01" "sub02" "sub03" ]]
export MRTM=$SUBJECT_DATA_DIR/"$(basename $file)"/kinetic_modelling_intervals_all
export OUTPUT=caudate
export TIME=$SUBJECT_DATA_DIR/time
#running mrtm1 analysis:
mri_glmfit --y $MRTM/$OUTPUT/gtm${i}.nii --mrtm1 $MRTM/$OUTPUT/km.ref.tac${i}.dat $MRTM/$OUTPUT/frame.time${i}.dat --o $MRTM/mrtm1_${i} --no-est-fwhm --nii.gz
fi
done
done