-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_info.m
409 lines (387 loc) · 15 KB
/
basic_info.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
function [h,status]=basic_info(file,h)
screensize = get( 0, 'Screensize' ); status=0;
fig1=figure('Menubar','none','position',[screensize(3)/2,screensize(4)/3,450,400] ,'visible','off','Name','Basic System Information' ,'NumberTitle','off','CloseRequestFcn', @cancel_button_callback);
%Experiment Name
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Experiment',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 375 90 20]);
h.handles.Experiment_edit=uicontrol(fig1,'Style', 'edit',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'HandleVisibility','on',...
'HorizontalAlignment','left',...
'callback',@Experiment_edit_callback,...
'Position',[115 375 310 20]);
%Number of channels
h.handles.txt6=uicontrol(fig1,'Style','text',...
'string','No. of Chans',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 350 90 20]);
h.handles.channels_edit=uicontrol(fig1,'Style', 'edit',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'HandleVisibility','on',...
'HorizontalAlignment','left',...
'callback',@num_channel_edit_callback,...
'Position',[115 350 310 20]);
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Stimulus PC',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 325 90 20]);
h.handles.stim_pc_edit=uicontrol(fig1,'Style', 'edit',...
'String','0',...
'BackgroundColor',[1 1 1],...
'FontSize',11,...
'HandleVisibility','on',...
'HorizontalAlignment','left',...
'callback',@stim_pc_edit_callback,...
'Position',[115 325 310 20]);
% %data
% h.handles.data =uicontrol(fig1,'Style', 'Pushbutton',...
% 'String','Select',...
% 'HandleVisibility','on',...
% 'callback',@data_dir_button_callback,...
% 'Position',[115 200 50 30]);
% h.handles.txt1=uicontrol(fig1,'Style','text',...
% 'string','System Data Dir',...
% 'HorizontalAlignment','left',...
% 'BackgroundColor',[0 0.75 0.75],...
% 'FontSize',11,...
% 'Position',[5 205 110 20]);
% h.handles.data_edit=uicontrol(fig1,'Style', 'edit',...
% 'String',' ',...
% 'HandleVisibility','on',...
% 'HorizontalAlignment','left',...
% 'BackgroundColor',[1 1 1],...
% 'FontSize',11,...
% 'callback',@data_edit_callback,...
% 'Position',[175 200 250 30]);
%prt
h.handles.prt =uicontrol(fig1,'Style', 'Pushbutton',...
'String','Select',...
'HandleVisibility','on',...
'callback',@protocol_button_callback,...
'Position',[115 285 50 30]);
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Protocol Dir',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 290 85 20]);
h.handles.prt_edit=uicontrol(fig1,'Style', 'edit',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'HandleVisibility','on',...
'FontSize',11,...
'HorizontalAlignment','right',...
'callback',@protocol_edit_callback,...
'Position',[175 285 250 30]);
%output
h.handles.out =uicontrol(fig1,'Style', 'Pushbutton',...
'String','Select',...
'HandleVisibility','on',...
'callback',@output_button_callback,...
'Position',[115 245 50 30]);
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Output Dir',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 250 75 20]);
h.handles.out_edit=uicontrol(fig1,'Style', 'edit',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'HandleVisibility','on',...
'FontSize',11,...
'HorizontalAlignment','left',...
'callback',@output_edit_callback,...
'Position',[175 245 250 30]);
%%%%%
h.handles.auto_se =uicontrol(fig1,'Style', 'togglebutton',...
'String','Automatic',...
'HandleVisibility','on',...
'callback',@auto_sel_button_callback,...
'Position',[150 205 100 30]);
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Channel Select',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 205 100 20]);
%System
h.handles.hitachi =uicontrol(fig1,'Style', 'Pushbutton',...
'String','Hitachi',...
'HandleVisibility','on',...
'FontSize',9,...
'callback',@hitachi_button_callback,...
'Position',[265 160 60 30]);
h.handles.nirx =uicontrol(fig1,'Style', 'Pushbutton',...
'String','NIRX',...
'HandleVisibility','on',...
'FontSize',9,...
'callback',@nirx_button_callback,...
'Position',[165 160 60 30]);
h.handles.txt4=uicontrol(fig1,'Style','text',...
'string','NIRS system',...
'HorizontalAlignment','center',...
'BackgroundColor',[0 0.75 0.75],...
'FontSize',12,...
'Position',[5 165 100 20]);
%output com
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','Output COM',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 125 90 20]);
h.handles.OutCom_pop=uicontrol(fig1,'Style', 'popup',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'FontSize',11,...
'HandleVisibility','on',...
'HorizontalAlignment','left',...
'enable','off',...
'callback',@outCOM_popup_callback,...
'Position',[115 120 310 30]);
%Nirx_address
h.handles.txt2=uicontrol(fig1,'Style','text',...
'string','COM Address',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 80 100 20]);
h.handles.OutCom_nirx_edit=uicontrol(fig1,'Style', 'edit',...
'String',' ',...
'BackgroundColor',[1 1 1],...
'FontSize',11,...
'HandleVisibility','on',...
'HorizontalAlignment','left',...
'enable','off',...
'callback',@outCOM_nirx_edit_callback,...
'Position',[115 85 310 30]);
% communication
h.handles.txt222=uicontrol(fig1,'Style','text',...
'string','Communication',...
'FontSize',11,...
'HorizontalAlignment','left',...
'BackgroundColor',[0 0.75 0.75],...
'Position',[5 50 100 20]);
h.handles.tcp =uicontrol(fig1,'Style', 'radiobutton',...
'String','TCP/IP',...
'HandleVisibility','on',...
'FontSize',12,...
'callback',@tcp_button_callback,...
'Position',[125 50 90 25]);
h.handles.text =uicontrol(fig1,'Style', 'radiobutton',...
'String','Text',...
'HandleVisibility','on',...
'FontSize',12,...
'callback',@text_button_callback,...
'Position',[250 50 90 25]);
% Done
h.handles.done =uicontrol(fig1,'Style', 'toggle',...
'String','Cancel',...
'HandleVisibility','on',...
'FontSize',12,...
'callback',@cancel_button_callback,...
'Position',[125 10 90 30]);
h.handles.done =uicontrol(fig1,'Style', 'toggle',...
'String','Done',...
'HandleVisibility','on',...
'FontSize',12,...
'callback',@done_button_callback,...
'Position',[250 10 90 30]);
if file==0
h.basic_info.experiment='';
h.basic_info.out_com='';
h.basic_info.isUDP=0;
h.basic_info.isText=0;
h.basic_info.stimulus_PC_folder='';
h.basic_info.auto_sel=0;
h.basic_info.protocol_dir='';
h.basic_info.output_dir ='';
h.basic_info.system='';
h.basic_info.nirx_address='';h.basic_info.auto_sel=0;
[~,res]=system('mode');
aa=regexp(res,'COM\d+','match')';
h.coms1{1,1}=' ';
for ii=2:length(aa)
h.coms1{1,ii+1}=aa{ii};
end
set(h.handles.OutCom_pop,'string',h.coms1);
set(fig1,'visible','on');
elseif ~isempty(file)
try
h.old=load(file);
h.basic_info=h.old.basic_info;
set(h.handles.stim_pc_edit, 'string',h.basic_info.stimulus_PC_folder);
set(h.handles.auto_se,'value', h.basic_info.auto_sel);
set(h.handles.Experiment_edit,'string',h.basic_info.experiment);
% set(h.handles.data_edit,'string',h.basic_info.system_data_dir);
set(h.handles.tcp ,'value',h.basic_info.isUDP);
set(h.handles.text ,'value',h.basic_info.isText);
if h.basic_info.isUDP
set(h.handles.tcp,'BackgroundColor',[0,0.5,0])
set(h.handles.text,'BackgroundColor',[0.94,0.94,0.94])
elseif h.basic_info.isText
set(h.handles.tcp,'BackgroundColor',[0.94,0.94,0.94])
set(h.handles.text,'BackgroundColor',[0,0.5,0])
end
set(h.handles.prt_edit,'string',h.basic_info.protocol_dir);
set(h.handles.out_edit,'string',h.basic_info.output_dir);
set(h.handles.channels_edit,'string', h.basic_info.num_channel);
if strcmp(h.basic_info.system,'NIRx')
set(h.handles.hitachi,'BackgroundColor',[0.94,0.94,0.94])
set(h.handles.nirx,'BackgroundColor',[0,0.5,0])
set(h.handles.OutCom_nirx_edit,'string',h.basic_info.nirx_address)
set(h.handles.OutCom_nirx_edit,'enable','on');
elseif strcmp(h.basic_info.system,'Hitachi')
set(h.handles.hitachi,'BackgroundColor',[0,0.5,0])
set(h.handles.nirx,'BackgroundColor',[0.94,0.94,0.94])
[~,res]=system('mode');
aa=regexp(res,'COM\d+','match')';
for ii=2:size(aa,1)+1
h.coms1{ii}=aa{ii-1};
if strcmp(h.basic_info.out_com,aa{ii-1})
com_val=ii;
end
end
set(h.handles.OutCom_pop,'string',h.coms1);
set(h.handles.OutCom_pop,'value',com_val);
%set( h.handles.OutCom_pop,'string',h.basic_info.out_com);
set(h.handles.OutCom_pop,'enable','on');
end
set(fig1,'visible','on');
catch
[~,res]=system('mode');
aa=regexp(res,'COM\d+','match')';
for ii=2:size(aa,1)+1
h.coms1{ii}=aa{ii-1};
end
set(h.handles.OutCom_pop,'string',h.coms1);
h.basic_info.experiment='';
h.basic_info.stimulus_PC_folder='';
h.basic_info.out_com='';
h.basic_info.num_channel='';
h.basic_info.protocol_dir='';
h.basic_info.output_dir ='';
h.basic_info.system='';
h.basic_info.nirx_address='';
h.basic_info.auto_sel=0;
set(fig1,'visible','on');
end
end
uiwait(fig1);
function auto_sel_button_callback(hObject,eventdata,handles)
if get(hObject,'value')==1
set(h.handles.auto_se,'BackgroundColor',[0,0.5,0])
h.basic_info.auto_sel=1;
else
set(h.handles.auto_se,'BackgroundColor',[0.94,0.94,0.94])
h.basic_info.auto_sel=0;
end
end
function Experiment_edit_callback (hObject,eventdata,handles)
h.basic_info.experiment = strtrim(get(hObject, 'String'));
end
function outCOM_popup_callback (hObject,eventdata,handles)
h.basic_info.out_com = h.coms1{get(hObject, 'value')};
end
function num_channel_edit_callback (hObject,eventdata,handles)
h.basic_info.num_channel = str2num(strtrim(get(hObject, 'String')));
end
function text_button_callback (hObject,eventdata,handles)
if get(hObject, 'value')==1
h.basic_info.isUDP=0;
h.basic_info.isText=1;
set(h.handles.tcp,'BackgroundColor',[0.94,0.94,0.94])
set(h.handles.text,'BackgroundColor',[0,0.5,0])
else
h.basic_info.isUDP=1;
h.basic_info.isText=0;
set(h.handles.tcp,'BackgroundColor',[0,0.5,0])
set(h.handles.text,'BackgroundColor',[0.94,0.94,0.94])
end
end
function tcp_button_callback (hObject,eventdata,handles)
if get(hObject, 'value')==1
h.basic_info.isUDP=1;
h.basic_info.isText=0;
set(h.handles.tcp,'BackgroundColor',[0,0.5,0])
set(h.handles.text,'BackgroundColor',[0.94,0.94,0.94])
else
h.basic_info.isUDP=0;
h.basic_info.isText=1;
set(h.handles.tcp,'BackgroundColor',[0.94,0.94,0.94])
set(h.handles.text,'BackgroundColor',[0,0.5,0])
end
end
function protocol_button_callback (hObject,eventdata,handles)
h.basic_info.protocol_dir = uigetdir;
set(h.handles.prt_edit,'string',h.basic_info.protocol_dir);
end
function protocol_edit_callback (hObject,eventdata,handles)
h.basic_info.protocol_dir = get(hObject, 'String');
end
function output_button_callback (hObject,eventdata,handles)
h.basic_info.output_dir = uigetdir;
set(h.handles.out_edit,'string',h.basic_info.output_dir);
end
function output_edit_callback (hObject,eventdata,handles)
h.basic_info.output_dir = get(hObject, 'String');
end
function nirx_button_callback(hObject,eventdata,handles)
if (get(hObject, 'Value') == 1)||(get(hObject, 'Value') == 1)
set(h.handles.nirx,'BackgroundColor',[0,0.5,0])
set(h.handles.hitachi,'BackgroundColor',[0.94,0.94,0.94])
set(h.handles.OutCom_nirx_edit, 'enable','on')
h.basic_info.system='NIRx';
end
end
function hitachi_button_callback(hObject,eventdata,handles)
if (get(hObject, 'Value') == 1)||(get(hObject, 'Value') == 1)
set(h.handles.hitachi,'BackgroundColor',[0,0.5,0])
set(h.handles.nirx,'BackgroundColor',[0.94,0.94,0.94])
set( h.handles.OutCom_pop, 'enable','on');
h.basic_info.system='Hitachi';
end
end
function stim_pc_edit_callback(hObject,eventdata,handles)
h.basic_info.stimulus_PC_folder= strtrim(get(hObject, 'String'));
end
function outCOM_nirx_edit_callback(hObject,eventdata,handles)
h.basic_info.nirx_address=hex2dec(strtrim(get(hObject, 'String')));
end
function done_button_callback(hObject,eventdata,handles)
if ~isempty(h.basic_info.system)&& ~isempty( h.basic_info.experiment)&& ~isempty(h.basic_info.num_channel) && (~isempty( h.basic_info.out_com) ||~isempty(h.basic_info.nirx_address))&& ~isempty( h.basic_info.protocol_dir) &&~isempty( ~isempty(h.basic_info.output_dir))
basic_info=h.basic_info;
if ~isdeployed
if exist([fileparts(which('pradeep.m')), filesep,'basic_info'],'dir')~=7
mkdir( [fileparts(which('pradeep.m')), filesep,'basic_info']);
end
save([fileparts(which('nirs_feedback.m')), filesep,'basic_info',filesep,'basic_info_', h.basic_info.experiment,'.mat'],'basic_info'); status=1;
else
[status,result]=system('path');
root_path=char(regexp(result,'Path=(.*?);','tokens','once'));
if exist([root_path, filesep,'basic_info'],'dir')~=7
mkdir( [root_path, filesep,'basic_info']);
end
save([root_path, filesep,'basic_info',filesep,'basic_info_', h.basic_info.experiment,'.mat'],'basic_info'); status=1;
end
delete(gcf);
return
end
end
function cancel_button_callback(hObject,eventdata,handles)
status=0;
delete(gcf);
return
end
end