vb_test_make_trial_file ----- Batch script for making trial file from continuous data ----- Make trial data files after extracting trials from continuous raw data [data, ch_info] = vb_msrmnt_make_trial_data(proc_spec) :proc_spec : <required> <<struct>> : .root_dir : <optional> data directory of base meg/eeg file : and trig_file ['.'] .trig_file : <conditionally required> <<file>> : trigger file name without path : this file is expected to have data as follows: : .parm.data_file (without path) : base file : .trig [1 x Ntrial] : .parm.Pretrigger_ms : pretrigger [msec] : .parm.Posttrigger_ms : posttrigger [msec] : .parm.fsamp : sampling frequency [Hz] : if this is invalid and .proc_parm field is not : specified, it is error. .new_file : <optional> new MEG/EEG filename .new_bin_dir : <optional> binaly external data directory : *ONLY FOR MEG* : This is relative path from '.new_file' : if this is not specified, data is stored internally .proc_parm : <optional> <<struct>> : .Pretrigger_ms : Pretrigger period [msec] : .Posttrigger_ms : Posttrigger period [msec] : .sample_freq : sampling frequency [Hz] : .data_file : base [meg/eeg] file (no path) : .trigger : list of trigger samples : : [1 x Ntrial] : if these are specified, : they overwrite the setting values of trig_file :trig_file にトリガファイルを指定します :base file は trig_file に保存されたファイル名parm.data_fileを使用 :通常はトリガファイルから取得したトリガ情報を使用しますが、 :proc_parm を指定すれば、このトリガ情報が優先されます :トリガファイルを作成した元データではなく、フィルタ処理されたデータから トライアルファイルを作成する時は、proc_parm.data_file を指定する :.new_bin_dir でデータの外部保存ディレクトリを指定します(MEGのみ) :.new_bin_dir が指定されない場合は、切り出したデータを内部保存します 2009-8-10 Masa-aki Sato Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 % vb_test_make_trial_file 0002 % ----- Batch script for making trial file from continuous data ----- 0003 % Make trial data files after extracting trials from continuous raw data 0004 % [data, ch_info] = vb_msrmnt_make_trial_data(proc_spec) 0005 % :proc_spec : <required> <<struct>> 0006 % : .root_dir : <optional> data directory of base meg/eeg file 0007 % : and trig_file ['.'] 0008 % .trig_file : <conditionally required> <<file>> 0009 % : trigger file name without path 0010 % : this file is expected to have data as follows: 0011 % : .parm.data_file (without path) : base file 0012 % : .trig [1 x Ntrial] 0013 % : .parm.Pretrigger_ms : pretrigger [msec] 0014 % : .parm.Posttrigger_ms : posttrigger [msec] 0015 % : .parm.fsamp : sampling frequency [Hz] 0016 % : if this is invalid and .proc_parm field is not 0017 % : specified, it is error. 0018 % .new_file : <optional> new MEG/EEG filename 0019 % .new_bin_dir : <optional> binaly external data directory 0020 % : *ONLY FOR MEG* 0021 % : This is relative path from '.new_file' 0022 % : if this is not specified, data is stored internally 0023 % .proc_parm : <optional> <<struct>> 0024 % : .Pretrigger_ms : Pretrigger period [msec] 0025 % : .Posttrigger_ms : Posttrigger period [msec] 0026 % : .sample_freq : sampling frequency [Hz] 0027 % : .data_file : base [meg/eeg] file (no path) 0028 % : .trigger : list of trigger samples 0029 % : : [1 x Ntrial] 0030 % : if these are specified, 0031 % : they overwrite the setting values of trig_file 0032 % 0033 % :trig_file にトリガファイルを指定します 0034 % :base file は trig_file に保存されたファイル名parm.data_fileを使用 0035 % :通常はトリガファイルから取得したトリガ情報を使用しますが、 0036 % :proc_parm を指定すれば、このトリガ情報が優先されます 0037 % :トリガファイルを作成した元データではなく、フィルタ処理されたデータから 0038 % トライアルファイルを作成する時は、proc_parm.data_file を指定する 0039 % :.new_bin_dir でデータの外部保存ディレクトリを指定します(MEGのみ) 0040 % :.new_bin_dir が指定されない場合は、切り出したデータを内部保存します 0041 % 0042 % 2009-8-10 Masa-aki Sato 0043 % 0044 % Copyright (C) 2011, ATR All Rights Reserved. 0045 % License : New BSD License(see VBMEG_LICENSE.txt) 0046 0047 clear all 0048 0049 data_mode = 'eeg'; 0050 0051 switch data_mode 0052 case 'meg' 0053 % root directry 0054 root_dir = [getenv('MATHOME') '/Sekiyama']; 0055 % --- List of data file names (base name without extension) 0056 data_base = {'AM090311a'}; 0057 ext = '.meg.mat'; 0058 % --- Set of onset condition list 0059 onset = {'_voice_mik_B', '_voice_mik_G'}; 0060 case 'eeg' 0061 % root directry 0062 root_dir = [getenv('MATHOME') '/BCI_Tmp/eeg_data']; 0063 % --- EEG file names (base name without extension) 0064 data_base = {'Sako_20080903_1', 'Sako_20080903_2'}; 0065 0066 ext = '.eeg.mat'; 0067 % --- Set of onset condition list 0068 onset = {'_task'}; 0069 end 0070 0071 % Filtered data file suffix (if it is empty. original data is used) 0072 filt_suffix = '_filt'; 0073 % Trial data file suffix 0074 epoch_suffix = '_epoch'; 0075 0076 % --- Length of trials 0077 parm.Pretrigger_ms = [ 0 ]; % [msec] 0078 parm.Posttrigger_ms = [10000 ]; % [msec] 0079 0080 proc_spec.proc_parm = parm; 0081 proc_spec.root_dir = root_dir; 0082 0083 Nfile = length(data_base); 0084 Ncond = length(onset); 0085 %Nfile = 1; 0086 0087 for n=1:Nfile 0088 for m=1:Ncond 0089 % Trial onset file 0090 proc_spec.trig_file = [data_base{n} onset{m} '.trig.mat']; 0091 0092 % When filtered data file is used 0093 if ~isempty(filt_suffix) 0094 data_file = [data_base{n} filt_suffix ext]; 0095 proc_spec.proc_parm.data_file = data_file; 0096 end 0097 0098 % Trial file 0099 proc_spec.new_file = ... 0100 [root_dir '/' data_base{n} onset{m} epoch_suffix ext]; 0101 0102 tic 0103 [data, ch_info] = vb_msrmnt_make_trial_data(proc_spec); 0104 vb_ptime(toc) 0105 end 0106 end 0107 0108 return