-
Notifications
You must be signed in to change notification settings - Fork 0
/
importData.m
57 lines (40 loc) · 1.79 KB
/
importData.m
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
% importData(X,folderName,tag,signaRange,Fs,channelLabels)
% Inputs
% X: A 3-D array of signals of size LxMxN, where L = signal length, M =
% Number of trials, N = number of Channels
% folderName: The folder where MP directories are created.
% Default: data folder in the current directory
% tag: An additional string to distinguish the data folder.
% Folders are created in foldername/tag. Default: 'test'
% signalRange: the portion of signal to be analysed. If not specified, the
% entire signal L is analyzed.
% Fs: Sampling Rate (default 1000)
% channelLabels: The channel numbers of the N channels. Default: 1:N
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Supratim Ray, 2008
% Distributed under the General Public License.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function importData(X,folderName,tag,signalRange,Fs,channelLabels)
sizeX = size(X);
if length(sizeX) == 2
% just one Channel;
L = sizeX(1); M = sizeX(2); N = 1;
else
L = sizeX(1); M = sizeX(2); N = sizeX(3);
end
if ~exist('folderName','var')
folderName = [pwd '/data/'];
end
if ~exist('tag','var') tag = 'test/'; end
if ~exist('signalRange','var') signalRange = [1 L]; end
if ~exist('Fs','var') Fs = 1000; end
if ~exist('channelLabels','var') channelLabels = 1:N; end
folderName=appendIfNotPresent(folderName,'/');
tag=appendIfNotPresent(tag,'/');
makeDirectory(folderName);
writeMPfiles(X,folderName,tag,signalRange);
[EDF, goodChannels, numTrials] = getEDF(X,Fs,channelLabels);
signalLength = signalRange(2)- signalRange(1)+1;
IDnum=1; firstName=tag;
writeheaderfile(folderName,tag,EDF,goodChannels,IDnum,firstName,numTrials,signalLength);
end