0001 function [ave_fhdr,ave_chdr,ave_ename,ave_cnames,ave_fcom,ave_ftext] = csdmhdr2avehdr(csdmfiles, obs)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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
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
0060
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