Hello @jdtournier ,
Suppose I have 5 data like this:
/User/study/patient_01/dti_01.nii.gz
/User/study/patient_02/dti_02.nii.gz
/User/study/patient_03/dti_03.nii.gz
/User/study/patient_04/dti_04.nii.gz
/User/study/patient_05/dti_05.nii.gz
Now, I would like to denoise these data using dwidenoise and I would like to obtain like this:
/User/study/patient_01/denoise_01.nii.gz
/User/study/patient_02/denoise_02.nii.gz
/User/study/patient_03/denoise_03.nii.gz
/User/study/patient_04/denoise_04.nii.gz
/User/study/patient_05/denoise_05.nii.gz
In general, I would always recommend using identical names within subject folders, to avoid the kinds of bash gymnastics required to deal with a situation like thisβ¦
If you relied on the folder to identify the subject, and kept names within the folder consistent, like so:
for pat in patient*; do dwidenoise $pat/dti.nii.gz $pat/denoise.nii.gz ; done
But with the structure youβre suggesting, things get a bit trickier. I canβt think of a way to do this with our for_each command, but it can be done using regular bash β itβs just a bit of a kludge:
for pat in patient*; do
n=${pat#patient};
dwidenoise $pat/dti_$n.nii.gz $pat/denoise_$n.nii.gz;
done
Things can get easily get messier than this for more complex commands or even slightly different naming schemes though, so again, I would recommend using a simpler structure with identical names within folders β it really makes things a lot easier to handle down the lineβ¦