Home > eeg > egis > egis_file_utils > csdmhdr2avehdr.m

csdmhdr2avehdr

PURPOSE ^

function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)

SYNOPSIS ^

function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)

DESCRIPTION ^

  function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)

  Moves relevant header information from csdm header to average header

  csdmfiles -- Matrix of csdm filenames
  obs -- Observations to extract from csdm files

  Note:      In the event that there is more than one csdmfile and length(obs) > 1,
            multiple files will be written out, with one file/obs.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)
0002 %  function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)
0003 %
0004 %  Moves relevant header information from csdm header to average header
0005 %
0006 %  csdmfiles -- Matrix of csdm filenames
0007 %  obs -- Observations to extract from csdm files
0008 %
0009 %  Note:      In the event that there is more than one csdmfile and length(obs) > 1,
0010 %            multiple files will be written out, with one file/obs.
0011 
0012 %  Modification history:
0013 %  01/26/96 PJ    Started work on function
0014 
0015 %
0016 % read in a csdm header in order to make an output file header
0017 %
0018 ave_hdr_offsets_v;
0019 
0020 if nargin < 2
0021   obs = [];
0022 end
0023 
0024 csdm_fid = fopen(csdmfiles(1,:),'r');
0025 if csdm_fid == -1
0026   error(['Trouble opening file -- ' csdmfiles(1,:)])
0027 end
0028 
0029 [csdm_fhdr,csdm_chdr,ename,czeros,cgains,cnames,fcom,ftext, coff]=rd_csdm_hdr_v(csdm_fid);
0030 fclose(csdm_fid);
0031 
0032 if obs == []
0033   obs = csdm_chdr(1,NObs);
0034 end
0035 
0036 if any(obs > csdm_chdr(1,NObs))
0037     error('observation number out of range')
0038 end;
0039 
0040 ave_fhdr = csdm_fhdr;
0041 if csdm_fhdr(NChan) == 8385
0042     ave_fhdr(NChan) = 129;
0043 elseif csdm_fhdr(NChan) == 2145
0044     ave_fhdr(NChan) = 65;
0045 elseif csdm_fhdr(NChan) == 33153;
0046     ave_fhdr(NChan) = 257;
0047 else
0048     error('Nchan is unacceptable in this csdm file')
0049 end;
0050 
0051 % Copy average file subject specifics array from each input file
0052 ave_chdr = concat_csdm_chdr(csdmfiles, obs);
0053 
0054 ave_ename = ename; ave_fcom = fcom; ave_ftext = ftext;
0055 ave_cnames = cnames;
0056 
0057 ave_fhdr(LastDone) = size(csdmfiles,1);
0058 
0059 % Write the correct number of observations into new header
0060 % depending on
0061 
0062 for c = 1:csdm_fhdr(NCells)
0063   if length(obs) > 1 & size(csdmfiles,1) == 1
0064     ave_chdr(c,NObs) = length(obs);
0065   else
0066     ave_chdr(c,NObs) = size(csdmfiles,1);
0067   end
0068 end

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003