#!/bin/sh

#Charlotte Rae 2012

#Put me in your /home/bin/, and remember to make me executable with chmod a+rwx copy_series_dcm2nii.

#Make a folder for each subject in the study directory

#Copy the DTI Series from the CBU mridata to subject folder

#Run dcm2nii in the copied Series folder

subjs="110159 110309"
#Put your subject ids in here

#Write your main directory here
cd /imaging/cr01/folder/

#Make a folder for each subject in the main study directory
for zzVARfol in ${subjs} ; do
echo "Making subject folder for ${zzVARfol}"
mkdir ${zzVARfol}
done

#Copy the DTI series from CBU mridata for each subject
for zzVARcopy in ${subjs} ; do
echo "Copying diffusion Series for ${zzVARcopy}"
cp -r /mridata/cbu/"CBU"${zzVARcopy}*/*/"Series"*"_nameofyourdiffusionsequence" ${zzVARcopy}
done

#Start in main study directory, go to each subject's copied Series folder and run dcm2nii, then go back to main study directory
for zzVARnii in ${subjs} ; do
cd /imaging/cr01/folder/
echo "dcm2nii-ing ${zzVARnii}"
cd ${zzVARnii}/Series*
dcm2nii *
done


echo "End"
