function [flat_trace]=ConstructFlatTrace( PSP,PSP_start,length_flat_trace,baseline)
% Constructs a "flattened" trace from
%       1. PSP -- struct of PSP's
%       2. PSP_start -- start times of PSP's
%       3. length of the trace
%       4. baseline value
%   (Overlapping PSP's are just overwritten by last PSP in list)...


% Construct a flattened trace from PSP and PSP_start
    
    flat_trace=baseline+zeros( length_flat_trace,1 );
    
    for j=1:numel(PSP_start)
        if j==1341
            %'1'
        end
        flat_trace( PSP_start(j):(PSP_start(j)+numel(PSP{j})-1) )=   ...
           PSP{j}; 
           %+ flat_trace( PSP_start(j):(PSP_start(j)+numel(PSP{j})-1) );
        
    end