-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimTracker.m
More file actions
5839 lines (4909 loc) · 246 KB
/
SimTracker.m
File metadata and controls
5839 lines (4909 loc) · 246 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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = SimTracker(varargin)
% SIMTRACKER M-file for SimTracker.fig
% SIMTRACKER, by itself, creates a new SIMTRACKER or raises the existing
% singleton*.
%
% H = SIMTRACKER returns the handle to a new SIMTRACKER or the handle to
% the existing singleton*.
%
% SIMTRACKER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SIMTRACKER.M with the given input arguments.
%
% SIMTRACKER('Property','Value',...) creates a new SIMTRACKER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SimTracker_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SimTracker_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help SimTracker
% Last Modified by GUIDE v2.5 23-May-2016 15:34:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SimTracker_OpeningFcn, ...
'gui_OutputFcn', @SimTracker_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before SimTracker is made visible.
function SimTracker_OpeningFcn(hObject, eventdata, handles, varargin)
global cygpath cygpathcd realpath mypath logloc sl donotsave javaaddpathstaticflag
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to SimTracker (see VARARGIN)
cygpathcd='';
donotsave=0;
try
if isdeployed
set(handles.txt_deployed,'String','Compiled')
set(handles.menuitem_jobscripts,'Enable','Off')
end
% figure format settings
handles.formatP.textwidth=15;
handles.formatP.plottextwidth=.1;
handles.formatP.marg=.03/2;
handles.formatP.st=2;
handles.formatP.left = .065;
handles.formatP.bottom=.065;
handles.formatP.hmar=-.03;
handles.formatP.colorvec={'m','k','b','r','g','y','c'};
handles.formatP.sizevec={5,5,5,5,5,5,5,5,5,5,5,5,5};
handles.formatP.figs=[];
if ispc
handles.curses.sl='\';
sl='\';
else
handles.curses.sl='/';
sl='/';
end
%%%%
[mypath, realpath]=GetSimStorageFolder();%GetExecutableFolder();
if iscell(realpath)
realpath=realpath{1};
end
if exist([realpath sl 'defaults' sl 'defaultparameters.mat'],'file')==0
if exist('defaultparameters.mat','file')
load('defaultparameters.mat')
save([realpath sl 'defaults' sl 'defaultparameters.mat'],'defchparams','defixparams','-v7.3');
elseif exist([realpath sl 'defaults' sl 'defaultparameters.mat'],'file')
load([realpath sl 'defaults' sl 'defaultparameters.mat'])
save([realpath sl 'defaults' sl 'defaultparameters.mat'],'defchparams','defixparams','-v7.3');
end
end
if exist([realpath sl 'defaults' sl 'defaultputs.mat'],'file')==0
if exist('defaultputs.mat','file')
load('defaultputs.mat')
save([realpath sl 'defaults' sl 'defaultputs.mat'],'defaultputs','-v7.3');
elseif exist([realpath sl 'defaults' sl 'defaultputs.mat'],'file')
load([realpath sl 'defaults' sl 'defaultputs.mat'])
save([realpath sl 'defaults' sl 'defaultputs.mat'],'defaultputs','-v7.3');
end
end
if ispc || ismac
javaaddpathstaticflag=1;
else
javaaddpathstaticflag=0;
end
if exist([mypath sl 'ganymed-ssh2-build250' sl 'ganymed-ssh2-build250.jar'],'file') && javaaddpathstaticflag
javaaddpathstatic([mypath sl 'ganymed-ssh2-build250' sl 'ganymed-ssh2-build250.jar']);
end
%
% addpath('.\ganymed-ssh2-build250\')
% addpath('.\ganymed-ssh2-build250\src\')
% addpath('.\ganymed-ssh2-build250\src\ch\')
% addpath('.\ganymed-ssh2-build250\src\ch\ethz\')
% addpath('.\ganymed-ssh2-build250\src\ch\ethz\ssh2\')
%%%%
if exist([mypath sl 'data' sl 'MyOrganizer.mat'],'file')
try
load([mypath sl 'data' sl 'MyOrganizer.mat'],'myoutputs')
id=strmatch('Fast Fourier Transform (FFT)',{myoutputs.output},'exact');
if ~isempty(id)
myoutputs(id).output='Spectral Analysis';
myoutputs(id).function='plot_spectral(handles)';
myoutputs(id).description='Spectral analysis of SDF, spike times, LFP, or MP by average, type, or heatmap, using Pwelch, periodogram, or FFT';
myoutputs(id).tooltip=sprintf('analysis method: pwelch|gram|fft\nproperty to analyze: sdf|spikes|lfp|mp\norganization: type|all|{gid}|{type} ex: 3920 for {gid} or sca for {type}\noutput: 2d|heatmap|table\nnormalization desired: norm');
save([mypath sl 'data' sl 'MyOrganizer.mat'],'myoutputs','-append')
end
end
end
if exist('myversion.mat','file')
load myversion.mat myversion % Do not change the values in myversion; they are used by Marianne for troubleshooting
handles.myversion=myversion;
else
handles.myversion = 'unknown';
end
%if ismac
logloc=[mypath sl];
%else
% logloc='';
%end
if isdeployed
try
wflag='w';
if exist([logloc 'SimTrackerOutput.log'],'file')
wflag='a';
end
fid = fopen([logloc 'SimTrackerOutput.log'],wflag);
fprintf(fid,'The repos (data storage) directory for SimTracker is:\n%s\n\nAnd the SimTracker directory is located in:\n%s\n\n',mypath, realpath);
fclose(fid);
catch ME
handleME(ME)
end
else
disp('The repos (data storage) directory for SimTracker is:')
disp(mypath)
disp('And the SimTracker application is located in:')
disp(realpath)
end
if exist([mypath sl 'data'],'dir')==0
mkdir([mypath sl 'data'])
end
if ispc % Set the slash type for paths
sl='\';
handles.dl='& ';
else
sl='/';
handles.dl='; ';
end
handles.output = hObject; % Choose default command line output for SimTracker
handles.curses=[];handles.curses.ind=[]; % handles.curses.ind holds the index into RunArray of the currently selected run in the table tbl_runs
if ispc && isempty(strfind(getenv('Path'),'cygwin')) % On PCs, Cygwin is needed for its Linux commands
msgbox('Note that Cygwin or similar must be installed and added to your system Path')
end
% Add the subfolders associated with SimTracker to the MATLAB searchable path
if isdeployed==0 % For deployed applications, these folders are added to the build
if exist([mypath sl 'customout'],'dir')==0
mkdir([mypath sl 'customout']);
end
addpath([mypath sl 'customout']) %#ok<MCAP>
addpath([mypath sl 'data']) %#ok<MCAP>
addpath([realpath sl 'outputtypes']) %#ok<MCAP>
addpath([realpath sl 'tools']) %#ok<MCAP>
addpath([realpath sl 'settings']) %#ok<MCAP>
addpath([realpath sl 'jobscripts']) %#ok<MCAP>
addpath([realpath sl 'ssh2_v2_m1_r4']) %#ok<MCAP>
addpath([realpath sl '..']) %#ok<MCAP>
end
% Load the .mat file containing all the settings for SimTracker
datastructs={'myoutputs','savedfigs','machines','general','myerrors','groups'};
if exist([mypath sl 'data' sl 'MyOrganizer.mat'],'file')==2
load([mypath sl 'data' sl 'MyOrganizer.mat']);
% Load all the settings structures into the handles structure for easy access
for r=1:length(datastructs)
if exist(datastructs{r},'var')==1
handles.(datastructs{r})=eval(datastructs{r}); % myoutputs previously loaded from MyOrganizer.mat
else
handles.(datastructs{r})=[];
end
eval(['clear ' datastructs{r}])
end
handles.savedfigs = [];
end
if isfield(handles,'general')==0 || isempty(handles.general)
handles.general.clean = '-C';
handles.general.savefigs= 1;
handles.general.showfigs= 1;
handles.general.res= 300;
handles.general.crop= 50;
handles.general.outputclick= 1;
if ispc
handles.general.explorer= 'cygstart';
handles.general.picviewer= 'cygstart';
handles.general.pdfviewer= 'cygstart';
handles.general.textviewer= 'cygstart';
elseif ismac
handles.general.explorer= 'open';
handles.general.picviewer= 'open';
handles.general.pdfviewer= 'open';
handles.general.textviewer= 'open';
else %if isunix
handles.general.explorer= 'nautilus';
handles.general.picviewer= 'xdg-open';
handles.general.pdfviewer= 'xdg-open';
handles.general.textviewer= 'xdg-open';
end
handles.general.gsi.flag=0;
handles.general.gsi.user='';
handles.general.gsi.command='GLOBUS_LOCATION=$HOME/globus;MYPROXY_SERVER=myproxy.teragrid.org;MYPROXY_SERVER_PORT=7514;export GLOBUS_LOCATION MYPROXY_SERVER MYPROXY_SERVER_PORT;. $GLOBUS_LOCATION/etc/globus-user-env.sh;myproxy-logon -T -t 12 -l';
handles.general.email= '';
if ispc
dd=dir('C:\*ygwin*');
handles.general.cygpath= ['C:\' dd(1).name];
else
handles.general.cygpath='';
end
otherdiff=1;
if ispc && otherdiff
cygpath=[handles.general.cygpath sl 'bin' sl];
else
cygpath='';
end
if ismac
[r, t]=system([cygpath 'which nrngui']);
else
[r, t]=system([cygpath 'which nrniv']);
end
if r==0
handles.general.neuron= strtrim(deblank(t));
if ispc
handles.general.neuron=[strrep(strrep(handles.general.neuron,'/cygdrive/c','C:'),'/','\') ' -nopython'];
end
else
handles.general.neuron='';
if ismac
[r, t]=system('find /Applications/N* -name nrngui');
if isempty(t)
[r, t]=system('find /Applications/n* -name nrngui');
end
elseif ispc
[r, t]=system('find /cygdrive/c/n* -name nrniv.exe');
else
[r, t]=system('find /nrn* -name nrniv');
if isempty(t)
[r, t]=system('find / -name nrniv');
end
end
handles.general.neuron='';
if ~isempty(t)
newt=regexp(t,'\n','split');
for nt=1:length(newt)
if ~isempty(strfind(newt{nt},'bin'))
handles.general.neuron=newt{nt};
end
end
end
if ispc
handles.general.neuron=[handles.general.neuron ' -nopython'];
end
end
if size(handles.general.neuron,1)>1, handles.general.neuron=strtrim(handles.general.neuron(end,:)); end
if isfield(handles.general,'python')==0 || isempty(handles.general.python)
if ismac && exist('/System/Library/Frameworks/Python.framework/Versions/Current','dir')
handles.general.python='/System/Library/Frameworks/Python.framework/Versions/Current';
else
[ss,rr]=system('which python');
if ss==0
w=strfind(rr,'/');
handles.general.python=[rr(1:w(end)-1)];% sl 'lib' sl 'python'];
else
w=strfind(handles.general.neuron,'bin');
handles.general.python=[handles.general.neuron(1:w-2)];% sl 'lib' sl 'python'];
end
end
end
if size(handles.general.python,1)>1, handles.general.python=strtrim(handles.general.python(end,:)); end
handles.general.roundcoresup= 1;
handles.general.mpi= 0;
handles.general.rpath= '';
handles.general.timelimit= 1;
handles.general.setenv=0;
general=handles.general;
save([mypath sl 'data' sl 'MyOrganizer.mat'],'general','-v7.3')
h=generalset;
uiwait(h);
if exist([mypath sl 'data' sl 'MyOrganizer.mat'],'file')==2
load([mypath sl 'data' sl 'MyOrganizer.mat'],'general');
if exist('general','var')==1
handles.general=general; % general previously loaded from MyOrganizer.mat
else
msgbox('Can''t find general settings');
end
else
msgbox('Can''t find MyOrganizer file');
end
end
if isfield(handles,'groups')==0 || isempty(handles.groups)
handles.groups(1).name = 'theta';
handles.groups(1).date = '08-Aug-2012 15:55:49';
handles.groups(2).name = 'oscillation';
handles.groups(2).date = '08-Jul-2013 17:17:14';
end
if isfield(handles,'myerrors')==0 || isempty(handles.myerrors)
handles.myerrors(1).category=[];
handles.myerrors(1).errorphrase=[];
handles.myerrors(1).description=[];
end
if isfield(handles,'machines')==0 || isempty(handles.machines)
handles.machines(1).Nickname=strtrim(getenv('computername'));
handles.machines(1).Address=strtrim(getenv('computername'));
handles.machines(1).Username=strtrim(getenv('username'));
if isempty(handles.machines(1).Nickname)
[~, mm]=system('hostname');
handles.machines(1).Nickname=strtrim(mm);
handles.machines(1).Address=strtrim(mm);
end
if isempty(handles.machines(1).Username)
[~, mm]=system('whoami');
handles.machines(1).Username=strtrim(mm);
end
handles.machines(1).Repos='';
handles.machines(1).Allocation='';
handles.machines(1).CoresPerNode=[];
handles.machines(1).Queues=[];
handles.machines(1).Script=[];
handles.machines(1).LatestVersion=[];
handles.machines(1).SubCmd=[];
handles.machines(1).GSIOpt= [];
handles.machines(1).gsi=[];
handles.machines(1).Submitchkr='1';
handles.machines(1).Conn='ssh2';
handles.machines(1).TopCmd='nrniv';
handles.machines(2).Nickname='NSG';
handles.machines(2).Address='';
handles.machines(2).Username='';
handles.machines(2).Repos='';
handles.machines(2).Allocation='';
handles.machines(2).CoresPerNode=32;
handles.machines(2).Queues=[];
handles.machines(2).Script=[];
handles.machines(2).LatestVersion=[];
handles.machines(2).SubCmd=[];
handles.machines(2).GSIOpt= [];
handles.machines(2).gsi=[];
handles.machines(2).Submitchkr='1';
handles.machines(2).Conn='ssh2';
handles.machines(2).TopCmd='nrniv';
end
if isfield(handles,'myoutputs')==0 || isempty(handles.myoutputs)
if exist([realpath sl 'defaults' sl 'defaultputs.mat'],'file')
load([realpath sl 'defaults' sl 'defaultputs.mat'],'defaultputs');
handles.myoutputs = defaultputs;
if isfield(handles.myoutputs(1),'tooltip')==0
for mm=1:length(handles.myoutputs)
handles.myoutputs(mm).tooltip='';
end
end
elseif exist(['defaultputs.mat'],'file')
load(['defaultputs.mat'],'defaultputs');
handles.myoutputs = defaultputs;
if isfield(handles.myoutputs(1),'tooltip')==0
for mm=1:length(handles.myoutputs)
handles.myoutputs(mm).tooltip='';
end
end
else
handles.myoutputs(1).output='Spike Raster';
handles.myoutputs(1).description='Which cells spiked and when';
handles.myoutputs(1).function='h=plot_raster(handles)';
handles.myoutputs(1).needs.eval='~isempty(RunArray(ind).ExecutedBy)';
handles.myoutputs(1).tooltip='';
end
handles.savedfigs = [];
end
for r=1:length(datastructs)
eval([datastructs{r} '=handles.(''' datastructs{r} ''');']); % myoutputs previously loaded from MyOrganizer.mat
end
save([mypath sl 'data' sl 'MyOrganizer.mat'],'-struct', 'handles', datastructs{:},'-v7.3');
if exist('cygpath','var')==0 || isempty(cygpath)
otherdiff=1;
if ispc && otherdiff
cygpath=[handles.general.cygpath sl 'bin' sl];
else
cygpath='';
end
end
if isfield(handles.general,'clean')==0
handles.general.clean='-C';
end
if isfield(handles.general,'setenv')==0
handles.general.setenv=0;
end
if isfield(handles.general,'crop')==0
handles.general.crop=50;
end
if isfield(handles.general,'mercurial')==0
if ispc
[~, r]=system([cygpath 'whereis hg']);
turtle=strfind(r,'TortoiseHg');
if isempty(turtle)
handles.general.mercurial='';
else
mystarts=strfind(r,'/cygdrive');
myends=strfind(r,'/hg');
handles.general.mercurial=r(mystarts(find(mystarts<turtle,1,'last')):myends(find(myends>turtle,1,'first')));
handles.general.mercurial=['"' strrep(strrep(handles.general.mercurial,'/cygdrive/c','C:'),'/','\') '"'];
end
else
handles.general.mercurial='';
end
end
if isfield(handles.general,'python')==0 || isempty(handles.general.python)
if ismac && exist('/System/Library/Frameworks/Python.framework/Versions/Current','dir')
handles.general.python='/System/Library/Frameworks/Python.framework/Versions/Current';
else
[ss,rr]=system('which python');
if ss==0
w=strfind(rr,'/');
handles.general.python=[rr(1:w(end)-1)];% sl 'lib' sl 'python'];
else
w=strfind(handles.general.neuron,'bin');
handles.general.python=[handles.general.neuron(1:w-2)];% sl 'lib' sl 'python'];
end
end
end
general = handles.general; %#ok<NASGU>
save([mypath sl 'data' sl 'MyOrganizer.mat'],'general','-append');
if ~isfield(handles.machines,'Submitchkr')
for r=1:length(handles.machines)
switch handles.machines(r).Nickname
case 'stampede'
handles.machines(r).Submitchkr = '~isempty(strfind(string{end},''Submitted batch job''))';
case 'trestles'
handles.machines(r).Submitchkr = '~isempty(strfind(string{end},''.sdsc.edu''))';
case 'hpc'
handles.machines(r).Submitchkr = '~isempty(strfind(string,''has been submitted''))';
otherwise
handles.machines(r).Submitchkr = '1';
end
end
machines = handles.machines; %#ok<NASGU>
save([mypath sl 'data' sl 'MyOrganizer.mat'],'machines','-append');
end
if ~isfield(handles.machines,'Allocation')
for r=1:length(handles.machines)
handles.machines(r).Allocation='';
end
machines = handles.machines; %#ok<NASGU>
save([mypath sl 'data' sl 'MyOrganizer.mat'],'machines','-append');
end
if ~isfield(handles.machines,'Conn')
for r=1:length(handles.machines)
switch handles.machines(r).Nickname
case 'stampede'
handles.machines(r).Conn = 'ssh2';
case 'trestles'
handles.machines(r).Conn = 'ssh2';
case 'hpc'
handles.machines(r).Conn = 'ssh';
otherwise
handles.machines(r).Conn = 'ssh2';
end
end
machines = handles.machines; %#ok<NASGU>
save([mypath sl 'data' sl 'MyOrganizer.mat'],'machines','-append');
end
[~, myname]=system([cygpath 'hostname']); % Get the name of this machine
myname=deblank(myname); % Remove the extra spaces
fl=0; % Add the machine to the machines list if it isn't already there
if isempty(handles.machines)
handles.machines(1).Nickname = myname;
fl=1;
elseif sum(strcmp({handles.machines(:).Nickname},myname))==0 && sum(strcmp({handles.machines(:).Nickname},getenv('computername')))==0
handles.machines(length(handles.machines)+1).Nickname = myname;
fl=1;
end
if fl==1
machines = handles.machines; %#ok<NASGU>
save([mypath sl 'data' sl 'MyOrganizer.mat'],'machines','-append');
clear machines
end
handles=getready2runNRN(handles);
if handles.general.gsi.flag==1 % Then run the GSI command to connect to XSEDE resources
try
[st,~]=system([handles.general.gsi.command ' ' handles.general.gsi.user]);
catch %#ok<CTCH>
msgbox({'Couldn''t start GSI. Turning it off', 'until the GSI command in general settings is corrected'})
handles.general.gsi.flag=0;
end
if st~=0
msgbox({'Couldn''t start GSI. Turning it off', 'until the GSI command in general settings is corrected'})
handles.general.gsi.flag=0;
end
end
% Update handles structure across all functions of the SimTracker
guidata(hObject, handles);
% Add context (right-click) menu to the list of runs
myfunc=@context_copytable_Callback;
myopenfunc=@context_open_Callback;
mycopyfunc=@context_copyrun_Callback;
mycontextmenuh=uicontextmenu('Tag','menu_copyh');
uimenu(mycontextmenuh,'Label','Copy Table','Tag','context_copytableh','Callback',myfunc);
uimenu(mycontextmenuh,'Label','Open Run Folder','Tag','context_copytableh1','Callback',myopenfunc);
uimenu(mycontextmenuh,'Label','Copy Run Info','Tag','context_copytableh2','Callback',mycopyfunc);
set(handles.tbl_runs,'UIContextMenu',mycontextmenuh);
% Add context (right-click) menu to the list of outputs per run
myopenfilefunc=@context_openfile_Callback;
mycontextmenua=uicontextmenu('Tag','menu_copya');
uimenu(mycontextmenua,'Label','Open File Location','Tag','context_copytablea1','Callback',myopenfunc);
uimenu(mycontextmenua,'Label','Open File','Tag','context_copytablea2','Callback',myopenfilefunc);
set(handles.tbl_savedfigs,'UIContextMenu',mycontextmenua);
guidata(hObject, handles); % resave the handles
% Update the uicontrols in the SimTracker to their initial state and populate the popupmenus
if isempty(handles.myerrors)==0
set(handles.txt_error,'String',{handles.myerrors(:).errorphrase},'Value',1)
end
if isempty(handles.groups)==0
set(handles.list_groups,'String',{handles.groups(:).name})
end
set(handles.btn_saverun,'Visible','off') % don't show save run button
setmachinemenu(handles,0) % update machine list, but not editable
% Make sure repository can be loaded or add one if none yet
if exist([mypath sl 'data' sl 'myrepos.mat'],'file')
load([mypath sl 'data' sl 'myrepos.mat'], 'myrepos')
end
stoptry=0;
while exist('myrepos','var')==0 || isempty(myrepos) && stoptry<3
menuitem_new_Callback(handles.menuitem_new, [], handles,1)
if exist([mypath sl 'data' sl 'myrepos.mat'], 'file')
load([mypath sl 'data' sl 'myrepos.mat'], 'myrepos')
end
stoptry=stoptry+1;
end
if ~isfield(handles.general,'rpath')
handles.general.rpath=''; % C:\R\R-3.0.1\bin\Rscript.exe
guidata(hObject, handles); % resave the handles
end
set(handles.menuitem_custom,'Enable','Off')
if isdeployed==0
handles.custmenus=[];
mm=dir([mypath sl 'customout' sl '*.m']);
for m=1:length(mm)
lblname=strrep(mm(m).name(1:end-2),'_',' ');
eval(['handles.custmenus(end+1)=uimenu(handles.menuitem_custom,''Label'',''' lblname ''' ,''Callback'',{@' mm(m).name(1:end-2) ',handles});']);
set(handles.menuitem_custom,'Enable','On')
end
end
q=getcurrepos(handles); %#ok<NASGU>
load([mypath sl 'data' sl 'myrepos.mat'],'myrepos')
set(handles.txt_datalabel,'String',['Current Directory: ' myrepos(q).dir])
pex=get(handles.txt_datalabel,'Extent');
pos=get(handles.txt_datalabel,'Position');
set(handles.txt_datalabel,'Position',[pos(1) pos(2) pex(3) pex(4)]);
handles.parameters=switchSimRun('',myrepos(q).dir);
guidata(hObject, handles); % resave the handles
% Attempt to load saved runs into the SimTracker. If successful, refresh the view
if loadRuns(handles,1) % This tries to load runs and returns 1 if successful
x = mystrfind(get(handles.list_view,'String'),'All');
set(handles.list_view,'Value',x)
list_view_Callback(handles.list_view, [], handles)
end
if isdeployed==0
mm=dir([myrepos(q).dir sl 'customout' sl '*.m']);
for m=1:length(mm)
lblname=strrep(mm(m).name(1:end-2),'_',' ');
eval(['handles.custmenus(end+1)=uimenu(handles.menuitem_custom,''Label'',''' lblname ''' ,''Callback'',{@' mm(m).name(1:end-2) ',handles});']);
set(handles.menuitem_custom,'Enable','On')
end
end
guidata(hObject, handles);
catch ME
handleME(ME)
end
% --- Outputs from this function are returned to the command line.
function varargout = SimTracker_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% Get default command line output from handles structure
varargout{1} = handles.output;
function list_view_Callback(hObject, eventdata, handles) % --- Executes on selection change in list_view.
% This function refreshes the view of the runs in the table tbl_runs
try
RefreshList(hObject, eventdata, handles)
catch ME
handleME(ME)
end
% --- Executes during object creation, after setting all properties.
function list_view_CreateFcn(hObject, eventdata, handles) %#ok<INUSD,DEFNU>
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function menu_file_Callback(hObject, eventdata, handles) %#ok<INUSD,DEFNU>
% --------------------------------------------------------------------
function menuitem_new_Callback(hObject, eventdata, handles,varargin)
% This function starts a new SimTracker repository in an already created folder
try
if isempty(varargin)
NewRepos(hObject, eventdata, handles)
else
myans=questdlg('Your ''repos'' directory contains no repositories known to SimTracker. Would you like to download a sample model repository?','Download sample repository?','ringdemo','ca1','Don''t Download','ringdemo');
NewRepos(hObject, eventdata, handles,myans)
end
catch ME
handleME(ME)
end
% --------------------------------------------------------------------
function menuitem_export_Callback(hObject, eventdata, handles)
% This function puts all the data currently selected in the table tbl_runs
% into a tab delimited file that can be opened by spreadsheet applications
global cygpath cygpathcd mypath RunArray sl
try
% Find the RunArray indices for all selected runs
tmpdata=get(handles.tbl_runs,'Data');
handles.curses.indices = [];
for r=1:size(handles.indices,1)
myrow = handles.indices(r,1);
RunName = tmpdata(myrow,1);
handles.curses.indices(r) = find(strcmp(RunName,{RunArray.RunName})==1, 1 );
end
% Decide where to store the exported files
PathName = uigetdir(RunArray(end).ModelDirectory, 'Pick a Location to save the exported runs.');
%[FileName,PathName] = uiputfile('*.txt','Export tab delimited file');
if PathName==0
return
end
% fid=fopen([PathName FileName],'w');
%
% headerstr='';
% formatstr='';
% cmdstr = '';
% parameters=handles.parameters;%load([mypath sl 'data' sl 'parameters.mat'],'parameters')
%
% % Design the header of the file and the print command for printing data
% for r=1:length(parameters)
% headerstr=[headerstr strrep(parameters(r).nickname,'%','%%') '\t' ]; %#ok<AGROW>
%
% formatstr=[formatstr parameters(r).format '\t']; %#ok<AGROW>
%
% cmdstr = [cmdstr 'RunArray(x).' parameters(r).name ', ']; %#ok<AGROW>
% end
%
% headerstr=[headerstr(1:end-1) 'n'];
% formatstr=[formatstr(1:end-1) 'n'];
% cmdstr=cmdstr(1:end-2);
%
% % Print all data for each run using the print command
% fprintf(fid,headerstr);
for r=1:length(handles.curses.indices)
x=handles.curses.indices(r); %#ok<NASGU>
% evalstr=['fprintf(fid,''' formatstr ''', ' cmdstr ');'];
% eval(evalstr);
% export results (zip files)
if ispc
[bb, cc]=system(cygwin([' tar -zcvf ' PathName sl RunArray(handles.curses.indices(r)).RunName '.tgz -C ' RunArray(handles.curses.indices(r)).ModelDirectory sl 'results .' sl RunArray(handles.curses.indices(r)).RunName sl ' ']));
else
[bb, cc]=system(['cd ' RunArray(handles.curses.indices(r)).ModelDirectory handles.dl ' tar -zcvf ' PathName sl RunArray(handles.curses.indices(r)).RunName '.tgz results' sl RunArray(handles.curses.indices(r)).RunName]);
end
if bb~=0
msgbox(cc)
disp(cc)
end
end
% fclose(fid);
catch ME
handleME(ME)
end
% --------------------------------------------------------------------
function menuitem_import_Callback(hObject, eventdata, handles)
% This function
global cygpath cygpathcd mypath RunArray sl
try
q=getcurrepos(handles); %#ok<NASGU>
load([mypath sl 'data' sl 'myrepos.mat'],'myrepos')
[FileName,PathName] = uigetfile({'*.gz;*.tgz;*.tar','Compressed Results Folder(s)';'*.zip','Zipped Results Folder(s)';'*.txt','Text file generated by SimTracker Export';'*.*','All file(s)'},'Select individual zipped files or choose a SimTracker-generated text file with the list of runs to import:','MultiSelect', 'on');
if isnumeric(PathName) && PathName==0
return
end
if iscell(FileName)==0 && strcmp(FileName(end-3:end),'txt')
NewList=textread([PathName FileName],'%s%*[^\n]');
for r=2:length(NewList) % r=1 is the header, "run"
if length(RunArray)>0 && ~isempty(strmatch(NewList{r},{RunArray.RunName},'exact'))
myans=questdlg(['Run ' NewList{r} ' already exists in the SimTracker. Rename new run?'],'Duplicate Names','Rename','Skip','Rename');
switch myans
case 'Rename'
if ispc
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.tgz -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']));
else
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.tgz -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']);
end
NewList{r}=[NewList{r} '_RenamedImported'];
case 'Skip'
continue
end
else
if ispc
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.tgz -C ' myrepos(q).dir sl 'results']));
else
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.tgz -C ' myrepos(q).dir sl 'results']);
end
end
ind=length(RunArray)+1;
RunArray(ind)=SimRun(NewList{r},myrepos(q).dir,'0');
%LocalDirectory = RunArray(ind).ModelDirectory;
if ~isempty(dir([myrepos(q).dir sl 'results' sl RunArray(ind).RunName sl 'spikeraster_*.dat']))
ConcatSpikeRaster(handles,ind)
SortSpikeRaster(handles,ind)
end
loadexecdata(RunArray(ind));
%RunArray(ind).RemoteDirectory = RunArray(ind).ModelDirectory;
%RunArray(ind).ModelDirectory = LocalDirectory;
GetJobNumber(ind)
if ~isempty(dir([myrepos(q).dir sl 'results' sl RunArray(ind).RunName sl 'subconns_*.dat']))
ConcatSubconns(handles,ind)
end
end
else
NewList={};
if iscell(FileName)==0
FileName={FileName};
end
% if strcmp(FileName{1}(end-2:end),'txt')
% NewList=textread([PathName FileName],'%s%*[^\n]');
% end
for r=1:length(FileName)
gzflag=0;
targzflag=0;
filextl=4;
switch FileName{r}(end-2:end)
case 'zip'
zipflag=1;
% case 'txt'
% msgbox('Sorry, you can only select a single txt file for importing.')
% return
case 'tgz'
zipflag=0;
otherwise % treat like tgz
if strcmp(FileName{r}(end-6:end),'.tar.gz')
targzflag=1;
filextl=7;
elseif strcmp(FileName{r}(end-2:end),'.gz')
gzflag=1;
filextl=3;
end
zipflag=0;
end
NewList{r}=FileName{r}(1:end-filextl);
if length(RunArray)>0 && ~isempty(strmatch(NewList{r},{RunArray.RunName},'exact'))
myans=questdlg(['Run ' NewList{r} ' already exists in the SimTracker. Rename new run?'],'Duplicate Names','Rename','Skip','Rename');
switch myans
case 'Rename'
if ispc
if zipflag
[bb, cc]=system(cygwin([' unzip ' PathName NewList{r} '.zip -d ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']));
elseif targzflag
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-5:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']));
elseif gzflag
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-1:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']));
else
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-2:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']));
end
else
if zipflag
[bb, cc]=system([' unzip ' PathName NewList{r} '.zip -d ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']);
elseif targzflag
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-5:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']);
elseif gzflag
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-1:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']);
else
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-2:end) ' -C ' PathName handles.dl ' mv ' PathName NewList{r} ' ' myrepos(q).dir sl 'results' sl NewList{r} '_RenamedImported']);
end
end
NewList{r}=[NewList{r} '_RenamedImported'];
case 'Skip'
continue
end
else
if ispc
if zipflag
[bb, cc]=system(cygwin([' unzip ' PathName NewList{r} '.zip -d ' myrepos(q).dir sl 'results']));
elseif targzflag
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-5:end) ' -C ' myrepos(q).dir sl 'results']));
elseif gzflag
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-1:end) ' -C ' myrepos(q).dir sl 'results']));
else
[bb, cc]=system(cygwin([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-2:end) ' -C ' myrepos(q).dir sl 'results']));
end
else
if zipflag
[bb, cc]=system([' unzip ' PathName NewList{r} '.zip -d ' myrepos(q).dir sl 'results']);
elseif targzflag
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-5:end) ' -C ' myrepos(q).dir sl 'results']);
elseif gzflag
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-1:end) ' -C ' myrepos(q).dir sl 'results']);
else
[bb, cc]=system([' tar -xzf ' PathName NewList{r} '.' FileName{r}(end-2:end) ' -C ' myrepos(q).dir sl 'results']);
end
end
end
ind=length(RunArray)+1;
RunArray(ind)=SimRun(NewList{r},myrepos(q).dir,'0');
%LocalDirectory = RunArray(ind).ModelDirectory;
if ~isempty(dir([myrepos(q).dir sl 'results' sl RunArray(ind).RunName sl 'spikeraster_*.dat']))
RunArray(ind).NumProcessors=length(dir([myrepos(q).dir sl 'results' sl RunArray(ind).RunName sl 'spikeraster_*.dat']));
ConcatSpikeRaster(handles,ind)
SortSpikeRaster(handles,ind)
end
loadexecdata(RunArray(ind));
%RunArray(ind).RemoteDirectory = RunArray(ind).ModelDirectory;
%RunArray(ind).ModelDirectory = LocalDirectory;
GetJobNumber(ind)
if ~isempty(dir([myrepos(q).dir sl 'results' sl RunArray(ind).RunName sl 'subconns_*.dat']))
ConcatSubconns(handles,ind)
end
end
NewList{length(NewList)+1}='header';
end
saveRuns(handles)
set(handles.list_view,'Value',1)
list_view_Callback(handles.list_view, [], handles);
msgbox([num2str(length(NewList)-1) ' runs have been imported.'])
catch ME
handleME(ME)
end
% --------------------------------------------------------------------
function menuitem_quit_Callback(hObject, eventdata, handles) %#ok<DEFNU>
figure1_CloseRequestFcn(handles.figure1, eventdata, handles)
% --------------------------------------------------------------------
function menuitem_parameterlist_Callback(hObject, eventdata, handles) %#ok<DEFNU>
global mypath sl
% This function allows you to edit the parameters used by the SimTracker
try
btn=questdlg('Before changing parameters, it is recommended that you backup your data','Backup Prompt','Backup','Don''t Backup','Backup');
if strcmp(btn,'Backup')==1
menuitem_backup_Callback(handles.menuitem_backup, [], handles)
end
h=parameterset;
uiwait(h);
if isdeployed
msgbox({'The parameters have been updated. If you clicked the Print button', ...
'which updates the parameters file in your model repository,', ...
'you must also commit the changes to a new version.'})
else
msgbox({'The parameters have been updated. You must now quit SimTracker', ...
', enter ''clear all'' at the command line, and then restart SimTracker.', ...
'If you clicked the Print button which updates the parameters file in', ...
'your model repository, you must also commit the changes to a new version.'})
end
q=getcurrepos(handles); %#ok<NASGU>
load([mypath sl 'data' sl 'myrepos.mat'],'myrepos')
handles.parameters=switchSimRun({myrepos.dir},myrepos(q).dir);
guidata(hObject, handles); % resave the handles
try
list_view_Callback(handles.list_view, [], handles);
CellSelected(hObject, [], handles)
catch
disp('Unable to refresh view until SimTracker is closed, all variables cleared, and SimTracker restarted.')
end
catch ME
handleME(ME)
end
% --------------------------------------------------------------------
function menuitem_general_Callback(hObject, eventdata, handles) %#ok<DEFNU>
global cygpath cygpathcd mypath sl
% This function allows you to edit general settings of the SimTracker
try
h=generalset;
uiwait(h);
if exist([mypath sl 'data' sl 'MyOrganizer.mat'],'file')==2
load([mypath sl 'data' sl 'MyOrganizer.mat']);
else
msgbox('Can''t find MyOrganizer file');
end
if exist('general','var')==1
handles.general=general; % general previously loaded from MyOrganizer.mat
else
msgbox('Can''t find general settings');
end
guidata(hObject, handles);
catch ME