function srd=srdPostProcess(srd,data)
%SRDPOSTPROCESS
%==========================================================================
% We want to reconstitute srd from a vector of structs into one struct.
%
% If srd is a struct array, then do the following:
% - For a given field in srd(i), e.g., srd(i).field, concatenate 
%   the data across i=1,2,...,n into a matrix, i.e., 
%   Mi=[srd(1).field; srd(2).field; ...; srd(n).field]. 
% - Repeat for each field in srd.
%==========================================================================

srdcopy=srd;
srd=[]; 
n=length(srdcopy);
if n > 1
    F=fieldnames(srdcopy);
    % Cycle through each field name in srd
    for i=1:length(F)
        v=cell(n,1);
        % Cycle through each component of srd associated with field F{i}
        % and extract the data into cell array components
        for j=1:n
            tmp=srdcopy(j).(F{i});
            v{j}=tmp(:)';
        end
        % Concatenate the data into a matrix and 
        v=srdStack(v);
        srd.(F{i})=v;    
    end    
else
    srd=srdcopy; 
end    

%
% Apppend data to srd struct for posterity 
%
srd.data=data;
%==========================================================================
end




