readSBI : Rev.1.0, 2001-11-17 read SBI data function [samp,pick1,pick2,bexp,ier]=readSBI(sqddat,sysid) Input: sqddat % $SQDDAT ex. /data1/toyama2/ sysid % System ID ex. 1000987 Output: samp struct(nch, % number of active gardiometers nsamp, % sampling number of measurement nprsamp, % sampling number for pre-trigger sampf, % sampling frequency nrept, % repeat number sph0, % origin of sphere model on DICOM cord. mrisys) % MRI system ID pick1(ch,samp) % position and direction of detection coils on DICOM cord. [m],[normal unit vector] pick2(ch,samp) % position and direction of compensation coils on DICOM cord. [m],[normal unit vector] bexp(ch,samp,rept) % measured fields [T] history 2001-11-09 S.Kajihara Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Ieeg,Ceeg,Deeg,Ietc,Cetc,Detc,ier]=readSBI2(sqddat,sysid) 0002 % readSBI : Rev.1.0, 2001-11-17 0003 % read SBI data 0004 % function [samp,pick1,pick2,bexp,ier]=readSBI(sqddat,sysid) 0005 % Input: sqddat % $SQDDAT ex. /data1/toyama2/ 0006 % sysid % System ID ex. 1000987 0007 % Output: samp struct(nch, % number of active gardiometers 0008 % nsamp, % sampling number of measurement 0009 % nprsamp, % sampling number for pre-trigger 0010 % sampf, % sampling frequency 0011 % nrept, % repeat number 0012 % sph0, % origin of sphere model on DICOM cord. 0013 % mrisys) % MRI system ID 0014 % pick1(ch,samp) % position and direction of detection coils on DICOM cord. [m],[normal unit vector] 0015 % pick2(ch,samp) % position and direction of compensation coils on DICOM cord. [m],[normal unit vector] 0016 % bexp(ch,samp,rept) % measured fields [T] 0017 % 0018 % history 0019 % 2001-11-09 S.Kajihara 0020 % 0021 % Copyright (C) 2011, ATR All Rights Reserved. 0022 % License : New BSD License(see VBMEG_LICENSE.txt) 0023 ier=0; 0024 0025 % file info. 0026 fid=fopen(sprintf('%shead%s%s.hd',sqddat,filesep,sysid),'r','l'); 0027 if fid==-1, disp('XXX Error : Cannot open head file !!'); ier=1; return; end 0028 H_file=meg_hread('file',fid); 0029 0030 % 0031 % --- read eeg 0032 % 0033 if H_file.i_eeg_begin>0, 0034 % condition 0035 H_eeg=meg_hread('eeg',fid,H_file.i_eeg_begin); 0036 nch=H_eeg.i_nch; % channel number 0037 nsamp=H_eeg.i_nsample; % sampling number of measurement 0038 nrept=H_eeg.i_nwave; % repeat number 0039 vbit=H_eeg.f_ad_weight; % AD sense 0040 for i=1:nch, 0041 H_eeg_ch=meg_hread('eeg_ch',fid,H_file.i_eeg_ch_begin+H_file.i_eeg_ch_size*(i-1)); 0042 Ceeg{i}=H_eeg_ch.c_ch_name; 0043 end 0044 % data 0045 fid0=fopen(sprintf('%seeg%s%s.eeg',sqddat,filesep,sysid),'r','l'); 0046 if fid0==-1, disp('XXX Error : Cannot open eeg file !!'); ier=1; return; end 0047 a=fread(fid0,nrept*nch*nsamp,'short'); 0048 fclose(fid0); 0049 Deeg=(reshape(a,nch,nsamp,nrept)).*vbit; clear a; 0050 else, 0051 disp('*** Warning : Not measured EEG !!'); 0052 nch=0; nsamp=0; nrept=0; ch_name='none'; Deeg=0; 0053 end 0054 Ieeg=struct('nch',nch, ... % number of active gardiometers 0055 'nsamp',nsamp, ... % sampling number of measurement 0056 'nrept',nrept ); % repeat number 0057 0058 % 0059 % --- read etc 0060 % 0061 % condition 0062 if H_file.i_etc_begin>0, 0063 % condition 0064 H_etc=meg_hread('etc',fid,H_file.i_etc_begin); 0065 nch=H_etc.i_nch; % channel number 0066 nsamp=H_etc.i_nsample; % sampling number of measurement 0067 % nrept=H_etc.i_nwave; % repeat number 0068 vbit=H_etc.f_ad_weight; % AD sense 0069 for i=1:nch, 0070 H_etc_ch=meg_hread('etc_ch',fid,H_file.i_etc_ch_begin+H_file.i_etc_ch_size*(i-1)); 0071 Cetc{i}=H_etc_ch.c_ch_name; 0072 end 0073 % data 0074 fid0=fopen(sprintf('%setc%s%s.etc',sqddat,filesep,sysid),'r','l'); 0075 if fid0==-1, disp('XXX Error : Cannot open etc file !!'); ier=1; return; end 0076 a=fread(fid0,nrept*nch*nsamp,'short'); 0077 fclose(fid0); 0078 Detc=(reshape(a,nch,nsamp,nrept)).*vbit; clear a; 0079 else, 0080 disp('*** Warning : Not measured ETC !!'); 0081 nch=0; nsamp=0; nrept=0; ch_name='none'; Detc=0; 0082 end 0083 Ietc=struct('nch',nch, ... % number of active gardiometers 0084 'nsamp',nsamp, ... % sampling number of measurement 0085 'nrept',nrept ); % repeat number