function  batrunanalysis(outlistname, resetanova)


global Userinput Expstreams Explags Expstreamnums ExpEvents Exptime numnames outlist outlist2

global rt startrt rtlist dottime compact T1r T2r T2rc T2rnc T1rc Trialcount Swap Both rtcount means ITEMS
global dotcount dotprofile samestream diffstream condcopy evcopy dotsatpos dotacc persubmeans Or ors subresp

global numtrials cstringssubject reporder strings cstrings numallgood avgreporder subjfile3  filename subcstrings
global numresponses


numcond = 7;

ft = fopen(outlistname,'r');

outlist = fscanf( ft ,'%s');

fclose(ft);

a = size(outlist,2);
sofar = 1
last = 1;
i = 1;

filename = 'CondT1T2'

 subjfile3 = fopen(sprintf('dataout%s.txt',filename), 'w');


for(i=1:a-3)
    if(sum(outlist(i:i+3)== '.mat') == 4)

        outlist2{sofar} = outlist(last:i+3);
        last = i+4;
        sofar = sofar + 1;
    end
end

sofar = sofar - 1;
newone = 0;
oldname = 'xxx'
numnames = 0;
for i=1:sofar

    load(outlist2{i})
    if(i ==1)
        newanalyzedots(1,1)
    elseif(i/2 < ceil(i/2))   %newsub
        newanalyzedots(0,1)
    else
        newanalyzedots(0,0)
        subcstrings((i/2),1:4,1:numcond,1) = reshape(cstringssubject(:,:,:),[1,4,numcond,1]);   %end of a subject, compile his data
        subresp((i/2),1:numcond,1) = reshape(numtrials,[1,numcond,1]);
         
    end
end
subcstrings

%T1r = T1r/Trialcount(1,1)


for(i = 1:size(reporder,1))
    for(j = 1:size(reporder,2))
        avgreporder(i,j,:,:) = reporder(i,j,:,:) /numallgood(i,j);
    end
end


subjfile = fopen('persubmeans.xl', 'w');

 
accuracies(:,1,:) = subcstrings(:,1,:) ./reshape(subresp(:,:),[12,1,7])
accuracies(:,2,:) = subcstrings(:,2,:) ./reshape(subresp(:,:),[12,1,7])
accuracies(:,3,:) = subcstrings(:,3,:) ./reshape(subresp(:,:),[12,1,7])
accuracies(:,4,:) = subcstrings(:,4,:) ./reshape(subresp(:,:),[12,1,7])

 for(j = 1:size(persubmeans,1))
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,1,1)/subresp(j,1,1));
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,2,1)/subresp(j,2,1));
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,3,1)/subresp(j,3,1));
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,4,1)/subresp(j,4,1));
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,5,1)/subresp(j,5,1));
     fprintf(subjfile, '%g, %g, %g, %g,,  ', subcstrings(j,:,6,1)/subresp(j,6,1));
     fprintf(subjfile, '%g, %g, %g, %g\n',   subcstrings(j,:,7,1)/subresp(j,7,1));
 end

numresponses = subresp;

 

subjfile2 = fopen('dataout.txt', 'w');

for(j = 1:size(persubmeans,1))
    for(pos = 1:4)
        for(soa = 1:6)
            for(idd = 1:1)
                              
                fprintf(subjfile2, '%d\t%d\t%d\t%d\t%.5g\n', j,pos,soa,idd,subcstrings(j,pos,soa,idd)/subresp(j,soa,idd));
            end
        end
    end
end




fclose(subjfile);
fclose(subjfile2);
fclose(subjfile3);

save('dataout','accuracies','subcstrings','subresp')

%showresults




