0001 function varargout = meg_hread(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 if nargin<1 | isempty(varargin{1}),
0086
0087 [fname,pname]=uigetfile('*.hd','Select Header File');
0088
0089
0090
0091
0092
0093 fid = -1;
0094 if vb_matlab_version('>=', '7.2')
0095 fid=fopen([pname fname],'r','a', 'US-ASCII');
0096 else
0097 fid=fopen([pname fname],'r','a');
0098 end
0099
0100
0101
0102
0103 H_file=meg_hread('file',fid);
0104 H_file
0105
0106 H_id=meg_hread('id',fid,H_file.i_file_size);
0107 if ~isempty(H_id),
0108 H_id
0109 end
0110
0111 H_exam=meg_hread('exam',fid,H_file.i_exam_begin);
0112 if ~isempty(H_exam),
0113 H_exam
0114 end
0115
0116 H_relat=meg_hread('relat',fid,H_file.i_relat_begin);
0117 if ~isempty(H_relat),
0118 H_relat
0119 end
0120
0121 H_disp=meg_hread('disp',fid,H_file.i_disp_begin);
0122 if ~isempty(H_disp),
0123 H_disp
0124 end
0125
0126 H_meg=meg_hread('meg',fid,H_file.i_meg_begin);
0127 if ~isempty(H_meg),
0128 H_meg
0129 end
0130 pause
0131
0132 H_eeg=meg_hread('eeg',fid,H_file.i_eeg_begin);
0133 if ~isempty(H_eeg),
0134 H_eeg
0135 end
0136
0137 H_pos=meg_hread('pos',fid,H_file.i_pos_begin);
0138 if ~isempty(H_pos),
0139 H_pos
0140 end
0141
0142 H_etc=meg_hread('etc',fid,H_file.i_etc_begin);
0143 if ~isempty(H_etc),
0144 H_etc
0145 end
0146
0147 H_mark=meg_hread('mark',fid,H_file.i_mark_begin);
0148 if ~isempty(H_mark),
0149 H_mark
0150 end
0151
0152 H_mri=meg_hread('mri',fid,H_file.i_mri_begin);
0153 if ~isempty(H_mri),
0154 H_mri
0155
0156
0157
0158 end
0159
0160 H_lcz=meg_hread('lcz',fid,H_file.i_lcz_begin);
0161 if ~isempty(H_lcz),
0162 H_lcz
0163 end
0164
0165
0166 H_meg_ch=meg_hread('meg_ch',fid,H_file.i_meg_ch_begin);
0167 if ~isempty(H_meg_ch),
0168 H_meg_ch
0169 end
0170
0171 H_eeg_ch=meg_hread('eeg_ch',fid,H_file.i_eeg_ch_begin);
0172 if ~isempty(H_eeg_ch),
0173 H_eeg_ch
0174 end
0175
0176 H_pos_coil=meg_hread('pos_coil',fid,H_file.i_pos_coil_begin);
0177 if ~isempty(H_pos_coil),
0178 H_pos_coil
0179 end
0180
0181 H_pos_rept=meg_hread('pos_rept',fid,H_file.i_pos_rept_begin);
0182 if ~isempty(H_pos_rept),
0183 H_pos_rept
0184 end
0185
0186 for i=1:H_etc.i_nch
0187 str=sprintf('%d/%d',i,H_etc.i_nch);
0188 disp(str);
0189 H_etc_ch=meg_hread('etc_ch',fid,H_file.i_etc_ch_begin+H_file.i_etc_ch_size*(i-1));
0190 if ~isempty(H_etc_ch),
0191 H_etc_ch
0192 end
0193 pause
0194 end
0195
0196 H_mark_each=meg_hread('mark_each',fid,H_file.i_mark_each_begin);
0197 if ~isempty(H_mark_each),
0198 H_mark_each
0199 end
0200
0201 H_mri_each=meg_hread('mri_each',fid,H_file.i_mri_each_begin);
0202 if ~isempty(H_mri_each),
0203 H_mri_each
0204 end
0205
0206 H_lcz_each=meg_hread('lcz_each',fid,H_file.i_lcz_each_begin);
0207 if ~isempty(H_lcz_each),
0208 H_lcz_each
0209 end
0210
0211 H_div=meg_hread('div',fid,H_file.i_div_begin);
0212 if ~isempty(H_div),
0213 H_div
0214 end
0215
0216 for i=1:H_div.i_ndiv
0217 str=sprintf('%d/%d',i,H_div.i_ndiv);
0218 disp(str);
0219 H_div_each=meg_hread('div_each',fid,H_file.i_div_ch_begin+H_file.i_div_ch_size*(i-1));
0220 if ~isempty(H_div_each),
0221 H_div_each
0222 end
0223 end
0224
0225 fclose(fid)
0226 return
0227 end
0228
0229
0230 switch varargin{1}
0231
0232 case {'meg_ch_name', 'meg_ch_gain', 'meg_ch_TV', 'meg_ch_lock', 'meg_ch_del'}
0233
0234 if nargin ~=2
0235 [fname_h,pname_h]=uigetfile('*.hd','Select Header File');
0236 fn_h=[pname_h fname_h];
0237 else
0238 fn_h=varargin{2};
0239 end
0240 fid=fopen(fn_h,'r','l');
0241 if fid==-1, disp('Cannot open the file');varargout={[]}; end;
0242 H_file=meg_hread('file',fid);
0243 H_meg=meg_hread('meg',fid,H_file.i_meg_begin);
0244
0245 if ~isempty(H_meg),
0246 nch=H_meg.i_nch;
0247 for i=1:nch,
0248 H_meg_ch=meg_hread('meg_ch',fid,H_file.i_meg_ch_begin+H_file.i_meg_ch_size*(i-1));
0249 switch varargin{1}
0250 case {'meg_ch_name'}
0251 ss{i}=H_meg_ch.c_ch_name;
0252 case {'meg_ch_gain'}
0253 ss{i}=H_meg_ch.f_amp_gain;
0254 case {'meg_ch_TV'}
0255 ss{i}=H_meg_ch.f_phy_v_coef;
0256 case {'meg_ch_lock'}
0257 ss{i}=H_meg_ch.i_meg_lock;
0258 case {'meg_ch_del'}
0259 ss{i}=H_meg_ch.i_meg_del;
0260 end
0261 end
0262 else
0263 chnm={''};
0264 end
0265 fclose(fid);
0266 varargout={ss};
0267
0268
0269
0270
0271
0272 case {'file'}
0273
0274 if isempty(varargin{1}) | isempty(varargin{2})
0275 varargout={[]};
0276 return;
0277 end
0278 fid=varargin{2};
0279
0280
0281
0282 fseek(fid,0,'bof');
0283 Head_file.c_rev = mysetstr(fread(fid,8,'char'))';
0284 Head_file.i_file_size = fread(fid,1,'int32');
0285 Head_file.i_id_size = fread(fid,1,'int32');
0286 Head_file.i_exam_begin = fread(fid,1,'int32');
0287 Head_file.i_exam_size = fread(fid,1,'int32');
0288 Head_file.i_relat_begin = fread(fid,1,'int32');
0289 Head_file.i_relat_size = fread(fid,1,'int32');
0290 Head_file.i_disp_begin = fread(fid,1,'int32');
0291 Head_file.i_disp_size = fread(fid,1,'int32');
0292 Head_file.i_meg_begin = fread(fid,1,'int32');
0293 Head_file.i_meg_size = fread(fid,1,'int32');
0294
0295 Head_file.i_eeg_begin = fread(fid,1,'int32');
0296 Head_file.i_eeg_size = fread(fid,1,'int32');
0297 Head_file.i_pos_begin = fread(fid,1,'int32');
0298 Head_file.i_pos_size = fread(fid,1,'int32');
0299 Head_file.i_etc_begin = fread(fid,1,'int32');
0300 Head_file.i_etc_size = fread(fid,1,'int32');
0301
0302 Head_file.i_mark_begin = fread(fid,1,'int32');
0303 Head_file.i_mark_size = fread(fid,1,'int32');
0304 Head_file.i_lcz_begin = fread(fid,1,'int32');
0305 Head_file.i_lcz_size = fread(fid,1,'int32');
0306
0307 Head_file.i_mri_begin = fread(fid,1,'int32');
0308 Head_file.i_mri_size = fread(fid,1,'int32');
0309 Head_file.i_meg_ch_begin = fread(fid,1,'int32');
0310 Head_file.i_meg_ch_size = fread(fid,1,'int32');
0311 Head_file.i_eeg_ch_begin = fread(fid,1,'int32');
0312 Head_file.i_eeg_ch_size = fread(fid,1,'int32');
0313 Head_file.i_pos_coil_begin = fread(fid,1,'int32');
0314 Head_file.i_pos_coil_size = fread(fid,1,'int32');
0315 Head_file.i_pos_rept_begin = fread(fid,1,'int32');
0316 Head_file.i_pos_rept_size = fread(fid,1,'int32');
0317 Head_file.i_etc_ch_begin = fread(fid,1,'int32');
0318 Head_file.i_etc_ch_size = fread(fid,1,'int32');
0319 Head_file.i_mark_each_begin = fread(fid,1,'int32');
0320 Head_file.i_mark_each_size = fread(fid,1,'int32');
0321 Head_file.i_lcz_each_begin = fread(fid,1,'int32');
0322 Head_file.i_lcz_each_size = fread(fid,1,'int32');
0323 Head_file.i_mri_each_begin = fread(fid,1,'int32');
0324 Head_file.i_mri_each_size = fread(fid,1,'int32');
0325 Head_file.c_meg_sysid = mysetstr(fread(fid,8,'char'))';
0326 Head_file.c_root_meg_sysid = mysetstr(fread(fid,8,'char'))';
0327 Head_file.c_old_meg_sysid = mysetstr(fread(fid,128,'char'))';
0328 Head_file.i_div_begin = fread(fid,1,'int32');
0329 Head_file.i_div_size = fread(fid,1,'int32');
0330
0331 Head_file.i_div_ch_begin = fread(fid,1,'int32');
0332 Head_file.i_div_ch_size = fread(fid,1,'int32');
0333
0334 varargout={Head_file};
0335
0336 case {'id'}
0337
0338 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0339 varargout={[]};
0340 return;
0341 end
0342 fid=varargin{2};
0343 offset=varargin{3};
0344 if offset<=0,varargout={[]};return,end;
0345
0346
0347 fseek(fid,offset,'bof');
0348 Head_id.c_date = mysetstr(fread(fid,12,'char'))';
0349 Head_id.c_time = mysetstr(fread(fid,10,'char'))';
0350 Head_id.c_type = mysetstr(fread(fid,64,'char'))';
0351
0352 Head_id.c_history = mysetstr(fread(fid,1024,'char'))';
0353
0354
0355
0356
0357 Head_id.c_hospital = mysetstr(fread(fid,18,'char'))';
0358 Head_id.c_docter = mysetstr(fread(fid,16,'char'))';
0359 Head_id.c_operator = mysetstr(fread(fid,16,'char'))';
0360 Head_id.i_procedure = fread(fid,1,'int32');
0361 Head_id.c_proc_name = mysetstr(fread(fid,32,'char'))';
0362 Head_id.i_protocol = fread(fid,1,'int32');
0363 Head_id.c_prot_name = mysetstr(fread(fid,32,'char'))';
0364 Head_id.c_prot_tyep = mysetstr(fread(fid,32,'char'))';
0365
0366 varargout={Head_id};
0367
0368 case {'exam'}
0369
0370 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0371 varargout={};
0372 return;
0373 end
0374 fid=varargin{2};
0375 offset=varargin{3};
0376 if offset<=0,varargout={[]};return,end;
0377
0378 fseek(fid,offset,'bof');
0379 Head_exam.c_patient = mysetstr(fread(fid,16,'char'))';
0380 Head_exam.c_id = mysetstr(fread(fid,12,'char'))';
0381 Head_exam.c_birth = mysetstr(fread(fid,12,'char'))';
0382 Head_exam.c_sex = mysetstr(fread(fid,2,'char'))';
0383 Head_exam.c_age = mysetstr(fread(fid,16,'char'))';
0384 Head_exam.c_comment = mysetstr(fread(fid,512,'char'))';
0385 Head_exam.c_comment2 = mysetstr(fread(fid,64,'char'))';
0386 Head_exam.c_comment3 = mysetstr(fread(fid,64,'char'))';
0387
0388 varargout={Head_exam};
0389
0390 case {'relat'}
0391
0392 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0393 varargout={};
0394 return;
0395 end
0396 fid=varargin{2};
0397 offset=varargin{3};
0398 if offset<=0,varargout={[]};return,end;
0399
0400 fseek(fid,offset,'bof');
0401 Head_relat.c_part = mysetstr(fread(fid,10,'char'))';
0402 Head_relat.c_region = mysetstr(fread(fid,10,'char'))';
0403
0404 Head_relat.c_object = mysetstr(fread(fid,10,'char'))';
0405
0406
0407
0408 Head_relat.c_comment = mysetstr(fread(fid,512,'char'))';
0409 Head_relat.c_comment2 = mysetstr(fread(fid,64,'char'))';
0410 Head_relat.c_comment3 = mysetstr(fread(fid,64,'char'))';
0411 Head_relat.c_comment4 = mysetstr(fread(fid,64,'char'))';
0412 Head_relat.c_comment5 = mysetstr(fread(fid,64,'char'))';
0413
0414 varargout={Head_relat};
0415
0416 case {'disp'}
0417
0418 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0419 varargout={};
0420 return;
0421 end
0422 fid=varargin{2};
0423 offset=varargin{3};
0424 if offset<=0,varargout={[]};return,end;
0425
0426 fseek(fid,offset,'bof');
0427 Head_disp.c_orient_x = mysetstr(fread(fid,4,'char'))';
0428 Head_disp.c_orient_y = mysetstr(fread(fid,4,'char'))';
0429 Head_disp.i_mode = fread(fid,1,'int32');
0430 Head_disp.i_meg_max = fread(fid,1,'int32');
0431 Head_disp.i_meg_min = fread(fid,1,'int32');
0432 Head_disp.i_eeg_max = fread(fid,1,'int32');
0433 Head_disp.i_eeg_min = fread(fid,1,'int32');
0434
0435 varargout={Head_disp};
0436
0437 case {'meg'}
0438
0439 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0440 varargout={};
0441 return;
0442 end
0443 fid=varargin{2};
0444 offset=varargin{3};
0445 if offset<=0,varargout={[]};return,end;
0446
0447 fseek(fid,offset,'bof');
0448 Head_meg.c_model = mysetstr(fread(fid,20,'char'))';
0449 Head_meg.c_serial_id = mysetstr(fread(fid,20,'char'))';
0450 Head_meg.c_sw_rev = mysetstr(fread(fid,8,'char'))';
0451 Head_meg.i_nch = fread(fid,1,'int32');
0452 Head_meg.i_nrept = fread(fid,1,'int32');
0453 Head_meg.i_nwave = fread(fid,1,'int32');
0454 Head_meg.i_nave = fread(fid,1,'int32');
0455 Head_meg.c_ave_mode = mysetstr(fread(fid,20,'char'))';
0456 Head_meg.i_offset_start = fread(fid,1,'int32');
0457 Head_meg.i_offset_end = fread(fid,1,'int32');
0458 Head_meg.f_lev_reject = fread(fid,1,'float');
0459 Head_meg.i_nsample = fread(fid,1,'int32');
0460 Head_meg.i_nprsample = fread(fid,1,'int32');
0461 Head_meg.i_samp_freq = fread(fid,1,'int32');
0462 Head_meg.f_ad_weight = fread(fid,1,'float');
0463 Head_meg.i_block = fread(fid,1,'int32');
0464 Head_meg.i_flag_begin = fread(fid,1,'int32');
0465 Head_meg.i_flag_size = fread(fid,1,'int32');
0466
0467 Head_meg.i_bal_cancel = fread(fid,1,'int32');
0468 Head_meg.i_ns_reduse = fread(fid,1,'int32');
0469 Head_meg.c_lev_rej_kind = mysetstr(fread(fid,20,'char'))';
0470 Head_meg.c_offset_kind = mysetstr(fread(fid,20,'char'))';
0471 Head_meg.i_del_nch = fread(fid,1,'int32');
0472 Head_meg.i_acq_nsamp = fread(fid,1,'int32');
0473 Head_meg.i_acq_nprsamp = fread(fid,1,'int32');
0474
0475 Head_meg.c_acq_offset_mod = mysetstr(fread(fid,20,'char'))';
0476 Head_meg.i_acq_offset_str = fread(fid,1,'int32');
0477 Head_meg.i_acq_offset_end = fread(fid,1,'int32');
0478 Head_meg.f_acq_lev_rej = fread(fid,1,'float');
0479 Head_meg.c_acq_ave_mode = mysetstr(fread(fid,20,'char'))';
0480 Head_meg.f_lev_rej_p = fread(fid,1,'float');
0481 Head_meg.f_lev_rej_m = fread(fid,1,'float');
0482 Head_meg.f_lev_rej_pp = fread(fid,1,'float');
0483 Head_meg.c_station_id = mysetstr(fread(fid,32,'char'))';
0484 Head_meg.i_lev_rej_p = fread(fid,1,'int32');
0485 Head_meg.i_lev_rej_m = fread(fid,1,'int32');
0486 Head_meg.i_lev_rej_pp = fread(fid,1,'int32');
0487 Head_meg.i_acq_lev_rej_p = fread(fid,1,'int32');
0488 Head_meg.i_acq_lev_rej_m = fread(fid,1,'int32');
0489 Head_meg.i_acq_lev_rej_pp = fread(fid,1,'int32');
0490 Head_meg.f_acq_lev_rej_p = fread(fid,1,'float');
0491 Head_meg.f_acq_lev_rej_m = fread(fid,1,'float');
0492 Head_meg.f_acq_lev_rej_pp = fread(fid,1,'float');
0493 Head_meg.c_trg_mode = mysetstr(fread(fid,64,'char'))';
0494
0495 varargout={Head_meg};
0496
0497 case {'eeg'}
0498
0499 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0500 varargout={};
0501 return;
0502 end
0503 fid=varargin{2};
0504 offset=varargin{3};
0505 if offset<=0,varargout={[]};return,end;
0506
0507 fseek(fid,offset,'bof');
0508 Head_eeg.c_model = mysetstr(fread(fid,20,'char'))';
0509 Head_eeg.c_serial_id = mysetstr(fread(fid,20,'char'))';
0510 Head_eeg.c_sw_rev = mysetstr(fread(fid,8,'char'))';
0511
0512 Head_eeg.i_nch = fread(fid,1,'int32');
0513 Head_eeg.i_nrept = fread(fid,1,'int32');
0514 Head_eeg.i_nwave = fread(fid,1,'int32');
0515 Head_eeg.i_nave = fread(fid,1,'int32');
0516 Head_eeg.c_ave_mode = mysetstr(fread(fid,20,'char'));
0517 Head_eeg.i_offset_start = fread(fid,1,'int32');
0518 Head_eeg.i_offset_end = fread(fid,1,'int32');
0519 Head_eeg.f_ave_cut = fread(fid,1,'float');
0520 Head_eeg.i_nsample = fread(fid,1,'int32');
0521 Head_eeg.i_nprsample = fread(fid,1,'int32');
0522 Head_eeg.i_samp_freq = fread(fid,1,'int32');
0523 Head_eeg.f_ad_weight = fread(fid,1,'float');
0524 Head_eeg.c_induct = mysetstr(fread(fid,10,'char'));
0525
0526 Head_eeg.c_base = mysetstr(fread(fid,10,'char'));
0527 Head_eeg.c_mode = mysetstr(fread(fid,10,'char'));
0528
0529 Head_eeg.i_block = fread(fid,1,'int32');
0530 Head_eeg.i_flag_begin = fread(fid,1,'int32');
0531 Head_eeg.i_flag_size = fread(fid,1,'int32');
0532
0533 Head_eeg.c_offset_kind = mysetstr(fread(fid,20,'char'))';
0534 Head_eeg.i_del_nch = fread(fid,1,'int32');
0535 Head_eeg.i_org_nsamp = fread(fid,1,'int32');
0536 Head_eeg.i_org_nprsamp = fread(fid,1,'int32');
0537
0538 Head_eeg.c_acq_ave_mode = mysetstr(fread(fid,20,'char'))';
0539
0540 varargout={Head_eeg};
0541
0542 case {'pos'}
0543
0544 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0545 varargout={};
0546 return;
0547 end
0548 fid=varargin{2};
0549 offset=varargin{3};
0550 if offset<=0,varargout={[]};return,end;
0551
0552 fseek(fid,offset,'bof');
0553 Head_pos.i_nch = fread(fid,1,'int32');
0554 Head_pos.i_nrept = fread(fid,1,'int32');
0555 Head_pos.i_ncoil = fread(fid,1,'int32');
0556 Head_pos.i_nsample = fread(fid,1,'int32');
0557 Head_pos.i_samp_freq = fread(fid,1,'int32');
0558 Head_pos.f_ad_weight = fread(fid,1,'float');
0559 Head_pos.i_block = fread(fid,1,'int32');
0560 Head_pos.i_flag_begin = fread(fid,1,'int32');
0561 Head_pos.i_flag_size = fread(fid,1,'int32');
0562 Head_pos.i_fft_begin = fread(fid,1,'int32');
0563 Head_pos.i_fft_block = fread(fid,1,'int32');
0564
0565 varargout={Head_pos};
0566
0567 case {'etc'}
0568
0569 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0570 varargout={};
0571 return;
0572 end
0573 fid=varargin{2};
0574 offset=varargin{3};
0575 if offset<=0,varargout={[]};return,end;
0576
0577 fseek(fid,offset,'bof');
0578 Head_etc.i_nch = fread(fid,1,'int32');
0579 Head_etc.i_flag_begin = fread(fid,1,'int32');
0580 Head_etc.i_flag_size = fread(fid,1,'int32');
0581 Head_etc.i_del_nch = fread(fid,1,'int32');
0582 Head_etc.i_nsample = fread(fid,1,'int32');
0583 Head_etc.i_nprsample = fread(fid,1,'int32');
0584 Head_etc.i_samp_freq = fread(fid,1,'int32');
0585 Head_etc.f_ad_weight = fread(fid,1,'float');
0586 Head_etc.i_org_nsamp = fread(fid,1,'int32');
0587 Head_etc.i_org_nprsamp = fread(fid,1,'int32');
0588
0589 Head_etc.c_acq_ave_mode = mysetstr(fread(fid,20,'char'))';
0590 Head_etc.i_data_begin = fread(fid,1,'int32');
0591 Head_etc.i_data_size = fread(fid,1,'int32');
0592
0593 varargout={Head_etc};
0594
0595 case {'mark'}
0596
0597 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0598 varargout={};
0599 return;
0600 end
0601 fid=varargin{2};
0602 offset=varargin{3};
0603 if offset<=0,varargout={[]};return,end;
0604
0605 fseek(fid,offset,'bof');
0606 Head_mark.i_nmark = fread(fid,1,'int32');
0607
0608 varargout={Head_mark};
0609
0610 case {'mri'}
0611
0612 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0613 varargout={};
0614 return;
0615 end
0616 fid=varargin{2};
0617 offset=varargin{3};
0618 if offset<=0,varargout={[]};return,end;
0619
0620 fseek(fid,offset,'bof');
0621 Head_mri.i_nfile = fread(fid,1,'int32');
0622 nmri=4;
0623 Head_mri.st_axes=zeros(nmri,3);
0624 for i=1:nmri
0625 Head_mri.st_axes(i,:) = fread(fid,3,'float')';
0626
0627 end
0628 Head_mri.c_sysid=cell(nmri);
0629 for i=1:nmri
0630 Head_mri.c_sysid{i} = mysetstr(fread(fid,8,'char'))';
0631 end
0632 Head_mri.c_format = mysetstr(fread(fid,16,'char'))';
0633 Head_mri.c_endian = mysetstr(fread(fid,16,'char'))';
0634
0635 varargout={Head_mri};
0636
0637 case {'lcz'}
0638
0639 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0640 varargout={};
0641 return;
0642 end
0643 fid=varargin{2};
0644 offset=varargin{3};
0645 if offset<=0,varargout={[]};return,end;
0646
0647 fseek(fid,offset,'bof');
0648 Head_lcz.f_model_r = fread(fid,1,'float');
0649 Head_lcz.st_model = fread(fid,3,'float');
0650 Head_lcz.i_latency = fread(fid,1,'int32');
0651 Head_lcz.i_nrezult = fread(fid,1,'int32');
0652 Head_lcz.c_outline = mysetstr(fread(fid,20,'char'))';
0653 Head_lcz.c_weight = mysetstr(fread(fid,20,'char'))';
0654 Head_lcz.i_level = fread(fid,1,'int32');
0655 Head_lcz.i_width = fread(fid,1,'int32');
0656 Head_lcz.c_imagedir = mysetstr(fread(fid,8,'char'))';
0657 Head_lcz.st_sf_focus = fread(fid,3,'float');
0658
0659 varargout={Head_lcz};
0660
0661 case {'meg_ch'}
0662
0663 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0664 varargout={};
0665 return;
0666 end
0667 fid=varargin{2};
0668 offset=varargin{3};
0669 if offset<=0,varargout={[]};return,end;
0670
0671
0672 fseek(fid,offset,'bof');
0673 Head_meg_ch.c_ch_name = mysetstr(fread(fid,8,'char'))';
0674 Head_meg_ch.f_amp_gain = fread(fid,1,'float');
0675 Head_meg_ch.f_fll_amp = fread(fid,1,'float');
0676 Head_meg_ch.f_hpf_amp = fread(fid,1,'float');
0677 Head_meg_ch.f_lpf_amp = fread(fid,1,'float');
0678 Head_meg_ch.f_notch_amp = fread(fid,1,'float');
0679 Head_meg_ch.f_lpf_cut = fread(fid,1,'float');
0680 Head_meg_ch.f_hpf_cut = fread(fid,1,'float');
0681 Head_meg_ch.f_notch_cut = fread(fid,1,'float');
0682 Head_meg_ch.f_dlpf_cut = fread(fid,1,'float');
0683 Head_meg_ch.f_dhpf_cut = fread(fid,1,'float');
0684 Head_meg_ch.f_dnotch_cut = fread(fid,1,'float');
0685 Head_meg_ch.i_df_order = fread(fid,1,'int32');
0686 Head_meg_ch.c_df_kind = mysetstr(fread(fid,20,'char'))';
0687 Head_meg_ch.f_squid_biasi = fread(fid,1,'float');
0688 Head_meg_ch.f_squid_v_phy = fread(fid,1,'float');
0689 Head_meg_ch.f_squid_biasv = fread(fid,1,'float');
0690
0691 Head_meg_ch.f_offset_volt = fread(fid,1,'float');
0692 Head_meg_ch.i_pick_type = fread(fid,1,'int32');
0693
0694
0695
0696
0697 Head_meg_ch.i_pick_shape = fread(fid,1,'int32');
0698 Head_meg_ch.f_pick_radius1 = fread(fid,1,'float');
0699 Head_meg_ch.f_pick_radius2 = fread(fid,1,'float');
0700 Head_meg_ch.f_pick_base = fread(fid,1,'float');
0701 Head_meg_ch.f_phy_v_coef = fread(fid,1,'float');
0702 Head_meg_ch.st_dcp = fread(fid,3,'float');
0703 Head_meg_ch.st_dca = fread(fid,3,'float');
0704 Head_meg_ch.st_ccp = fread(fid,3,'float');
0705 Head_meg_ch.st_cca = fread(fid,3,'float');
0706 Head_meg_ch.f_coil_balance1 = fread(fid,1,'float');
0707 Head_meg_ch.f_coil_balance1 = fread(fid,1,'float');
0708 Head_meg_ch.f_coil_balance1 = fread(fid,1,'float');
0709 Head_meg_ch.f_calb_good = fread(fid,1,'float');
0710 Head_meg_ch.f_calb_gamma = fread(fid,1,'float');
0711 Head_meg_ch.i_meg_lock = fread(fid,1,'int32');
0712 Head_meg_ch.i_pos_act = fread(fid,1,'int32');
0713 Head_meg_ch.i_meg_del = fread(fid,1,'int32');
0714 Head_meg_ch.i_ad_ch_no = fread(fid,1,'int32');
0715 Head_meg_ch.i_fll_ch_no = fread(fid,1,'int32');
0716 Head_meg_ch.f_pos_amp_gain = fread(fid,1,'float');
0717 Head_meg_ch.f_pos_fll_amp = fread(fid,1,'float');
0718 Head_meg_ch.f_pos_hpf_amp = fread(fid,1,'float');
0719 Head_meg_ch.f_pos_lpf_amp = fread(fid,1,'float');
0720 Head_meg_ch.f_pos_notch_amp = fread(fid,1,'float');
0721 Head_meg_ch.f_pos_lpf_cut = fread(fid,1,'float');
0722 Head_meg_ch.f_pos_hpf_cut = fread(fid,1,'float');
0723 Head_meg_ch.f_pos_notch_cut = fread(fid,1,'float');
0724 Head_meg_ch.f_squid_phy = fread(fid,1,'float');
0725 Head_meg_ch.f_org_dlpf_cut = fread(fid,1,'float');
0726 Head_meg_ch.f_org_dhpf_cut = fread(fid,1,'float');
0727 Head_meg_ch.f_org_dnotch_cut = fread(fid,1,'float');
0728 Head_meg_ch.c_acq_df_cut = mysetstr(fread(fid,512,'char'))';
0729 Head_meg_ch.c_acq_df_pass = mysetstr(fread(fid,512,'char'))';
0730 Head_meg_ch.i_acq_df_order = fread(fid,1,'int32');
0731 Head_meg_ch.c_acq_df_kind = mysetstr(fread(fid,20,'char'))';
0732 Head_meg_ch.c_df_cut = mysetstr(fread(fid,512,'char'))';
0733 Head_meg_ch.c_df_pass = mysetstr(fread(fid,512,'char'))';
0734 Head_meg_ch.f_bala1 = fread(fid,10,'float');
0735 Head_meg_ch.f_bala2 = fread(fid,10,'float');
0736 Head_meg_ch.f_bala3 = fread(fid,10,'float');
0737 Head_meg_ch.f_bala4 = fread(fid,10,'float');
0738 Head_meg_ch.f_squid_offset = fread(fid,1,'float');
0739
0740 varargout={Head_meg_ch};
0741
0742 case {'eeg_ch'}
0743
0744 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0745 varargout={};
0746 return;
0747 end
0748 fid=varargin{2};
0749 offset=varargin{3};
0750 if offset<=0,varargout={[]};return,end;
0751
0752 fseek(fid,offset,'bof');
0753 Head_eeg_ch.c_eeg_kind = mysetstr(fread(fid,10,'char'))';
0754
0755 Head_eeg_ch.c_ch_name = mysetstr(fread(fid,10,'char'))';
0756 Head_eeg_ch.f_amp_sence = fread(fid,1,'float');
0757 Head_eeg_ch.f_hpf_cut = fread(fid,1,'float');
0758 Head_eeg_ch.f_lpf_cut = fread(fid,1,'float');
0759 Head_eeg_ch.f_notch_cut = fread(fid,1,'float');
0760 Head_eeg_ch.c_special_cut = mysetstr(fread(fid,4,'char'))';
0761 Head_eeg_ch.st_ch_xyz = fread(fid,3,'float');
0762 Head_eeg_ch.i_eeg_lock = fread(fid,1,'int32');
0763 Head_eeg_ch.i_eeg_del = fread(fid,1,'int32');
0764 Head_eeg_ch.i_ad_ch_no = fread(fid,1,'int32');
0765 Head_eeg_ch.i_ser_ch_no = fread(fid,1,'int32');
0766 Head_eeg_ch.i_acq_lev_rej_p = fread(fid,1,'int32');
0767 Head_eeg_ch.i_acq_lev_rej_m = fread(fid,1,'int32');
0768 Head_eeg_ch.i_acq_lev_rej_pp = fread(fid,1,'int32');
0769 Head_eeg_ch.f_acq_lev_rej_p = fread(fid,1,'float');
0770 Head_eeg_ch.f_acq_lev_rej_m = fread(fid,1,'float');
0771 Head_eeg_ch.f_acq_lev_rej_pp = fread(fid,1,'float');
0772
0773 varargout={Head_eeg_ch};
0774
0775 case {'pos_coil'}
0776
0777 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0778 varargout={};
0779 return;
0780 end
0781 fid=varargin{2};
0782 offset=varargin{3};
0783 if offset<=0,varargout={[]};return,end;
0784
0785 fseek(fid,offset,'bof');
0786 Head_pos_coil.c_name = mysetstr(fread(fid,10,'char'))';
0787 Head_pos_coil.f_diameter = fread(fid,1,'float');
0788 Head_pos_coil.f_cur = fread(fid,1,'float');
0789
0790 Head_pos_coil.f_freq = fread(fid,1,'float');
0791 Head_pos_coil.i_turn = fread(fid,1,'int32');
0792 Head_pos_coil.i_array = fread(fid,1,'int32');
0793 Head_pos_coil.f_pitch1 = fread(fid,1,'float');
0794 Head_pos_coil.f_pitch2 = fread(fid,1,'float');
0795 Head_pos_coil.i_ad_ch_no = fread(fid,1,'int32');
0796 Head_pos_coil.i_para_ch_no = fread(fid,1,'int32');
0797 Head_pos_coil.c_vvd_sysid = mysetstr(fread(fid,8,'char'))';
0798 Head_pos_coil.c_mri_sysid = mysetstr(fread(fid,8,'char'))';
0799 Head_pos_coil.st_vvd_orign = fread(fid,3,'float');
0800 Head_pos_coil.st_vvd_eular = fread(fid,3,'float');
0801 Head_pos_coil.st_vvd_xyz = fread(fid,3,'float');
0802
0803 varargout={Head_pos_coil};
0804
0805 case {'pos_rept'}
0806
0807 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0808 varargout={};
0809 return;
0810 end
0811 fid=varargin{2};
0812 offset=varargin{3};
0813 if offset<=0,varargout={[]};return,end;
0814
0815 fseek(fid,offset,'bof');
0816 Head_pos_rept.i_meg_rept = fread(fid,1,'int32');
0817 Head_pos_rept.i_data_begin = fread(fid,1,'int32');
0818
0819 varargout={Head_pos_rept};
0820
0821 case {'etc_ch'}
0822
0823 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0824 varargout={};
0825 return;
0826 end
0827 fid=varargin{2};
0828 offset=varargin{3};
0829 if offset<=0,varargout={[]};return,end;
0830
0831 fseek(fid,offset,'bof');
0832 Head_etc_ch.c_kind = mysetstr(fread(fid,10,'char'))';
0833 Head_etc_ch.c_model = mysetstr(fread(fid,20,'char'))';
0834 Head_etc_ch.c_serial_id = mysetstr(fread(fid,20,'char'))';
0835 Head_etc_ch.c_sw_rev = mysetstr(fread(fid,8,'char'))';
0836 Head_etc_ch.c_ch_name = mysetstr(fread(fid,6,'char'))';
0837 Head_etc_ch.c_part = mysetstr(fread(fid,20,'char'))';
0838 Head_etc_ch.i_nrept = fread(fid,1,'int32');
0839 Head_etc_ch.i_nwave = fread(fid,1,'int32');
0840 Head_etc_ch.i_nave = fread(fid,1,'int32');
0841 Head_etc_ch.c_ave_mode = mysetstr(fread(fid,20,'char'))';
0842 Head_etc_ch.i_offset_start = fread(fid,1,'int32');
0843 Head_etc_ch.i_offset_end = fread(fid,1,'int32');
0844 Head_etc_ch.f_ave_cut = fread(fid,1,'float');
0845 Head_etc_ch.i_nsample = fread(fid,1,'int32');
0846 Head_etc_ch.i_nprsample = fread(fid,1,'int32');
0847 Head_etc_ch.i_samp_freq = fread(fid,1,'int32');
0848 Head_etc_ch.f_ad_weight = fread(fid,1,'float');
0849 Head_etc_ch.f_amp_gain = fread(fid,1,'float');
0850 Head_etc_ch.i_data_begin = fread(fid,1,'int32');
0851 Head_etc_ch.i_block_size = fread(fid,1,'int32');
0852 Head_etc_ch.f_aud_rate = fread(fid,1,'float');
0853 Head_etc_ch.f_aud_freq = fread(fid,1,'float');
0854 Head_etc_ch.f_aud_rise_fall = fread(fid,1,'float');
0855 Head_etc_ch.f_aud_plateau = fread(fid,1,'float');
0856 Head_etc_ch.c_aud_random = mysetstr(fread(fid,4,'char'))';
0857 Head_etc_ch.c_aud_click = mysetstr(fread(fid,4,'char'))';
0858 Head_etc_ch.c_aud_burst = mysetstr(fread(fid,4,'char'))';
0859 Head_etc_ch.c_aud_cont = mysetstr(fread(fid,4,'char'))';
0860 Head_etc_ch.c_aud_phase = mysetstr(fread(fid,4,'char'))';
0861 Head_etc_ch.f_aud_intensity = fread(fid,1,'float');
0862 Head_etc_ch.f_aud_masking = fread(fid,1,'float');
0863 Head_etc_ch.c_aud_mask_sw = mysetstr(fread(fid,4,'char'))';
0864 Head_etc_ch.c_aud_headphone = mysetstr(fread(fid,4,'char'))';
0865 Head_etc_ch.c_som_mode = mysetstr(fread(fid,20,'char'))';
0866
0867 Head_etc_ch.f_som_rate = fread(fid,1,'float');
0868 Head_etc_ch.f_som_delay = fread(fid,1,'float');
0869 Head_etc_ch.f_som_delay_range = fread(fid,1,'float');
0870 Head_etc_ch.f_som_duration = fread(fid,1,'float');
0871 Head_etc_ch.c_som_train_mode = mysetstr(fread(fid,4,'char'))';
0872 Head_etc_ch.f_som_train = fread(fid,1,'float');
0873 Head_etc_ch.i_som_post_n = fread(fid,1,'int32');
0874 Head_etc_ch.f_som_post_int = fread(fid,1,'float');
0875 Head_etc_ch.c_som_cur_sw = mysetstr(fread(fid,4,'char'))';
0876 Head_etc_ch.c_som_volt_sw = mysetstr(fread(fid,4,'char'))';
0877 Head_etc_ch.f_som_fine = fread(fid,1,'float');
0878 Head_etc_ch.i_ad_ch_no = fread(fid,1,'int32');
0879 Head_etc_ch.i_ser_ch_no = fread(fid,1,'int32');
0880 Head_etc_ch.f_trig_interval = fread(fid,1,'float');
0881 Head_etc_ch.f_trig_random = fread(fid,1,'float');
0882 Head_etc_ch.f_trig_freq = fread(fid,1,'float');
0883 Head_etc_ch.f_trig_delay = fread(fid,1,'float');
0884 Head_etc_ch.f_di_start = fread(fid,1,'float');
0885 Head_etc_ch.f_di_end = fread(fid,1,'float');
0886 Head_etc_ch.i_di_on = fread(fid,1,'int32');
0887 Head_etc_ch.i_etc_lock = fread(fid,1,'int32');
0888
0889 varargout={Head_etc_ch};
0890
0891 case {'mark_each'}
0892
0893 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0894 varargout={};
0895 return;
0896 end
0897 fid=varargin{2};
0898 offset=varargin{3};
0899 if offset<=0,varargout={[]};return,end;
0900
0901 fseek(fid,offset,'bof');
0902 Head_mark_each.c_kind = mysetstr(fread(fid,10,'char'))';
0903 Head_mark_each.i_rept_no = fread(fid,1,'int32');
0904 Head_mark_each.i_sample_no = fread(fid,1,'int32');
0905
0906 varargout={Head_mark_each};
0907
0908 case {'mri_each'}
0909
0910 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0911 varargout={};
0912 return;
0913 end
0914 fid=varargin{2};
0915 offset=varargin{3};
0916 if offset<=0,varargout={[]};return,end;
0917
0918 fseek(fid,offset,'bof');
0919 Head_mri_each.c_sysid = mysetstr(fread(fid,8,'char'))';
0920 Head_mri_each.i_kind = fread(fid,1,'int32');
0921
0922
0923 varargout={Head_mri_each};
0924
0925 case {'lcz_each'}
0926
0927 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0928 varargout={};
0929 return;
0930 end
0931 fid=varargin{2};
0932 offset=varargin{3};
0933 if offset<=0,varargout={[]};return,end;
0934
0935 fseek(fid,offset,'bof');
0936 Head_lcz_each.c_date = mysetstr(fread(fid,12,'char'))';
0937 Head_lcz_each.c_time = mysetstr(fread(fid,10,'char'))';
0938 Head_lcz_each.i_rept_no = fread(fid,1,'int32');
0939 Head_lcz_each.i_sample_no = fread(fid,1,'int32');
0940 Head_lcz_each.c_lcz_mode = mysetstr(fread(fid,20,'char'))';
0941
0942
0943 Head_lcz_each.c_comment = mysetstr(fread(fid,512,'char'))';
0944 Head_lcz_each.st_pos_cp=zeros(5,3);
0945 for i=1:5
0946 Head_lcz_each.st_pos_cp(i,:) = fread(fid,3,'float')';
0947 end
0948 Head_lcz_each.st_pos_cazeros(5,3);
0949 for i=1:5
0950 Head_lcz_each.st_pos_ca(i,:) = fread(fid,3,'float')';
0951 end
0952 Head_lcz_each.f_pos_good=zeros(5,3);
0953 for i=1:5
0954 Head_lcz_each.f_pos_good(i) = fread(fid,1,'float');
0955 end
0956 Head_lcz_each.f_pos_gamma=zeros(5,3);
0957 for i=1:5
0958 Head_lcz_each.f_pos_gamma(i) = fread(fid,1,'float');
0959 end
0960 Head_lcz_each.f_model_r = fread(fid,1,'float');
0961 Head_lcz_each.st_model = fread(fid,3,'float');
0962 Head_lcz_each.c_eval_func = mysetstr(fread(fid,20,'char'))';
0963
0964
0965 Head_lcz_each.f_good = fread(fid,1,'float');
0966 Head_lcz_each.f_gamma = fread(fid,1,'float');
0967 Head_lcz_each.i_nlcz = fread(fid,1,'int32');
0968 Head_lcz_each.i_data_begin = fread(fid,1,'int32');
0969 Head_lcz_each.i_series = fread(fid,1,'int32');
0970 for i=1:256
0971 Head_lcz_each.i_ch_use(i) = fread(fid,1,'int32')';
0972 end
0973 Head_lcz_each.c_model_out = mysetstr(fread(fid,20,'char'))';
0974 Head_lcz_each.c_model_wght = mysetstr(fread(fid,20,'char'))';
0975 Head_lcz_each.st_axes=zeros(5,3);
0976 for i=1:5
0977 Head_lcz_each.st_axes(i,:) = fread(fid,3,'float')';
0978 end
0979 Head_lcz_each.c_sysid=cell(5);
0980 for i=1:5
0981 Head_lcz_each.c_sysid{i} = mysetstr(fread(fid,8,'char'))';
0982 end
0983 Head_lcz_each.i_lcz_del = fread(fid,1,'int32');
0984 Head_lcz_each.i_mag_type = fread(fid,1,'int32');
0985 Head_lcz_each.c_ch_use=cell(256);
0986 for i=1:256
0987 Head_lcz_each.c_ch_use{i} = mysetstr(fread(fid,6,'char'))';
0988 end
0989 Head_lcz_each.i_level = fread(fid,1,'int32');
0990 Head_lcz_each.i_width = fread(fid,1,'int32');
0991 Head_lcz_each.c_imagedir = mysetstr(fread(fid,8,'char'))';
0992
0993 varargout={Head_lcz_each};
0994
0995 case {'div'}
0996
0997 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
0998 varargout={};
0999 return;
1000 end
1001 fid=varargin{2};
1002 offset=varargin{3};
1003 if offset<=0,varargout={[]};return,end;
1004
1005 fseek(fid,offset,'bof');
1006 Head_div.i_ndiv = fread(fid,1,'int32');
1007
1008 varargout={Head_div};
1009
1010 case {'div_each'}
1011
1012 if nargin<3 | isempty(varargin{1})| isempty(varargin{2}) | isempty(varargin{3})
1013 varargout={};
1014 return;
1015 end
1016 fid=varargin{2};
1017 offset=varargin{3};
1018 if offset<=0,varargout={[]};return,end;
1019
1020 fseek(fid,offset,'bof');
1021 Head_div_each.c_div_name = mysetstr(fread(fid,128,'char'))';
1022 Head_div_each.i_div_to_port = fread(fid,1,'int32');
1023 Head_div_each.i_div_di_port = fread(fid,1,'int32');
1024
1025 varargout={Head_div_each};
1026
1027
1028 otherwise
1029 error('unrecognized type')
1030 end
1031
1032 return
1033
1034
1035
1036
1037 function out = mysetstr(in)
1038 tmp = find(in == 0);
1039 tmp = min([min(tmp) length(in)]);
1040
1041 out = char(in(1:tmp));
1042 return;
1043
1044