Home > eeg > egis > egis_file_utils > concat_csdm_chdr.m

concat_csdm_chdr

PURPOSE ^

function new_chdr = concat_csdm_chdr(csdmfiles, obs)

SYNOPSIS ^

function new_chdr = concat_csdm_chdr(csdmfiles, obs)

DESCRIPTION ^

 function new_chdr = concat_csdm_chdr(csdmfiles, obs)

 Concatenates several average file subject specifics array
 into a single chdr
 NOTE: THIS ROUTINE ASSUMES HOMOGENEOUS CELL HEADERS

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function new_chdr = concat_csdm_chdr(csdmfiles, obs)
0002 % function new_chdr = concat_csdm_chdr(csdmfiles, obs)
0003 %
0004 % Concatenates several average file subject specifics array
0005 % into a single chdr
0006 % NOTE: THIS ROUTINE ASSUMES HOMOGENEOUS CELL HEADERS
0007 
0008 % Modification history:
0009 % 01/26/96  PJ Created routine
0010 %
0011 
0012 csdm_hdr_offsets_v;
0013 
0014 csdm_fid = fopen(csdmfiles(1,:),'r');
0015 [csdm_fhdr,csdm_chdr]=rd_csdm_hdr_v(csdm_fid);
0016 fclose(csdm_fid);
0017 
0018 num_files = size(csdmfiles,1);
0019 
0020 if nargin == 2 & num_files > 1
0021   if length(obs) > 1
0022     disp('Warning: Multiple files, multiple observations')
0023     disp('To have proper headers, either specify one observation, or use all, dammit!')
0024   end
0025 else
0026   obs = 1:csdm_chdr(1,NObs);
0027 end
0028 
0029 num_obs = length(obs);
0030 
0031 % Copy top part of chdr from 1st file
0032 new_chdr = csdm_chdr(:,1:5);
0033 
0034 for f = 1:size(csdmfiles,1)
0035   csdm_fid = fopen(csdmfiles(f,:),'r');
0036   [csdm_fhdr,csdm_chdr]=rd_csdm_hdr_v(csdm_fid);
0037   fclose(csdm_fid);
0038 
0039   last_col = size(new_chdr,2);
0040   num_new_col = num_obs * csdm_chdr(1,LSpec)/2;
0041   if num_obs > 1
0042     new_chdr(:,last_col+1:last_col+num_new_col) = csdm_chdr(:,6:5+num_new_col);
0043   else
0044     spec_start = 6+(obs-1)*num_new_col;
0045     spec_stop = 5 + (obs)*num_new_col;
0046     new_chdr(:,last_col+1:last_col+num_new_col) = csdm_chdr(:,spec_start:spec_stop);
0047   end
0048 end
0049 
0050 return

Generated on Sat 24-Aug-2019 04:00:39 by m2html © 2003