function batchAFNIgetonifti(workDir,dirPre,saveName)

currentDir = pwd;

cd(workDir);

dirName = dir([workDir '/' dirPre]);

numDir = numel(dirName);

for ii = 1:numDir
    
  
  system(['Ifile ' dirName(ii).name '/I.*']);
  system('./GERT_Reco');
  system(['mri_convert -ot nii ./afni/OutBrick_r1+orig.BRIK ./' saveName '_' dirName(ii).name '.nii']);
  system('rm -r afni');
  system('rm GERT_Reco PangaList MAPLOG_Panga');
  

  
end

  cd(currentDir);
