load data from fiffile. [USAGE] [bexp] = neuromag_load_meg_data(<fif_file>, <index_in_fif_file>); [IN] fif_file : fif file(Continuous file or Evoked file) index_in_fiffile : = -1 : continuous = N : read data set number in fiffile. [OUT] bexp : The data of one channel in each row, a single time sample in each column. Units: SI units. fT/m for gradiometers, fT for magnetometers, V for electric channels. Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [bexp, ch_info, sf] = neuromag_load_meg_data(fif_file, index_in_fiffile) 0002 % load data from fiffile. 0003 % [USAGE] 0004 % [bexp] = neuromag_load_meg_data(<fif_file>, <index_in_fif_file>); 0005 % [IN] 0006 % fif_file : fif file(Continuous file or Evoked file) 0007 % index_in_fiffile : = -1 : continuous 0008 % = N : read data set number in fiffile. 0009 % [OUT] 0010 % bexp : The data of one channel in each row, a single time sample in 0011 % each column. Units: SI units. fT/m for gradiometers, fT for 0012 % magnetometers, V for electric channels. 0013 % 0014 % Copyright (C) 2011, ATR All Rights Reserved. 0015 % License : New BSD License(see VBMEG_LICENSE.txt) 0016 0017 % 0018 % --- Previous check 0019 % 0020 if ~exist('fif_file', 'var') 0021 error('fif_file is a required parameter.'); 0022 end 0023 if exist(fif_file, 'file') ~= 2 0024 error('fif_file:%s is not found.', fif_file); 0025 end 0026 if ~exist('index_in_fiffile', 'var') 0027 index_in_fiffile = -1; % continuous 0028 end 0029 0030 0031 % 0032 % --- Main Procedure 0033 % 0034 ch_info = neuromag_load_ch_info(fif_file); 0035 0036 if index_in_fiffile == -1 0037 % load Continuous data 0038 raw = fiff_setup_read_raw(fif_file); 0039 bexp = fiff_read_raw_segment(raw); 0040 sf = raw.info.sfreq; 0041 else 0042 % load Evoked data 0043 raw = fiff_read_evoked(fif_file, index_in_fiffile); 0044 bexp = raw.evoked.epochs; 0045 sf = raw.info.sfreq; 0046 end 0047 0048 meg_ix = []; 0049 for k=1:ch_info.Nch 0050 channel_name = ch_info.channel_name(k, :); 0051 meg_ix = [meg_ix; strmatch(channel_name, raw.info.ch_names, 'exact')]; 0052 end 0053 bexp = bexp(meg_ix, :, :);