0001 function [version, NChan, NMeg, NEeg, NReference, NBad_sensor, NTrigger, NResponse, NUtility, NAnalog, Samp_Rate, NData_Epoch, Names, NSamp, trigger, response, header_length] = rd_meg_hdr(meg_fid);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if meg_fid < 1
0013 error('you passed rd_hdr_meg a bogus fid')
0014 end;
0015 frewind(meg_fid);
0016 version = fread(meg_fid,1,'integer*2');
0017 if version ~= 1
0018 error('this is not an meg data file');
0019 end
0020 NChan= fread(meg_fid,1,'integer*2');
0021 NMeg = fread(meg_fid,1,'integer*2');
0022 NEeg = fread(meg_fid,1,'integer*2');
0023 NReference = fread(meg_fid,1,'integer*2');
0024 NBad_sensor = fread(meg_fid,1,'integer*2');
0025 NTrigger = fread(meg_fid,1,'integer*2');
0026 NResponse = fread(meg_fid,1,'integer*2');
0027 NUtility = fread(meg_fid,1,'integer*2');
0028 NAnalog = fread(meg_fid,1,'integer*2');
0029 Samp_Rate = fread(meg_fid,1,'real*4');
0030 NData_Epoch = fread(meg_fid,1,'integer*2');
0031 sizenames = fread(meg_fid,1,'integer*2');
0032 Names = fread(meg_fid,[NChan,sizenames],'char*1');
0033 Names = setstr(Names);
0034 rd_hdr_length = 28 + sizenames*NChan;
0035
0036
0037 NSamp = fread(meg_fid,[1,NData_Epoch],'integer*4');
0038 rd_hdr_length = rd_hdr_length + 4*NData_Epoch;
0039
0040 trigger = fread(meg_fid,[max(NSamp),NTrigger*NData_Epoch],'real*4');
0041
0042 rd_hdr_length = rd_hdr_length + 4*max(NSamp)*NTrigger*NData_Epoch;
0043
0044 response = fread(meg_fid,[max(NSamp), NTrigger*NData_Epoch],'real*4');
0045
0046 rd_hdr_length = rd_hdr_length + 4*max(NSamp)*NResponse*NData_Epoch;
0047
0048 rd_hdr_length = rd_hdr_length + 4;
0049
0050 header_length = fread(meg_fid,1,'integer*4');
0051
0052 if rd_hdr_length ~= header_length
0053 error('header length dont match up')
0054 end;
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066