clear;clc;
cd /home/subhadip/Autism_AnatNet/austistic_study

maindirpath=['/home/subhadip/Autism_AnatNet/austistic_study/'];
%specify the subject directories
subjdir=dir('aHU*');

for l=1%:length(chk)
   
    subjdirpath=strcat( maindirpath , subjdir(l).name)
    [status currdir] = system([ ' cd  '  strcat( maindirpath , subjdir(l).name) ])
  
%     datafiles=dir('dti*')
%    
% %    for m=1:length(datafiles)
% %    
% %    %split the individual datafiles
% %    datafile=strcat(maindirpath,subjdir(l).name,'/',datafiles(m).name);
% %    datapath=strcat(maindirpath,subjdir(l).name,'/');
% %    [status currdir] = system([' fslsplit ' datafile ]);
% %    
%    %move the splitted volumes to the subject directory
%    tempvolfiles=strcat(maindirpath,'vol*');
%    movefile(tempvolfiles , datapath);
%    
%    
%    %merge the bo and other volfiles
%    setenv('FSLOUTPUTTYPE','NIFTI_GZ');
%    
%    tempvolpath=strcat(datapath , 'vol*');
%    tempfiles=dir(tempvolpath)
%    
%     b0path=strcat(datapath , 'b0.nii.gz')
% %    
% %    a=['fslmaths -t ' b0path];
% %    for l=2:length(files)
% %        file=strcat(datapath,tempfiles(l).name)
% %    a=[a  ' -add ' file];    
% %    end
% %    
% %    ch=str2num(m,'%03d');
% %    outputname=strcat('dataset',ch);
% %    a=[a outputname];
% %    [status currdir] = system([a]);
% %    
% % %    [status currdir] = system([' rm ' datapath ]);
% %    volfiles=strcat(subjdir(l),'/','vol*.nii.gz');
% %    [status currdir] = system([' rm ' volfiles ]);
%    
%    end
% 
 end