-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPscript_Usleepv2.m
57 lines (51 loc) · 2.29 KB
/
MPscript_Usleepv2.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
%matlab end MATLAB-Python tandem TSV producer.
%This script loads data from L-drive (DXA DATA SET) and produces an EDF
%file into an output destination path. This can then be used by the python
%U-Sleep script to process via the online U-Sleep API and then output a
%.TSV file into its own output destination. This script, after seeing the
%new .TSV file will delete the .EDF file it created as to conserve space.
%BE CAREFUL WHERE YOU PUT THE OUTPUT DIRECTORY FOR THIS SCRIPT, IT CAN
%DELETE FILES.
%For use in U-sleep v2
direc = dir('L:\Lab_JamesR\Paediatric_Sleep\diagnostic\DXA*');
clear scnew
clear global scnew
load('L:\Lab_JamesR\Paediatric_Sleep\studyinfo\scnew.mat');
global scnew
names = fields(scnew);
% names = fields(scnew);
%prog initializes the process
% prog = false;
%quick predict count = 2905;
%813
count = 285;
%BELOW DEFINES INPUT/OUTPUT DIRECTORIES
%It is recommended that 'tsvloc', also, 'edfloc' MUST be empty beforehand
%else the script will throw an error saying it doesn't know what postbool is.
tsvloc = 'L:\Lab_JamesR\alexW\U-Sleep_Hypnograms\v2new'; %location where final output tsv files are to be output
dataloc = 'L:\Lab_JamesR\Paediatric_Sleep\diagnostic\'; %location where the .mat psgdata files are located
edfloc = 'C:\Data&Scripts\Tempbin\'; %location where edf files are TEMPORARYILY located for processing, will be deleted after.
while length(dir(tsvloc)) < length(fields(scnew))
if length(dir('C:\Data&Scripts\Tempbin')) < 3
count = count + 1;
disp(['Loading and converting ' names{count} ' to EDF format --- ' str2num(count)]);
load([dataloc names{1} '\' names{1} '-psgdata.mat']);
edf_func_v2([edfloc names{count} '.edf'], psgdata);
disp('Succesfully created edf');
pause(1)
postbool = false;
else
pause(1)
if postbool == false
disp(['awaiting U-sleep analysis of file ' names{count} '.edf'])
postbool = true;
end
uslepdir = dir(tsvloc);
uslepnames = {uslepdir.name};
if max(contains(uslepnames, [names{count} '.tsv']))
delete([edfloc names{count} '.edf']);
disp(['Sucessfully processed ' names{count}]);
pause(1)
end
end
end