Skip to content

Instantly share code, notes, and snippets.

@j6k4m8
Created May 24, 2016 15:05
Show Gist options
  • Save j6k4m8/bbfca3047466b1c77b860d324222d893 to your computer and use it in GitHub Desktop.
Save j6k4m8/bbfca3047466b1c77b860d324222d893 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Stolen ahem I mean borrowed from @gkiar
rawdir='HCP900/raw'
cd ${rawdir}
for i in `ls `;
do
cd ${i}
mkdir ${i}"_95LR" ${i}"_95RL" ${i}"_96LR" ${i}"_96RL" ${i}"_97LR" ${i}"_97RL"
rm -rf *BIAS*
rm -rf *SBRef*
mv *dir95_LR* ${i}"_95LR"
mv *dir95_RL* ${i}"_95RL"
mv *dir96_LR* ${i}"_96LR"
mv *dir96_RL* ${i}"_96RL"
mv *dir97_LR* ${i}"_97LR"
mv *dir97_RL* ${i}"_97RL"
for j in `ls -d */`;
do
echo $j
cp ./*T1w_MPR1.nii.gz ${j}
cd ${j}
for m in `ls | grep MPR1`;
do
echo ${m} 'HCP500_'`echo ${j} | cut -c -11`'_MPRAGE'`echo ${m} | cut -c 19-`;
mv ${m} 'HCP500_'`echo ${j} | cut -c -11`'_MPRAGE'`echo ${m} | cut -c 19-`;
done
for m in `ls | grep DWI`;
do
echo ${m} 'HCP500_'`echo ${j} | cut -c -11`'_DTI'`echo ${m} | cut -c 23-`;
mv ${m} 'HCP500_'`echo ${j} | cut -c -11`'_DTI'`echo ${m} | cut -c 23-`;
done
cd ..
done
rm -rf *T1w_MPR1.nii.gz
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment