#!/bin/bash
for i in $(ls -d subj*) #this will assign to variable i each directory beggining with subj
do
  cd ~/freesurfer/subjects/$i/mri #my freesurfer is installed under my home directory, adapt to your environment
  rm -f RightVol #just to erase the file you may have created during a previous run
  kvlQuantifyPosteriorProbabilityImages $FREESURFER_HOME/data/GEMS/compressionLookupTable.txt   posterior_right_* posterior_Right-Hippocampus.mgz > RightVol
  rm -f LeftVol
  kvlQuantifyPosteriorProbabilityImages $FREESURFER_HOME/data/GEMS/compressionLookupTable_left.txt   posterior_left_* posterior_Left-Hippocampus.mgz > LeftVol
done
