forked from samuellab/mindcontrol-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview_wYAML_v9.m
1983 lines (1530 loc) · 75 KB
/
preview_wYAML_v9.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
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
% Copyright 2010 Andrew Leifer et al <[email protected]>
% This file is part of Mindcontrol-analysis.
%
% Mindcontrol-analysis is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Mindcontrol-analysis is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with mindcontrol-analysis. If not, see <http://www.gnu.org/licenses/>.
function varargout = preview_wYAML_v9(varargin)
% PREVIEW_WYAML_V9 M-file for preview_wYAML_v9.fig
% PREVIEW_WYAML_V9, by itself, creates a new PREVIEW_WYAML_V9 or raises the existing
% singleton*.
%
% H = PREVIEW_WYAML_V9 returns the handle to a new PREVIEW_WYAML_V9 or the handle to
% the existing singleton*.
%
% PREVIEW_WYAML_V9('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PREVIEW_WYAML_V9.M with the given input arguments.
%
% PREVIEW_WYAML_V9('Property','Value',...) creates a new PREVIEW_WYAML_V9 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before preview_wYAML_v9_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to preview_wYAML_v9_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
%
% This is the main GUI to preview data that is outputted from mindcontrol
% software. The gui was originally written by Chris Fang-Yen
%
%
% For the most up to date version of this software, see:
% http://github.com/samuellab/mindcontrol
%
% NOTE: If you use any portion of this code in your research, kindly cite:
% Leifer, A.M., Fang-Yen, C., Gershow, M., Alkema, M., and Samuel A. D.T.,
% "Optogenetic manipulation of neural activity with high spatial resolution
% in freely moving Caenorhabditis elegans," Nature Methods, Submitted
% (2010).
%
% Edit the above text to modify the response to help preview_wYAML_v9
% Last Modified by GUIDE v2.5 25-Jun-2010 16:48:53
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @preview_wYAML_v9_OpeningFcn, ...
'gui_OutputFcn', @preview_wYAML_v9_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 preview_wYAML_v9 is made visible.
function preview_wYAML_v9_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 preview_wYAML_v9 (see VARARGIN)
% Choose default command line output for preview_wYAML_v9
handles.output = hObject;
handles.CamFrameNumber = [];
handles.Head_data = [];
handles.Tail_data = [];
handles.BoundaryAx_data = [];
handles.BoundaryAy_data = [];
handles.BoundaryBx_data = [];
handles.BoundaryBy_data = [];
handles.DLPIsOn_data = [];
handles.IllumSegCenter_data = [];
handles.IllumSegRadius_data = [];
handles.IllumNullLeftRightBoth_data = [];
handles.SegmentedCenterlinex_data = [];
handles.SegmentedCenterliney_data = [];
handles.FloodLightIsOn_data = [];
handles.IllumRectOrigin_data = [];
handles.IllumRectRadius_data = [];
handles.mmVidObj=[];
% Update handles structure
guidata(hObject, handles);
%Make sure dependencies are installed...
if isempty(which('newid','-all'))
errordlg('You are missing a dependency. Please download newid from mathworks and follow the directions at http://www.mathworks.com/support/solutions/en/data/1-39UWQT/index.html?product=ML&solution=1-39UWQT');
disp('http://www.mathworks.com/support/solutions/en/data/1-39UWQT/index.html?product=ML&solution=1-39UWQT');
end
%marc's basic routines
addpath('basic routines')
if isempty(which('lowpass1d','-all'))
errordlg('You are missing Marc Gershow`s "basic routines", or they have not been correctly added to the path. Please add them to the path.');
error('You are missing Marc Gershow`s "basic routines", or they have not been correctly added to the path. Please add them to the path.');
end
% UIWAIT makes preview_wYAML_v9 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = preview_wYAML_v9_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% SELECT FILE BUTTON
% --- Executes on button press in pushbutton1.
% This is the "load image button"
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
contents = get(handles.popupmenu1,'String') ;
filetype = contents{get(handles.popupmenu1,'Value')};
prefix = get(handles.edit_prefix, 'String');
[filename,pathname] = uigetfile({['*' filetype]}, 'select file', prefix);
if ~strcmp(filetype, '.avi')
tmp = zeros(1,length(filename)-4);
for kk=1:length(filename)-4
tmp(kk) = length(str2num(filename(kk)));
end
last_nondigit = find(~tmp, 1, 'last'); % position of last non-numeric character not including extension
prefix = [pathname filename(1:last_nondigit)];
numdigits = length(filename) - last_nondigit-4;
else
prefix = [pathname filename(1:end-4)];
numdigits = 0;
tmp = aviinfo([pathname filename]);
numframes = tmp.NumFrames;
set(handles.edit_numframes, 'String', num2str(numframes));
end
set(handles.edit_prefix, 'String', prefix);
%Update the frame number from the box in the current frame
current_HUDS_frame = str2num(get(handles.edit_currentframe, 'String'));
numspec = ['%0' num2str(numdigits) 'd'];
set(handles.edit15, 'String', numspec);
%Load in Videa with mmreader
prefix = get(handles.edit_prefix, 'String');
if strcmp(filetype, '.avi')
filetype = contents{get(handles.popupmenu1,'Value')};
handles.mmVidObj=mmreader([prefix filetype]);
guidata(hObject, handles);
end
img = load_img(handles,current_HUDS_frame); %1
display_img(handles,img);
function out=load_img(handles,current_frame)
contents = get(handles.popupmenu1,'String') ;
filetype = contents{get(handles.popupmenu1,'Value')};
prefix = get(handles.edit_prefix, 'String');
numspec = get(handles.edit15, 'String');
if (current_frame > 9999) && (strcmp(numspec, '%04d'))
numspec = '%05d';
end
try
if strcmp(filetype, '.avi')
%read in the frame using multimedia reader object
tempframe = read(handles.mmVidObj,current_frame);
out = tempframe(:,:,1);
else
out = imread([prefix num2str(current_frame, numspec) filetype]);
end
catch
disp('error');
end
function display_img(handles,img)
current_frame = str2num(get(handles.edit_currentframe, 'String'));
decim = str2num(get(handles.edit3, 'String'));
if decim>1
decim_filter = ones(decim,decim)/(decim*decim);
img = imfilter(img, decim_filter, 'same');
img = img(1:decim:end,1:decim:end);
end
if get(handles.checkbox4, 'Value') % autoscale ON
lim1=min(min(img));
lim2=max(max(img));
else
lim1 = str2double(get(handles.edit8,'String'));
lim2 = str2double(get(handles.edit9,'String'));
end
if get(handles.checkbox1, 'Value') % increase brightness
lim1=min(min(img));
lim2 = lim1+ 0.1*(max(max(img)) - lim1);
end
if get(handles.docrop, 'Value')
cropx1 = str2num(get(handles.cropx1, 'String'));
cropx2 = str2num(get(handles.cropx2, 'String'));
cropy1 = str2num(get(handles.cropy1, 'String'));
cropy2 = str2num(get(handles.cropy2, 'String'));
else
cropx1 = 1;
cropx2 = size(img,2);
cropy1 = 1;
cropy2 = size(img,1);
end
if ~get(handles.rotate90, 'Value')
imagesc(img(cropy1:cropy2,cropx1:cropx2), [lim1 lim2]);
else
imagesc(img(cropy1:cropy2,cropx2:-1:cropx1)', [lim1 lim2]);
end
axis image;
if get(handles.checkbox3, 'Value')
colormap jet;
else
colormap gray;
end
drawnow;
% --- Executes on button press in pushbutton2. % ANALYZE
function pushbutton2_Callback(hObject, eventdata, handles)
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton2.
function pushbutton2_ButtonDownFcn(hObject, eventdata, handles)
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% point = get(gca,'CurrentPoint')
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
%
% ACCEPT KEYPRESS AND UPDATE IMAGE
%
% --- Executes on key press with focus on slider2 and no controls selected.
function slider2_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
contents = get(handles.popupmenu1,'String') ;
filetype = contents{get(handles.popupmenu1,'Value')};
%the box tells us the current HUDS frame
current_frame = str2num(get(handles.edit_currentframe, 'String'));
prefix = get(handles.edit_prefix, 'String');
numspec = get(handles.edit15, 'String');
UpdateAnnotations=1;
f=gcf;
val=double(get(f,'CurrentCharacter'));
% idx = str2num(get(handles.text2, 'String'));
old_frame = current_frame;
%disp(val);
switch val
case 28 % left arrow
current_frame=current_frame-1;
UpdateAnnotations=0;
case 29 % right arrow
current_frame=current_frame+1;
UpdateAnnotations=0;
case 30 % up arrow
current_frame=current_frame-10;
UpdateAnnotations=0;
case 31 % down arrow
current_frame=current_frame+10;
UpdateAnnotations=0;
case 97 % A
current_frame=current_frame-20;
case 115 % S
current_frame=current_frame+20;
case 48 % 0
current_frame=current_frame-100;
case 46 % .
current_frame=current_frame+100;
case 49 % 1
set(handles.edit_T1, 'String', num2str(current_frame));
case 50 % 2
set(handles.edit_T4, 'String', num2str(current_frame));
case 103 %g
hframe=str2num(char(newid('Go to HUDS frame number:','Jump to HUDS frame number')));
mframe=find(handles.frameindex(:,1)==hframe);
if ~isempty(mframe)
current_frame=mframe;
else
msgbox('That number is not valid')
end
case 45 % - (jump to previous DLP off->on event)
%find all off->on events
q=find(handles.dlpindex(:,3)==1);
%Find the most recent off->on event
current_frame = max(q(find(q<current_frame)));
clear q;
case 43 % + (jump to next DLP off->on event)
%find all off->on events
q=find(handles.dlpindex(:,3)==1);
%Find the next off->on event
current_frame = min(q(find(q>current_frame)));
clear q;
case 109% m for magic
%Ask the user for input in terms of seconds.
seconds_pre=str2num(char(newid('Enter number of seconds BEFORE dlp event:','Magically analyze and export a DLP on event')));
if isempty(seconds_pre)
%User canceled the magic
disp('User canceled the magic.');
return
end
seconds_post=str2num(char(newid('Enter number of seconds AFTER dlp event:','Magically analyze and export a DLP on event')));
if isempty(seconds_post)
%User canceled the magic
disp('User canceled the magic.');
return
end
%find the nearest off->on event
q=find(handles.dlpindex(:,3)==1);
[blah, ind]=min(abs(q-current_frame));
t2=q(ind);
clear q;
%find the subsequent on->off event
q=find(handles.dlpindex(:,3)==-1);
t3=min(q(find(q>t2)));
clear q;
%Find the frame number corresponding to the timestamp before and after that we want
t1=findClosest(handles.time,handles.time(t2)-seconds_pre);
t4=findClosest(handles.time,handles.time(t3)+seconds_post);
set(handles.edit_T1, 'String', num2str(t1));
set(handles.edit_T2, 'String', num2str(t2));
set(handles.edit_T3, 'String', num2str(t3));
set(handles.edit_T4, 'String', num2str(t4));
otherwise
end
if isempty(current_frame)
current_frame=old_frame;
end
if current_frame < 1
current_frame = 1;
end
set(handles.edit_currentframe, 'String', num2str(current_frame));
%Find hframe (HUDS) corresponding to mframe (movie) and set that.
set(handles.HUDSFrame, 'String', num2str(handles.frameindex(current_frame,1)));
try
%Update the image
img = load_img(handles,current_frame);
display_img(handles,img);
%Update the Contextual annotation display
if UpdateAnnotations
filename=handles.YAML_filename;
pathname=handles.YAML_pathname;
[blah,text]=dos(['python showAnnotation.py ',pathname,'index.yml ', filename(1:(end-5)), ' ', num2str(handles.frameindex(current_frame,1)), ' 3000']);
set(handles.ContextualAnnotations,'String',text);
end
set(handles.status, 'String', 'OK');
catch
current_frame = old_frame;
set(handles.edit_currentframe, 'String', num2str(current_frame));
set(handles.status, 'String', 'Out of range or file error');
end
function edit_T1_Callback(hObject, eventdata, handles)
% hObject handle to edit_T1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_T1 as text
% str2double(get(hObject,'String')) returns contents of edit_T1 as a double
% --- Executes during object creation, after setting all properties.
function edit_T1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_T1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_T4_Callback(hObject, eventdata, handles)
% hObject handle to edit_T4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_T4 as text
% str2double(get(hObject,'String')) returns contents of edit_T4 as a double
% --- Executes during object creation, after setting all properties.
function edit_T4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_T4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on key press with focus on pushbutton3 and no controls selected.
function pushbutton3_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
current_frame = str2num(get(handles.edit_currentframe, 'String'));
set(handles.edit_T1, 'String', num2str(current_frame));
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
current_frame = str2num(get(handles.edit_currentframe, 'String'));
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit_T4, 'String', num2str(current_frame));
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton4.
function pushbutton4_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton5.
function pushbutton5_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox1
% --- Executes on button press in checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox3
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
current_frame = str2num(get(handles.edit_currentframe, 'String'))
set(handles.edit_T2, 'String', num2str(current_frame));
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
current_frame = str2num(get(handles.edit_currentframe, 'String'))
% current_frame
set(handles.edit_T3, 'String', num2str(current_frame));
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit_T2_Callback(hObject, eventdata, handles)
% hObject handle to edit_T2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_T2 as text
% str2double(get(hObject,'String')) returns contents of edit_T2 as a double
% --- Executes during object creation, after setting all properties.
function edit_T2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_T2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit_T3_Callback(hObject, eventdata, handles)
% hObject handle to edit_T3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_T3 as text
% str2double(get(hObject,'String')) returns contents of edit_T3 as a double
% --- Executes during object creation, after setting all properties.
function edit_T3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_T3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton6.
function pushbutton6_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('pushbutton8');
[x y] = ginput(1);
set(handles.edit6, 'String', num2str(round(x)));
set(handles.edit7, 'String', num2str(round(y)));
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton8.
function pushbutton8_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function slider4_Callback(hObject, eventdata, handles)
% hObject handle to slider4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider4_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject handle to checkbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of checkbox4
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in docrop.
function docrop_Callback(hObject, eventdata, handles)
% hObject handle to docrop (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of docrop
function cropy1_Callback(hObject, eventdata, handles)
% hObject handle to cropy1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of cropy1 as text
% str2double(get(hObject,'String')) returns contents of cropy1 as a
% double
% --- Executes during object creation, after setting all properties.
function cropy1_CreateFcn(hObject, eventdata, handles)
% hObject handle to cropy1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function cropy2_Callback(hObject, eventdata, handles)
% hObject handle to cropy2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of cropy2 as text
% str2double(get(hObject,'String')) returns contents of cropy2 as a double
% --- Executes during object creation, after setting all properties.
function cropy2_CreateFcn(hObject, eventdata, handles)
% hObject handle to cropy2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function cropx1_Callback(hObject, eventdata, handles)
% hObject handle to cropx1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of cropx1 as text
% str2double(get(hObject,'String')) returns contents of cropx1 as a double
% --- Executes during object creation, after setting all properties.
function cropx1_CreateFcn(hObject, eventdata, handles)
% hObject handle to cropx1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function cropx2_Callback(hObject, eventdata, handles)
% hObject handle to cropx2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of cropx2 as text
% str2double(get(hObject,'String')) returns contents of cropx2 as a double
% --- Executes during object creation, after setting all properties.
function cropx2_CreateFcn(hObject, eventdata, handles)
% hObject handle to cropx2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in cropbutton.
function cropbutton_Callback(hObject, eventdata, handles)
% hObject handle to cropbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
zoom on;
pause;
zoom off;
cropx = xlim;
cropy = ylim;
set(handles.cropx1, 'String', num2str(round(cropx(1))));
set(handles.cropx2, 'String', num2str(round(cropx(2))));
set(handles.cropy1, 'String', num2str(round(cropy(1))));
set(handles.cropy2, 'String', num2str(round(cropy(2))));
set(handles.docrop, 'Value', 1);
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over cropbutton.
function cropbutton_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to cropbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in rotate90.
function rotate90_Callback(hObject, eventdata, handles)
% hObject handle to rotate90 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)