-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathianread.m
120 lines (119 loc) · 3.44 KB
/
ianread.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
directorio = uigetdir;
sides = {};
tiempo = [];
cabeza = [];
ojo = [];
ojo_sinsac = [];
paciente = {};
sidesr = {};
tiempor = [];
cabezar = [];
ojor = [];
ojor_sinsac = [];
pacienter = {};
pat = cd;
exito = 0;
if not(directorio == 0)
lista_archivos = strsplit(ls(directorio));
archivos = sort(lista_archivos);
archivos(1) = [];
exito = 1;
cd(directorio);
[nul,numlist] = size(archivos);
posicion = 1;
impulso = 0;
prog=waitbar(0,'Importing files...');
while posicion <= numlist
try
[file_num,file_txt] = xlsread(char(archivos(posicion)));
catch
close(prog);
cd(pat);
exito = 0;
posicion = numlist;
msgbox('Error importing XLS files!', 'ERROR','error');
return
end
leer = 1;
[tama nul] = size(file_num);
while leer <= tama
if isnan(file_num(leer,2))
sides = horzcat(sides,file_txt(leer,3));
impulso = impulso + 1;
leer = leer + 1;
escribir = 1;
else
tiempo(escribir,impulso) = file_num(leer,1);
cabeza(escribir,impulso) = file_num(leer,2);
ojo(escribir,impulso) = file_num(leer,3);
ojo_sinsac(escribir,impulso) = file_num(leer,4);
paciente(impulso) = archivos(posicion);
escribir = escribir + 1;
end
leer = leer + 1;
end
posicion = posicion + 1;
waitbar(posicion/numlist);
end
end
try
close(prog);
end
cd(pat);
if exito == 1
text = [num2str(posicion-1) ' files were imported. Do you want to import both sides?'];
alerta = questdlg(text, 'Imported options', 'Left','Right','Both','Both');
if strcmp(alerta,'Left')
match = strfind(sides, 'LEFT');
[nul val] = size(match);
pos = 1;
esc = 1;
while pos <=val
if not(isempty(match{pos}));
tiempor(:,esc) = tiempo(:,pos);
cabezar(:,esc) = cabeza(:,pos);
ojor(:,esc) = ojo(:,pos);
ojor_sinsac(:,esc) = ojo_sinsac(:,pos);
sidesr(esc)= sides(pos);
pacienter(esc)=paciente(pos);
esc = esc + 1;
end
pos = pos + 1;
end
tiempo = tiempor;
cabeza = cabezar;
ojo = ojor;
ojo_sinsac = ojor_sinsac;
sides = sidesr;
paciente = pacienter;
end
if strcmp(alerta,'Right')
match = strfind(sides, 'RIGHT');
[nul val] = size(match);
pos = 1;
esc = 1;
while pos <=val
if not(isempty(match{pos}));
tiempor(:,esc) = tiempo(:,pos);
cabezar(:,esc) = cabeza(:,pos);
ojor(:,esc) = ojo(:,pos);
ojor_sinsac(:,esc) = ojo_sinsac(:,pos);
sidesr(esc)= sides(pos);
pacienter(esc)=paciente(pos);
esc = esc + 1;
end
pos = pos + 1;
end
tiempo = tiempor;
cabeza = cabezar;
ojo = ojor;
ojo_sinsac = ojor_sinsac;
sides = sidesr;
paciente = pacienter;
end
[archivo,directorio] = uiputfile('*.mat','Save imported data to file','imported.mat');
if archivo == 0
return
end
save([directorio archivo],'ojo','cabeza','tiempo','ojo_sinsac','sides','archivos','paciente');
end