Mrcat_batch_concatenation

Dear @jdtournier ,
I hope you are doing great today. Happy Valentine’s Day.
I have a simple question for you.
Suppose, I would like to concatenate FA images for 6 patients (actually higher than 6). All FA images were warped into 2010/FA.nii.gz.

/suren/2010/FA.nii.gz
/suren/2011/FA.nii.gz
/suren/2012/FA.nii.gz
/suren/2013/FA.nii.gz
/suren/2014/FA.nii.gz
/suren/2015/FA.nii.gz

I create a SubjList.txt that has

2010
2011
2012
2013
2014
2015

Now, I would like to use mrcat command.

cat $(pwd)/SubjList.txt | while read line
do
mrcat -axis 3 ${line}/FA.nii.gz FA_cat.nii.gz
done

I don’t want to list all the paths in the mrcat command for input images. I want to use for loop if it helps. Would you please help me with the above script?

Thanks a lot,
Suren

This should do the trick:

mrcat $(for x in $(cat SubjList.txt); do echo $x/FA.nii.gz; done) -axis 3 FA_cat.nii.gz
1 Like