


load Jact file
USAGE:
[Jact, Jback]=vb_load_Jact(proj_root, JactInfo, session, trial)
INPUT:
proj_root - directory of project root
JactInfo - 'JactInfo = vb_load_JactInfo(proj_root,currfile);'
Session - Vector of interesting session No., e.g. [1,3,5].
If this argument is set as charactor of 'all',
all sessions are output.
Trial - cell including vectors of interesting trial No. for
each 'Session', e.g. {[1:10],[1:20],[1,3,10,20]}.
If this argument is set as charactor of 'all',
all trials of each sessions are output.
OUTPUT:
Jact - average current data of interesting Sessions and
Trials.
[num_channels x num_samples]
2006.06.26 Dai Kawawaki.
2006.06.27 Some bugs were fixed by Dai Kawawaki.
Copyright (C) 2011, ATR All Rights Reserved.
License : New BSD License(see VBMEG_LICENSE.txt)

0001 function [Jact, Jback]=vb_load_Jact(proj_root, JactInfo, Session, Trial) 0002 % load Jact file 0003 % 0004 % USAGE: 0005 % [Jact, Jback]=vb_load_Jact(proj_root, JactInfo, session, trial) 0006 % 0007 % INPUT: 0008 % proj_root - directory of project root 0009 % JactInfo - 'JactInfo = vb_load_JactInfo(proj_root,currfile);' 0010 % Session - Vector of interesting session No., e.g. [1,3,5]. 0011 % If this argument is set as charactor of 'all', 0012 % all sessions are output. 0013 % Trial - cell including vectors of interesting trial No. for 0014 % each 'Session', e.g. {[1:10],[1:20],[1,3,10,20]}. 0015 % If this argument is set as charactor of 'all', 0016 % all trials of each sessions are output. 0017 % 0018 % OUTPUT: 0019 % Jact - average current data of interesting Sessions and 0020 % Trials. 0021 % [num_channels x num_samples] 0022 % 0023 % 2006.06.26 Dai Kawawaki. 0024 % 2006.06.27 Some bugs were fixed by Dai Kawawaki. 0025 % 0026 % Copyright (C) 2011, ATR All Rights Reserved. 0027 % License : New BSD License(see VBMEG_LICENSE.txt) 0028 0029 jactdir = [proj_root JactInfo.jactdir]; 0030 Tsample = JactInfo.Tsample; 0031 NJact = JactInfo.NJact; 0032 0033 if ischar(Session) 0034 switch lower(Session) 0035 case 'all' 0036 session = [1:JactInfo.Nsession]; 0037 otherwise 0038 error('Invalid value of 3rd argument.'); 0039 end 0040 else 0041 session = Session; 0042 end 0043 0044 if ischar(Trial) 0045 switch lower(Trial) 0046 case 'all' 0047 for n = 1:length(session) 0048 trial{n} = [1:JactInfo.Ntrial{session(n)}]; 0049 end 0050 otherwise 0051 error('Invalid value of 4th argument.'); 0052 end 0053 else 0054 if iscell(Trial) 0055 trial = Trial; 0056 else 0057 trial = {Trial}; 0058 end 0059 end 0060 0061 %error check 0062 if length(session) ~= length(trial) 0063 error(['Iinvalid usage of this function. Vector length of ''Session''' ... 0064 ' must be same as the number of cell components of ''Trial''.']); 0065 end 0066 0067 nrepeat = 0; 0068 for n = 1:length(session), 0069 nrepeat = nrepeat + length(trial{n}); 0070 end; 0071 0072 Jact_tmp = zeros(NJact,Tsample); 0073 Jback_tmp = zeros(NJact,Tsample); 0074 for s = 1:length(session) 0075 for t = trial{s} 0076 fprintf('---- load file : data_s%04dt%04d\n',session(s),t); 0077 fname = [jactdir sprintf('data_s%04dt%04d',session(s),t)]; 0078 load(fname,'Jact','Jback'); 0079 Jact_tmp = Jact_tmp + (Jact / nrepeat); 0080 Jback_tmp = Jback_tmp + (Jback / nrepeat); 0081 end 0082 end 0083 Jact = Jact_tmp; 0084 Jback = Jback_tmp; 0085 return