-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCAPE_QuickView_v1_kinetix.m
1301 lines (1140 loc) · 46.5 KB
/
SCAPE_QuickView_v1_kinetix.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
function varargout = SCAPE_QuickView_v1_kinetix(varargin)
% SCAPE_QUICKVIEW_V1_KINETIX MATLAB code for SCAPE_QuickView_v1_kinetix.fig
% SCAPE_QuickView allows you to quickly visualize SCAPE_data in 3 dimensions, create time
% courses and save summary movies and screenshots. Data can be visualized in
% dual color if the RGBtransform.mat file has already been created.
% Developed by the Hillman Lab at Columbia University (2018)
% Edit the above text to modify the response to help SCAPE_QuickView_v1_kinetix
% Last Modified by GUIDE v2.5 01-Aug-2022 16:53:21
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SCAPE_QuickView_v1_kinetix_OpeningFcn, ...
'gui_OutputFcn', @SCAPE_QuickView_v1_kinetix_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 %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Open and Output Functions %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function SCAPE_QuickView_v1_kinetix_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
try clear_data = evalin('base', 'clear_data');
catch
clear_data = 0;
end
try
handles.data = evalin('base', 'SCAPE_data');
handles.info = evalin('base', 'info');
if clear_data == 1; evalin('base', 'clear SCAPE_data');
disp('workspace data cleared - Click "write data to workspace" to transfer back when you close!');
end
catch
msgbox('Please Load Data to Workspace in advance');
end
handles.RGB = varargin{1};
% Set default slice numbers
handles.t = 1;
handles.xslice = 1;
handles.yslice = 1;
handles.zslice = 1;
if ~handles.RGB
handles.ss = size(handles.data);
% Set axes
handles.y = [1:handles.ss(1)]-1;
handles.x = [1:handles.ss(3)]-1;
handles.z = [1:handles.ss(2)]-1;
% Set default colormap
if (length(handles.ss) == 3)
handles.maxDataColor = double(squeeze(max(max(max(handles.data)))));
elseif (length(handles.ss) == 4)
handles.maxDataColor = double(squeeze(max(max(max(max(handles.data))))));
end
set(handles.colorMaxTextbox, 'String', num2str(handles.maxDataColor));
set(handles.colorMinSlider, 'Value', (110/handles.maxDataColor));
% keyboard
set(handles.colorMaxSlider, 'Value', (1));
else
% Data is dual color - align red and green and set scaling individually
try RGBname = evalin('base','RGBname');
FilePath2 = RGBname;
catch
fname = handles.info.scanName;
names = dir(fullfile(handles.info.storage_dir, sprintf('RGBtransform*%s*.mat',fname)));
for k = 1:size(names,1)
tt(k) = names(k).datenum;
end
% [o oo] = max(tt);
if isempty(names)
FilePath2= fullfile(handles.info.storage_dir, 'RGBtransform.mat');
else
FilePath2 = [names(oo).folder, '/', names(oo).name];
end
end
[out] = questdlg(sprintf('Using: %s -- ok?',FilePath2),'Confirm RGB Transform','Ok','No, chose a different one','Ok');
if strcmp(out,'Ok')==0;
[filename, pathname] = uigetfile([handles.info.storage_dir],'chose RGB transform file to use');
FilePath2 = [pathname '/' filename];
end
% FilePath2 = fullfile(handles.info.storage_dir, 'RGBtransform.mat');
if (2 == exist(FilePath2, 'file'))
load(FilePath2)
newss = size(handles.data);
transforms.ss = newss;
%update x reference points
tempxg = transforms.ss(1)/2-transforms.xg; %distance of x point from centerline of camera width on alignment image
transforms.xg = round(newss(1)/2-tempxg); %accounts for differences in camera FOV width
tempxr = transforms.xr - transforms.ss(1)/2; %distance of x point from centerline of camera width on alignment image
transforms.xr = round(newss(1)/2+tempxr); %accounts for differences in camera FOV width
%update z reference points
tempzg = transforms.ss(2)/2-transforms.zg; %distance of z point from centerline of camera height on alignment image
transforms.zg = round(newss(2)/2-tempzg); %accounts for differences in camera FOV height
tempzr = transforms.ss(2)/2-transforms.zr; %distance of z point from centerline of camera height on alignment image
transforms.zr = round(newss(2)/2-tempzr); %accounts for differences in camera FOV height
handles.xg2 = transforms.xg;
handles.xr2 = transforms.xr;
handles.yr2 = transforms.yr;
handles.yg2 = transforms.yg;
handles.zr2 = transforms.zr;
handles.zg2 = transforms.zg;
xg = handles.xg2;
xr = handles.xr2;
yr = handles.yr2;
yg = handles.yg2;
zr = handles.zr2;
zg = handles.zg2;
try
scaleR = transforms.scaleR; % The code is RED/GREEN shifted!!
catch
scaleR = 1; % If there is not scaleR
end
left = floor(min([xg xr]))-1;
right = floor(size(handles.data,1)-max([xg xr]));
top = floor(min([zr zg]))-1;
bot = floor(size(handles.data,2)-max([zr zg]));
topy = floor(min([yr yg]))-1;
boty = floor(size(handles.data,3)-max([yr yg]));
if length(size(handles.data))>3
red = (handles.data(round(xg+[-left:right]),round(zg+[-top:bot]),:,:));
green = (handles.data(round(xr+[-left:right]),round(zr+[-top:bot]),:,:));
else
red = (handles.data(round(xg+[-left:right]),round(zg+[-top:bot]),:));
green = (handles.data(round(xr+[-left:right]),round(zr+[-top:bot]),:));
end
% scale correction for 1st gen imagesplitter
if scaleR~=1
red = imresize(red,scaleR*[size(red,1) size(red,2)]);
if scaleR <1
dif1 = size(green,1) - size(red,1);
dif2 = size(green,2) - size(red,2);
x1 = floor(dif1/2) ;
x2 = ceil(dif1/2);
y1 = floor(dif2/2);
y2 = ceil(dif2/2);
red = padarray(red,[x1 y1],0,'pre');
red = padarray(red,[x2 y2],0,'post');
else
dif1 = size(red,1) - size(green,1);
dif2 = size(red,2) - size(green,2);
x1 = floor(dif1/2)+1; x2 = ceil(dif1/2);
y1 = floor(dif2/2)+1; y2 = ceil(dif2/2);
if length(size(handles.data))>3
red = red(x1:end-x2,y1:end-y2,:,:);
else
red = red(x1:end-x2,y1:end-y2,:);
end
end
end
handles = rmfield(handles,'data'); %clear handles.data % beth banana
handles.ss = size(red);
% Set axes
handles.y = [1:handles.ss(1)]-1;
handles.x = [1:handles.ss(3)]-1;
handles.z = [1:handles.ss(2)]-1;
% Set default colormap
% red
if (length(handles.ss) == 3)
handles.maxredColor = double(squeeze(max(max(max(red)))));
elseif (length(handles.ss) == 4)
handles.maxredColor = double(squeeze(max(max(max(max(red))))));
end
if (length(handles.ss) == 3)
handles.maxredColor = double(squeeze(max(max(max(red)))));
elseif (length(handles.ss) == 4)
handles.maxredColor = double(squeeze(max(max(max(max(red))))));
end
set(handles.redMaxTextbox, 'String', num2str(handles.maxredColor));
set(handles.redMinSlider, 'Value', (110/handles.maxredColor));
set(handles.redMaxSlider, 'Value', (1))
% green
if (length(handles.ss) == 3)
handles.maxgreenColor = double(squeeze(max(max(max(green)))));
elseif (length(handles.ss) == 4)
handles.maxgreenColor = double(squeeze(max(max(max(max(green))))));
end
if (length(handles.ss) == 3)
handles.maxgreenColor = double(squeeze(max(max(max(green)))));
elseif (length(handles.ss) == 4)
handles.maxgreenColor = double(squeeze(max(max(max(max(green))))));
end
set(handles.greenMaxTextbox, 'String', num2str(handles.maxgreenColor));
set(handles.greenMinSlider, 'Value', (110/handles.maxgreenColor));
set(handles.greenMaxSlider, 'Value', (1));
handles.red = red;
handles.green = green;
clear red green
end
end
% Set default crop parameters
handles.cropParams.xmin = 1;%handles.x(1);
handles.cropParams.ymin = 1;%handles.y(1);
handles.cropParams.zmin = 1;%handles.z(1);
handles.cropParams.xmax = 10000;%handles.x(end);
handles.cropParams.ymax = 10000;%handles.y(end);
handles.cropParams.zmax = 10000; %handles.z(end);
set(handles.cropXmaxTextbox, 'String', num2str(handles.cropParams.xmax))
set(handles.cropYmaxTextbox, 'String', num2str(handles.cropParams.ymax))
set(handles.cropZmaxTextbox, 'String', num2str(handles.cropParams.zmax))
% Update handles structure
axis(handles.axes1);
if ~handles.RGB
imagesc(handles.y, handles.x, squeeze(handles.data(:,1,:,1))');
axis image
colormap gray;
xlabel('Y', 'Color', 'w')
ylabel('X', 'Color', 'w')
set(handles.axes1, 'YColor', 'w');
set(handles.axes1, 'XColor', 'w');
set(handles.greyscaling, 'Visible', 'On')
set(handles.RGBscaling, 'Visible', 'Off')
else
rgb(:,:,1) = squeeze(handles.red(:,1,:,1))';
rgb(:,:,2) = squeeze(handles.green(:,1,:,1))';
rgb(:,:,3) = zeros(size(rgb(:,:,1)));
imagesc(handles.y, handles.x, rgb);
axis image
xlabel('Y', 'Color', 'w')
ylabel('X', 'Color', 'w')
set(handles.axes1, 'YColor', 'w');
set(handles.axes1, 'XColor', 'w');
set(handles.RGBscaling, 'Visible', 'On')
set(handles.greyscaling, 'Visible', 'Off')
end
if(length(handles.ss) == 3)
sliderStep = 1;
set(handles.timeStamp, 'Visible', 'Off');
set(handles.timeslider, 'Enable', 'Off');
set(handles.timenum, 'Enable', 'Off');
set(handles.playPushbutton, 'Enable', 'Off');
set(handles.playbackSpeedSlider, 'Enable', 'Off');
set(handles.timecoursePushbutton, 'Enable', 'Off');
set(handles.clearTimecoursesPushbutton, 'Enable', 'Off');
set(handles.exportTimecoursesPushbutton, 'Enable', 'Off');
else
sliderStep = 1/(handles.ss(4)-1);
set(handles.timeStamp, 'Visible', 'On');
set(handles.timeslider, 'Enable', 'On');
set(handles.timenum, 'Enable', 'On');
set(handles.playPushbutton, 'Enable', 'On');
set(handles.playbackSpeedSlider, 'Enable', 'On');
set(handles.timecoursePushbutton, 'Enable', 'On');
set(handles.clearTimecoursesPushbutton, 'Enable', 'On');
set(handles.exportTimecoursesPushbutton, 'Enable', 'On');
end
set(handles.timeslider, 'SliderStep', [sliderStep, sliderStep*5])
sliceSliderStep = 1/(handles.ss(2)-1);
set(handles.sliceslider, 'SliderStep', [sliceSliderStep, sliceSliderStep*5])
handles.playbackSpeed = handles.info.daq.scanRate;
handles.numTC = 1;
handles.info.listbox{end+1} = ['Scan Name: ',handles.info.scanName];
if isfield(handles.info,'listbox'); set(handles.infobox,'String',handles.info.listbox); end
sliceslider_Callback(hObject, eventdata, handles)
guidata(hObject, handles);
function varargout = SCAPE_QuickView_v1_kinetix_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Callback Functions %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function sliceslider_Callback(hObject, eventdata, handles)
sl = get(handles.sliceslider,'Value');
if (sl==0)
sl = 0.00000001; % Prevents the slice number from being set to zero.
end
if ~handles.RGB
colorMaxVal = get(handles.colorMaxSlider, 'Value')*handles.maxDataColor;
colorMinVal = get(handles.colorMinSlider, 'Value')*handles.maxDataColor;
tmp = uint16([colorMinVal colorMaxVal]);
logscale = get(handles.logScaleCheckbox, 'Value');
if(logscale)
clims = log10(double([min(tmp) max(tmp)]));
else
clims = [min(tmp) max(tmp)];
end
else
greenMaxVal = get(handles.greenMaxSlider, 'Value')*handles.maxgreenColor;
greenMinVal = get(handles.greenMinSlider, 'Value')*handles.maxgreenColor;
tmpg = uint16([greenMinVal greenMaxVal]);
logscaleg = get(handles.greenlogscale, 'Value');
if(logscaleg)
climg = log10(double([min(tmpg) max(tmpg)]));
else
climg = [min(tmpg) max(tmpg)];
end
redMaxVal = get(handles.redMaxSlider, 'Value')*handles.maxredColor;
redMinVal = get(handles.redMinSlider, 'Value')*handles.maxredColor;
tmpr = uint16([redMinVal redMaxVal]);
logscaler = get(handles.redlogscale, 'Value');
if(logscaler)
climr = log10(double([min(tmpr) max(tmpr)]));
else
climr = [min(tmpr) max(tmpr)];
end
scr = 1/double(climr(2));
scg = 1/double(climg(2));
minr = double(climr(1));
ming = double(climg(1));
scr =1/(1/scr-minr);
scg =1/(1/scg-minr);
end
mipview = get(handles.mipViewCheckbox, 'Value');
xwin = round(str2num(get(handles.xSliceThicknessTextbox, 'String'))/2);
ywin = round(str2num(get(handles.ySliceThicknessTextbox, 'String'))/2);
zwin = round(str2num(get(handles.zSliceThicknessTextbox, 'String'))/2);
if get(handles.xyzview,'Value')==1
if(mipview)
win = [-zwin zwin];
else
win = [0 0];
end
sll = ceil(handles.ss(2)*sl);
handles.zslice = sll+win;
handles.zslice(1) = max(handles.zslice(1), 1);
handles.zslice(2) = min(handles.zslice(2), handles.ss(2));
handles.zslice = [handles.zslice(1):handles.zslice(2)];
axis(handles.axes1);
if ~handles.RGB
if(~logscale)
imagesc(handles.y, handles.x, squeeze(max(handles.data(:,handles.zslice,:,handles.t), [], 2))');
else
imagesc(handles.y, handles.x, log10(double(squeeze(max(handles.data(:,handles.zslice,:,handles.t), [], 2))')));
end
else
if(~logscaleg)
green = squeeze(max(handles.green(:,handles.zslice,:,handles.t), [], 2))';
else
green = log10(double(squeeze(max(handles.green(:,handles.zslice,:,handles.t), [], 2))'));
end
if(~logscaler)
red = squeeze(max(handles.red(:,handles.zslice,:,handles.t), [], 2))';
else
red = log10(double(squeeze(max(handles.red(:,handles.zslice,:,handles.t), [], 2))'));
end
rgb(:,:,1) = scr.*double(red-minr);
rgb(:,:,2) = scg.*double(green-ming);
rgb(:,:,3) = zeros(size(red));
image(handles.y, handles.x, rgb);
end
axis image
xlim([max(handles.cropParams.ymin, 0) min(handles.y(end), handles.cropParams.ymax)])
ylim([max(handles.cropParams.xmin, 0) min(handles.x(end), handles.cropParams.xmax)])
xlabel('Y (um)', 'Color', 'w')
ylabel('X (um)', 'Color', 'w')
elseif get(handles.xyzview,'Value')==2
if(mipview)
win = [-xwin xwin];
else
win = [0 0];
end
sll = ceil(handles.ss(3)*sl);
handles.xslice = sll+win;
handles.xslice(1) = max(handles.xslice(1), 1);
handles.xslice(2) = min(handles.xslice(2), handles.ss(3));
handles.xslice = [handles.xslice(1):handles.xslice(2)];
axis(handles.axes1);
if ~handles.RGB
if(~logscale)
imagesc(handles.y, handles.z, squeeze(max(handles.data(:,:,handles.xslice,handles.t), [], 3))');
else
imagesc(handles.y, handles.z, log10(double(squeeze(max(handles.data(:,:,handles.xslice,handles.t), [], 3))')));
end
else
if(~logscaleg)
green = squeeze(max(handles.green(:,:,handles.xslice,handles.t), [], 3))';
else
green = log10(double(squeeze(max(handles.green(:,:,handles.xslice,handles.t), [], 3))'));
end
if(~logscaler)
red = squeeze(max(handles.red(:,:,handles.xslice,handles.t), [], 3))';
else
red = log10(double(squeeze(max(handles.green(:,:,handles.xslice,handles.t), [], 3))'));
end
rgb(:,:,1) = scr.*double(red-minr);
rgb(:,:,2) = scg.*double(green-ming);
rgb(:,:,3) = zeros(size(red));
image(handles.y, handles.z, rgb);
end
ylabel('Z (um)', 'Color', 'w')
xlabel('Y (um)', 'Color', 'w')
axis image
xlim([max(handles.cropParams.ymin, 0) min(handles.y(end), handles.cropParams.ymax)])
ylim([max(handles.cropParams.zmin, 0) min(handles.z(end), handles.cropParams.zmax)])
elseif get(handles.xyzview,'Value')==3
if(mipview)
win = [-ywin ywin];
else
win = [0 0];
end
sll = ceil(handles.ss(1)*sl);
handles.yslice = sll+win;
handles.yslice(1) = max(handles.yslice(1), 1);
handles.yslice(2) = min(handles.yslice(2), handles.ss(1));
handles.yslice = [handles.yslice(1):handles.yslice(2)];
axis(handles.axes1);
if ~handles.RGB
if(~logscale)
imagesc(handles.x, handles.z, squeeze(max(handles.data(handles.yslice,:,:,handles.t), [], 1)));
else
imagesc(handles.x, handles.z, log10(double(squeeze(max(handles.data(handles.yslice,:,:,handles.t), [], 1)))));
end
else
if(~logscaleg)
green = squeeze(max(handles.green(handles.yslice,:,:,handles.t), [], 1));
else
green = log10(double(squeeze(max(handles.green(handles.yslice,:,:,handles.t), [], 1))));
end
if(~logscaler)
red = squeeze(max(handles.red(handles.yslice,:,:,handles.t), [], 1));
else
red = log10(double(squeeze(max(handles.green(handles.yslice,:,:,handles.t), [], 1))));
end
rgb(:,:,1) = scr.*double(red-minr);
rgb(:,:,2) = scg.*double(green-ming);
rgb(:,:,3) = zeros(size(red));
image(handles.x, handles.z, rgb);
end
ylabel('Z (um)', 'Color', 'w')
xlabel('X (um)', 'Color', 'w')
axis image
xlim([max(handles.cropParams.xmin, 0) min(handles.cropParams.xmax, handles.x(end))])
ylim([max(handles.cropParams.zmin, 0) min(handles.z(end), handles.cropParams.zmax)])
end
set(handles.timeStamp, 'String', ['Time: ' num2str(round(handles.t/handles.info.daq.scanRate*100)/100) ' sec']);
if ~handles.RGB
caxis(clims);
colormap gray;
end
set(handles.axes1, 'YColor', 'w');
set(handles.axes1, 'XColor', 'w');
set(handles.slicenum,'String',sll);
guidata(hObject, handles);
function slicenum_Callback(hObject, eventdata, handles)
mipval = get(handles.xyzview,'Value');
sliceval = str2num(get(handles.slicenum, 'String'));
switch mipval
case 1
maxsliceval = handles.ss(2);
case 2
maxsliceval = handles.ss(3);
case 3
maxsliceval = handles.ss(1);
end
if(sliceval> maxsliceval)
sliceval = maxsliceval;
set(handles.slicenum, 'String', num2str(sliceval));
end
if (sliceval < 1)
sliceval = 1;
set(handles.slicenum, 'String', num2str(sliceval));
end
set(handles.sliceslider,'Value', sliceval/maxsliceval);
sliceslider_Callback(hObject, eventdata, handles)
function xyzview_Callback(hObject, eventdata, handles)
val = get(handles.xyzview, 'Value');
switch val
case 1
sliceSliderStep = 1/(handles.ss(2)-1);
set(handles.sliceslider, 'SliderStep', [sliceSliderStep, sliceSliderStep*5])
set(handles.xSliceThicknessTextbox, 'Enable','Off');
set(handles.ySliceThicknessTextbox, 'Enable','Off');
set(handles.zSliceThicknessTextbox, 'Enable','On');
case 2
sliceSliderStep = 1/(handles.ss(3)-1);
set(handles.sliceslider, 'SliderStep', [sliceSliderStep, sliceSliderStep*5])
set(handles.xSliceThicknessTextbox, 'Enable','On');
set(handles.ySliceThicknessTextbox, 'Enable','Off');
set(handles.zSliceThicknessTextbox, 'Enable','Off');
case 3
sliceSliderStep = 1/(handles.ss(1)-1);
set(handles.sliceslider, 'SliderStep', [sliceSliderStep, sliceSliderStep*5])
set(handles.xSliceThicknessTextbox, 'Enable','Off');
set(handles.ySliceThicknessTextbox, 'Enable','On');
set(handles.zSliceThicknessTextbox, 'Enable','Off');
end
sliceslider_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% TIME PLAYBACK CALLBACKS %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function timeslider_Callback(hObject, eventdata, handles)
if (length(handles.ss) == 3)
handles.t = 1;
else
handles.t = ceil(handles.ss(4)*get(handles.timeslider,'Value'));
if(handles.t == 0)
handles.t = 1;
end
end
set(handles.timenum,'String',num2str(handles.t));
sliceslider_Callback(hObject, eventdata, handles)
function timenum_Callback(hObject, eventdata, handles)
val = str2num(get(handles.timenum, 'String'));
if (val <=0)
val = 1
elseif (val >= handles.ss(4))
val = handles.ss(4);
end
handles.t = val;
set(handles.timeslider, 'Value', val/handles.ss(4));
timeslider_Callback(hObject, eventdata, handles)
function playPushbutton_Callback(hObject, eventdata, handles)
val = get(handles.playPushbutton, 'Value');
set(handles.timeslider, 'Enable', 'Off');
set(handles.playbackSpeedSlider, 'Enable', 'Off');
while(val == 1)
val = get(handles.playPushbutton, 'Value');
handles.t = handles.t+1;
if(handles.t>handles.ss(4))
handles.t = 1;
end
set(handles.timenum,'String',num2str(handles.t));
sliceslider_Callback(hObject, eventdata, handles);
pause(1/handles.playbackSpeed)
end
set(handles.timeslider, 'Enable', 'On');
set(handles.playbackSpeedSlider, 'Enable', 'On');
timenum_Callback(hObject, eventdata, handles)
function playbackSpeedSlider_Callback(hObject, eventdata, handles)
val = get(handles.playbackSpeedSlider, 'Value');
val = val-0.5;
if (val <0)
val = round(abs(val*100)/5);
handles.playbackSpeed = (handles.info.daq.scanRate)*power(0.8, val);
else
val = round(abs(val*100)/5);
handles.playbackSpeed = (handles.info.daq.scanRate)*power(1.2, val);
end
guidata(hObject, handles);
function timecoursePushbutton_Callback(hObject, eventdata, handles)
mipval = get(handles.xyzview, 'Value');
calval = (get(handles.uniformAspectRadiobutton, 'Value')*1)+...
(get(handles.calibratedAspectRadiobutton, 'Value')*2)+...
(get(handles.customAspectRadiobutton, 'Value')*3);
slicenum = str2num(get(handles.slicenum, 'String'));
cmap = lines(50);
hold on;
switch mipval
case 1
[y,x] = ginput_col(2);
x = round(x);
y = round(y);
z = slicenum;
plot(handles.axes1, mean(y), mean(x), 'o', 'color', cmap(handles.numTC, :));
case 2
[y,z] = ginput_col(2);
y = round(y);
z = round(z);
x = slicenum;
plot(handles.axes1, mean(y), mean(z), 'o', 'color', cmap(handles.numTC, :));
case 3
[x,z] = ginput_col(2);
x = round(x);
z = round(z);
y = slicenum;
plot(handles.axes1, mean(x), mean(z), 'o', 'color', cmap(handles.numTC, :));
end
hold off
time = ([1:handles.ss(4)]-1)/handles.info.daq.scanRate;
switch calval
case 1
% Do nothing. The axes coordinates and the indices of the data
% matrix are already the same.
case 2
x = (x/handles.info.GUIcalFactors.x_umPerPix)+1;
y = (y/handles.info.GUIcalFactors.y_umPerPix)+1;
z = (z/handles.info.GUIcalFactors.z_umPerPix)+1;
case 3
xCal = str2num(get(handles.xCalTextbox, 'String'));
yCal = str2num(get(handles.yCalTextbox, 'String'));
zCal = str2num(get(handles.zCalTextbox, 'String'));
x = (x/xCal)+1;
y = (y/yCal)+1;
z = (z/zCal)+1;
end
isMIP = get(handles.mipViewCheckbox, 'Value');
switch mipval
case 1
if (isMIP)
thickness = round(str2num(get(handles.zSliceThicknessTextbox, 'String'))/2);
else
thickness = 0;
end
win = [-thickness:thickness];
z = slicenum+win;
z(1) = max(1, z(1));
z(end) = min(z(end), handles.ss(2));
z = [z(1):z(end)];
case 2
if (isMIP)
thickness = round(str2num(get(handles.xSliceThicknessTextbox, 'String'))/2);
else
thickness = 0;
end
win = [-thickness:thickness];
x = slicenum+win;
x(1) = max(1, x(1));
x(end) = min(x(end), handles.ss(3));
x = [x(1):x(end)];
case 3
if (isMIP)
thickness = round(str2num(get(handles.ySliceThicknessTextbox, 'String'))/2);
else
thickness = 0;
end
win = [-thickness:thickness];
y = slicenum+win;
y(1) = max(1, y(1));
y(end) = min(y(end), handles.ss(1));
y = [y(1):y(end)];
end
x =round(x); y = round(y); z = round(z);
if (isMIP)
if ~handles.RGB
switch mipval
case 1
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.data(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 2)), 1), 2));
case 2
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.data(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 3)), 1), 2));
case 3
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.data(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 1)), 1), 2));
end
else
switch mipval
case 1
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.green(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 2)), 1), 2));
case 2
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.green(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 3)), 1), 2));
case 3
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(max(handles.green(min(y):max(y), ...
min(z):max(z), min(x):max(x), :),[], 1)), 1), 2));
end
end
handles.ROI(handles.numTC).x = x;
handles.ROI(handles.numTC).y = y;
handles.ROI(handles.numTC).z = z;
handles.ROI(handles.numTC).isMIP = 1;
handles.ROI(handles.numTC).MIPval = mipval;
else
if ~handles.RGB
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(handles.data(min(y):max(y), ...
min(z):max(z), min(x):max(x), :)), 1), 2));
else
handles.ROI(handles.numTC).TC = squeeze(mean(mean(squeeze(handles.green(min(y):max(y), ...
min(z):max(z), min(x):max(x), :)), 1), 2));
end
handles.ROI(handles.numTC).x = x;
handles.ROI(handles.numTC).y = y;
handles.ROI(handles.numTC).z = z;
handles.ROI(handles.numTC).isMIP = 0;
end
figure(2);
hold on;
plot(time, handles.ROI(handles.numTC).TC'+(10*handles.numTC), 'color', cmap(handles.numTC, :));
handles.numTC = handles.numTC+1;
guidata(hObject, handles);
function clearTimecoursesPushbutton_Callback(hObject, eventdata, handles)
choice = questdlg('Are you sure you want to delete all saved timecourses?', ...
'Yes', 'No');
if (strcmp(choice, 'Yes'))
try
close(2)
catch
end
handles.numTC = 1;
handles.ROI = [];
end
guidata(hObject, handles);
function exportTimecoursesPushbutton_Callback(hObject, eventdata, handles)
varname = cell2mat(inputdlg('Enter variable name of exported time courses:'));
assignin('base', varname, handles.ROI);
guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% COLORMAP CALLBACKS %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function colorMaxSlider_Callback(hObject, eventdata, handles)
val = get(handles.colorMaxSlider, 'Value');
set(handles.colorMaxTextbox, 'String', num2str(uint16(val*handles.maxDataColor)))
sliceslider_Callback(hObject, eventdata, handles)
function colorMinSlider_Callback(hObject, eventdata, handles)
val = get(handles.colorMinSlider, 'Value');
set(handles.colorMinTextbox, 'String', num2str(uint16(val*handles.maxDataColor)))
sliceslider_Callback(hObject, eventdata, handles)
function colorMaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.colorMaxTextbox, 'String'));
set(handles.colorMaxSlider, 'Value', val/handles.maxDataColor)
sliceslider_Callback(hObject, eventdata, handles)
function colorMinTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.colorMinTextbox, 'String'));
set(handles.colorMinSlider, 'Value', val/handles.maxDataColor)
sliceslider_Callback(hObject, eventdata, handles)
function logScaleCheckbox_Callback(hObject, eventdata, handles)
sliceslider_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% RGB Color scaling %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function greenMaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.greenMaxTextbox, 'String'));
set(handles.greenMaxSlider, 'Value', val/handles.maxgreenColor)
sliceslider_Callback(hObject, eventdata, handles)
function greenMinSlider_Callback(hObject, eventdata, handles)
val = get(handles.greenMinSlider, 'Value');
set(handles.greenMinTextbox, 'String', num2str(uint16(val*handles.maxgreenColor)))
sliceslider_Callback(hObject, eventdata, handles)
function greenMinTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.greenMinTextbox, 'String'));
set(handles.greenMinSlider, 'Value', val/handles.maxgreenColor)
sliceslider_Callback(hObject, eventdata, handles)
function greenMaxSlider_Callback(hObject, eventdata, handles)
val = get(handles.greenMaxSlider, 'Value');
set(handles.greenMaxTextbox, 'String', num2str(uint16(val*handles.maxgreenColor)))
sliceslider_Callback(hObject, eventdata, handles)
function greenlogscale_Callback(hObject, eventdata, handles)
sliceslider_Callback(hObject, eventdata, handles)
function redMaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.redMaxTextbox, 'String'));
set(handles.redMaxSlider, 'Value', val/handles.maxredColor)
sliceslider_Callback(hObject, eventdata, handles)
function redMinSlider_Callback(hObject, eventdata, handles)
val = get(handles.redMinSlider, 'Value');
set(handles.redMinTextbox, 'String', num2str(uint16(val*handles.maxredColor)))
sliceslider_Callback(hObject, eventdata, handles)
function redMinTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.redMinTextbox, 'String'));
set(handles.redMinSlider, 'Value', val/handles.maxredColor)
sliceslider_Callback(hObject, eventdata, handles)
function redMaxSlider_Callback(hObject, eventdata, handles)
val = get(handles.redMaxSlider, 'Value');
set(handles.redMaxTextbox, 'String', num2str(uint16(val*handles.maxredColor)))
sliceslider_Callback(hObject, eventdata, handles)
function redlogscale_Callback(hObject, eventdata, handles)
sliceslider_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CROP FIELD CALLBACKS %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function cropFieldCheckbox_Callback(hObject, eventdata, handles)
val = get(handles.cropFieldCheckbox, 'Value');
if(val == 0)
set(handles.cropUIPanel, 'Visible', 'Off');
handles.cropParams.xmin = handles.x(1);
handles.cropParams.ymin = handles.y(1);
handles.cropParams.zmin = handles.z(1);
handles.cropParams.xmax = handles.x(end);
handles.cropParams.ymax = handles.y(end);
handles.cropParams.zmax = handles.z(end);
else
set(handles.cropUIPanel, 'Visible', 'On');
handles.cropParams.xmin = str2num(get(handles.cropXminTextbox, 'String'));
handles.cropParams.ymin = str2num(get(handles.cropYminTextbox, 'String'));
handles.cropParams.zmin = str2num(get(handles.cropZminTextbox, 'String'));
handles.cropParams.xmax = str2num(get(handles.cropXmaxTextbox, 'String'));
handles.cropParams.ymax = str2num(get(handles.cropYmaxTextbox, 'String'));
handles.cropParams.zmax = str2num(get(handles.cropZmaxTextbox, 'String'));
end
sliceslider_Callback(hObject, eventdata, handles)
function cropXminTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropXminTextbox, 'String'));
if(val>=handles.cropParams.xmax)
val = handles.cropParams.xmax-1;
set(handles.cropXminTextbox, 'String', num2str(val));
elseif (val<0)
val = 0;
set(handles.cropXminTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function cropXmaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropXmaxTextbox, 'String'));
if(val<=handles.cropParams.xmin)
val = handles.cropParams.xmin+1;
set(handles.cropXmaxTextbox, 'String', num2str(val));
elseif (val>handles.x(end))
val = handles.x(end);
set(handles.cropXmaxTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function cropYminTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropYminTextbox, 'String'));
if(val>=handles.cropParams.ymax)
val = handles.cropParams.ymax-1;
set(handles.cropYminTextbox, 'String', num2str(val));
elseif (val<0)
val = 0;
set(handles.cropYminTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function cropYmaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropYmaxTextbox, 'String'));
if(val<=handles.cropParams.ymin)
val = handles.cropParams.ymin+1;
set(handles.cropYmaxTextbox, 'String', num2str(val));
elseif (val>handles.y(end))
val = handles.y(end);
set(handles.cropYmaxTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function cropZminTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropZminTextbox, 'String'));
if(val>=handles.cropParams.zmax)
val = handles.cropParams.zmax-1;
set(handles.cropZminTextbox, 'String', num2str(val));
elseif (val<0)
val = 0;
set(handles.cropZminTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function cropZmaxTextbox_Callback(hObject, eventdata, handles)
val = str2num(get(handles.cropZmaxTextbox, 'String'));
if(val<=handles.cropParams.zmin)
val = handles.cropParams.zmin+1;
set(handles.cropZmaxTextbox, 'String', num2str(val));
elseif (val>handles.z(end))
val = handles.z(end);
set(handles.cropZmaxTextbox, 'String', num2str(val));
end
cropFieldCheckbox_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% ASPECT RATIO CALLBACKS %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function uniformAspectRadiobutton_Callback(hObject, eventdata, handles)
set(handles.customCalPanel, 'Visible', 'Off');
handles.y = [1:handles.ss(1)]-1;
handles.x = [1:handles.ss(3)]-1;
handles.z = [1:handles.ss(2)]-1;
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function calibratedAspectRadiobutton_Callback(hObject, eventdata, handles)
handles.y = ([1:handles.ss(1)]-1)*handles.info.GUIcalFactors.y_umPerPix;
try
handles.x = ([1:handles.ss(3)]-1)*handles.info.GUIcalFactors.x_umPerPix;
catch
handles.info.GUIcalFactors.x_umPerPix = handles.info.GUIcalFactors.xK_umPerVolt*handles.info.daq.scanAngle/(handles.info.daq.pixelsPerLine-2);
handles.x = ([1:handles.ss(3)]-1)*handles.info.GUIcalFactors.x_umPerPix;
end
handles.z = ([1:handles.ss(2)]-1)*handles.info.GUIcalFactors.z_umPerPix;
set(handles.customCalPanel, 'Visible', 'Off');
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function customAspectRadiobutton_Callback(hObject, eventdata, handles)
set(handles.customCalPanel, 'Visible', 'On');
xCal = str2num(get(handles.xCalTextbox, 'String'));
yCal = str2num(get(handles.yCalTextbox, 'String'));
zCal = str2num(get(handles.zCalTextbox, 'String'));
handles.y = yCal*([1:handles.ss(1)]-1);
handles.x = xCal*([1:handles.ss(3)]-1);
handles.z = zCal*([1:handles.ss(2)]-1);
cropFieldCheckbox_Callback(hObject, eventdata, handles)
function xCalTextbox_Callback(hObject, eventdata, handles)
customAspectRadiobutton_Callback(hObject, eventdata, handles)
function yCalTextbox_Callback(hObject, eventdata, handles)
customAspectRadiobutton_Callback(hObject, eventdata, handles)
function zCalTextbox_Callback(hObject, eventdata, handles)
customAspectRadiobutton_Callback(hObject, eventdata, handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% MIP CALLBACKS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mipViewCheckbox_Callback(hObject, eventdata, handles)
val = get(handles.mipViewCheckbox,'Value');
if (val)
set(handles.mipUIPanel, 'Visible', 'On');