function setup

%stream pattern
global ITEMPRESENT ITEMOFF RANDOMBGCOLOR ONTIMINGVARIATION OFFTIMINGVARIATION ITEMS SIZES LOCATIONSX LOCATIONSY COLORS BACKCOLORS FRAMECOLOR ITEMSETS LOCATIONSXVAR LOCATIONSYVAR LOCKP1MASKLOCATION LOCKM1MASKLOCATION PARAMNAMES PARAMS ORTHOPAIRS
%stream structure
global PREITEMS POSTITEMS MINRSVPLENGTH P1BLANKPERCENTAGE M1BLANKPERCENTAGE MAXTARGETS MINTARGETS SKELETAL STARTVARIANCE LAGS  TARGETREPETITION DRECYCLE INFORMUSER TARGETDIST ITEMSETPOOL ONETARGETSTREAMS


%frame parameters

global Axeshandle ITEMPools Setsize Fixcross Realnumstreams Condition Numper

global Laglist  sparecond NUMSTREAMS


%setupparams
load parmfile

NUMSTREAMS


%seed the rng by running it many times.
a = ceil(GetSecs) - GetSecs;
a = ceil(a * 100);
b = 1;

for(i = 1:a)
    b = b + rand;
end
sprintf('Seed output is %d',b)


for (i = 1:size(ITEMS,1))
    [x c] = min(ITEMS(i,:));  %find the zero
    Setsize(i) = c - 1;
end


%now create the table for evenly distributing lags and target
%distributions.

%Note that number of Targets is done separately, an add on.



%conditions:

%Factor 1 7 conditions
%TTTT
%TTTDT
%TTTDDT
%TTTDDDT
%TTTDDDDT

NUMSTREAMS

Numper(1) = ceil(NUMSTREAMS/7)  %7 conditions
Numper(2) = ceil(Numper(1)/1)
Numper(3) = ceil(Numper(2)/1) 
Numper(4) = ceil(Numper(3)/1)  
Numper(5) = ceil(Numper(4)/1) 
Numper(6) = ceil(Numper(5)/1)


%reset condition
Condition = 0;

Targset = 1;


for(s = 1:7)   
    sstart = (s-1)*Numper(1);
    sstop = s*Numper(1);   
    Condition(1,sstart+1:sstop) = s;
  	for(s2 = 1:1)   
		s2start = sstart + (s2-1)*Numper(2);
		s2stop = sstart + s2 *Numper(2);
        
		Condition(2,s2start+1:s2stop) = s2;  
		for(s3 = 1:1)   
			s3start = s2start + (s3-1)*Numper(3);
			s3stop = s2start + s3 *Numper(3);
            
			Condition(3,s3start+1:s3stop) = s3;  
			for(s4 = 1:1)   
				s4start = s3start + (s4-1)*Numper(4);
				s4stop = s3start + s4 *Numper(4);            
				Condition(4,s4start+1:s4stop) = s4;  
				for(s5 = 1:1)   
					s5start = s4start + (s5-1)*Numper(5);
					s5stop = s4start + s5 *Numper(5);            
					Condition(5,s5start+1:s5stop) = s5;  
					for(s6 = 1:1)   
						s6start = s5start + (s6-1)*Numper(6);
						s6stop = s5start + s6 *Numper(6);            
						Condition(6,s6start+1:s6stop) = s6;  
					end
				
				
				end
			
			
			
			end            
		end
	end

end



	[x i] = min(Condition(1,:));
	if(x ==0)
		Condition = Condition(1:6,1:i-1);
	end




	
	
	
