%% first go to each folder and look at good stims
clear;
goodstims=[1 2 3];
save(['goodstims.mat'],'-v7.3','goodstims' )

%% detect folders
clear
Folders=dir(cd);
isub = [Folders(:).isdir]; %# returns logical vector
Folders(~isub)=[];
remove=[];
for i=1:length(Folders)
if Folders(i).name=="." | Folders(i).name==".."
remove=[remove i];
end
end
Folders(remove)=[];
clear isub remove i
%%
currentPath=cd;
for folderi=2: length(Folders)
folderi
copyfile( 'Analysis.m', Folders(folderi).name)
cd (Folders(folderi).name)
run('Analysis.m')
folderi
clearvars -except folderi currentPath Folders
folderi
cd(currentPath)
end
