1  function [ X, W ] = gen_data( channels, length, window, overlap, fraction )


2 


3  % function to generate test data for SKIM script


4  % written by Jonathan Tapson at Telluride, 2/7/2013


5  %


6  % X is data set, W is the target pattern


7  % multiple inputs, one output


8  % output is the last column of X


9  % channels is number of input neurons


10  % length is number of samples in time


11  % window is length in samples of pattern


12  % overlap is likelihood of patterns overlapping (not real probability)


13  % fraction is fraction of samples which are random spikes


14  % gen_stp: Generate a spatiotemporal pattern for training or testing


15 


16  out_block=10; % length of output spike


17  out_pat=ones(10,1); % target pattern


18  X = (rand(length, channels+1)<fraction); % start with random spike noise


19  X(:,(channels+1))=zeros(length,1); % empty output array


20  W = zeros(window, channels+1); % empty pattern block


21 


22  % make spatiotemporal pattern


23  R= round(rand(1,channels)*(windowout_block1)); % spike indices, not overlapping with target


24  for i=1:channels


25  W((R(i)+1),i)=1; % make spikes


26  end


27  W((windowout_block+1):window,channels+1)=out_pat;


28 


29  % insert spatiotemporal pattern in X (this is a mess)


30  T=window/length*overlap;


31  I=(rand(length,1)<T);


32  for i=1:(lengthwindow)


33  if I(i,1)==1


34  X(i:(i+window1),:)=W+X(i:(i+window1),:);


35  end


36 


37 


38 


39 


40  end


41 

