forked from gmicros/MATLAB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_data.m
More file actions
31 lines (31 loc) · 1.21 KB
/
load_data.m
File metadata and controls
31 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [ signal, state, parameters, code] = load_data
%
% Call the function: [signal, state, parms] = load_data();
% to load in (possibly multiple) .dat files
%
%Load in multiple .dat files
signal=[]; state=struct([]);
[files,dir] = uigetfile('*.dat','Select the .dat file(s)','multiselect','on');
if(~iscell(files))
files=cellstr(files);
end
for kk = 1:length(files)
disp(['Loading file ' num2str(kk) ' ...']);
[sig, sts, prms] = load_bcidat([dir char(files(kk))]);
gain=prms.SourceChGain.NumericValue;
offset=prms.SourceChOffset.NumericValue;
%concatenate signal from multiple files, multiply in the gains, and add
%offsets
signal=cat(1,signal,int16(repmat(gain',size(sig,1),1).* double(sig) + repmat(offset',size(sig,1),1)));
%concatenate all of the fields in the state structure
stateNames=fieldnames(sts);
for jj = 1:length(stateNames);
if(isfield(state, char(stateNames(jj)))==0)
state(1).(char(stateNames(jj)))=sts.(char(stateNames(jj)));
else
state.(char(stateNames(jj)))=cat(1,state.(char(stateNames(jj))),sts.(char(stateNames(jj))));
end
end
%save the parameters for each run (in case they differ)
parameters(1,kk)=prms;
end