-
Notifications
You must be signed in to change notification settings - Fork 1
/
brl_tip_cell_update.m
1281 lines (942 loc) · 51.3 KB
/
brl_tip_cell_update.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 = brl_tip_cell_update(varargin)
% BRL_TIP_CELL_UPDATE MATLAB code for brl_tip_cell_update.fig
% © 2015 Allen Institute.
% This file is part of smartACT.
% smartACT 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. smartACT 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 smartACT.
% If not, see <http://www.gnu.org/licenses/>.
%
% This package is currently not maintained and no support is implied.
% Questions may be directed to Brian Long
% <[email protected]> with 'smartACT' in the subject line.
%
%
% BRL_TIP_CELL_UPDATE, by itself, creates a new BRL_TIP_CELL_UPDATE or raises the existing
% singleton*.
%
% H = BRL_TIP_CELL_UPDATE returns the handle to a new BRL_TIP_CELL_UPDATE or the handle to
% the existing singleton*.
%
% BRL_TIP_CELL_UPDATE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BRL_TIP_CELL_UPDATE.M with the given input arguments.
%
% BRL_TIP_CELL_UPDATE('Property','Value',...) creates a new BRL_TIP_CELL_UPDATE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before brl_tip_cell_update_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to brl_tip_cell_update_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 brl_tip_cell_update
% Last Modified by GUIDE v2.5 24-Nov-2014 10:03:40
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @brl_tip_cell_update_OpeningFcn, ...
'gui_OutputFcn', @brl_tip_cell_update_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 brl_tip_cell_update is made visible.
function brl_tip_cell_update_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 brl_tip_cell_update (see VARARGIN)
% Choose default command line output for brl_tip_cell_update
handles.output = hObject;
tipCellData.archiveMode = 0;
% get the handle to the smartACT gui
tipCellData.smartACTh = findobj('name','smartACT');
tipCellData.runBh = handles.collectTipCellSubstackB;
tipCellData.runfunctionh = @collectTipCellSubstackB_Callback;
tipCellData.importh = @importStack;
tipCellData.findTiph =@locateTipB_Callback;
tipCellData.findCellh = @locateCellB_Callback;
tipCellData.findTipB =handles.locateTipB;
tipCellData.findCellB = handles.locateCellB;
set(handles.figure1, 'UserData', tipCellData);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes brl_tip_cell_update wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = brl_tip_cell_update_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;
% --- Executes on button press in useLatestFullStackB.
function useLatestFullStackB_Callback(hObject, eventdata, handles)
% hObject handle to useLatestFullStackB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get path to some relevant image data
tipCellData = get(handles.figure1, 'UserData');
global spStackdata
spUdat = get(tipCellData.smartACTh,'UserData');
imPath = spStackdata.lastFullStackRaw
%
% import defined substack.
%
tipCellData.tiprows = fliplr(255-[115 180]);
tipCellData.tipcols = [10 90];
tipCellData.tipzs = [50 67]
argh = brl_tif_read(imPath, 2,2,tipCellData.tiprows ,tipCellData.tipcols,tipCellData.tipzs);
tipCellData.rawTipImage = argh;
tipCellData.normTipImage = tipCellData.rawTipImage-percentile(tipCellData.rawTipImage(:), .05);
tipCellData.normTipImage = tipCellData.normTipImage/percentile(tipCellData.normTipImage(:), get( handles.tipNormalization, 'value'));
tipCellData.normTipImage = 255*tipCellData.normTipImage;
tipCellData.segTipImage = tipCellData.normTipImage>get(handles.tipThreshold,'Value');
%
% import defined substack.
%
tipCellData.lastCellLocation = []
tipCellData.cellrows = fliplr(255-[115 180]);
tipCellData.cellcols = [90 110];
tipCellData.cellzs = [95 115];
argh = brl_tif_read(imPath, 1,2,tipCellData.cellrows ,tipCellData.cellcols, tipCellData.cellzs);
tipCellData.rawCellImage = argh;
tipCellData.normCellImage = tipCellData.rawCellImage-percentile(tipCellData.rawCellImage(:), .05);
tipCellData.normCellImage = tipCellData.normCellImage/percentile(tipCellData.normCellImage(:), get( handles.cellNormalization, 'value'));
tipCellData.normCellImage = 255*tipCellData.normCellImage;
set(handles.imageFileT,'String', imPath);
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
% --- Executes on button press in analyzeArchivedStackB.
function analyzeArchivedStackB_Callback(hObject, eventdata, handles)
% hObject handle to analyzeArchivedStackB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tipCellData = get(handles.figure1, 'UserData');
% give option to load a stack and enter tip coordinates.
tipCellData.archiveMode = 1
[imPath,dir] = uigetfile('*.tif');
%
% import defined substack.
%
% tip location
tipCellData.tipLocation = round([ 93 122 16]);
tipCellData.tiprows = [max(tipCellData.tipLocation(2)-20,1) ,tipCellData.tipLocation(2)+20] ;
tipCellData.tipcols = [max(tipCellData.tipLocation(1)-20,1),tipCellData.tipLocation(1)+20 ];
tipCellData.tipzs = [max(tipCellData.tipLocation(3)-20,1) , tipCellData.tipLocation(3)+20];
argh = brl_tif_read(fullfile(dir,imPath), 2,2,tipCellData.tiprows ,tipCellData.tipcols,tipCellData.tipzs);
tipCellData.rawTipImage = argh;
tipCellData.normTipImage = tipCellData.rawTipImage-percentile(tipCellData.rawTipImage(:), .05);
tipCellData.normTipImage = tipCellData.normTipImage/percentile(tipCellData.normTipImage(:), get( handles.tipNormalization, 'value'));
tipCellData.normTipImage = 255*tipCellData.normTipImage;
tipCellData.segTipImage = tipCellData.normTipImage>get(handles.tipThreshold,'Value');
%
% import defined substack.
%
tipCellData.lastCellLocation = round([ 128 122 26])
tipCellData.cellrows = [max(tipCellData.lastCellLocation(2)-20,1) tipCellData.lastCellLocation(2)+20];
tipCellData.cellcols = [max(tipCellData.lastCellLocation(1)-20,1) tipCellData.lastCellLocation(1)+20];
tipCellData.cellzs = [max(tipCellData.lastCellLocation(3)-10,1), tipCellData.lastCellLocation(3)+10];
argh = brl_tif_read(fullfile(dir,imPath), 1,2,tipCellData.cellrows ,tipCellData.cellcols, tipCellData.cellzs);
size(argh)
tipCellData.cellzs = tipCellData.cellzs(1):tipCellData.cellzs(2);
tipCellData.cellzs =[tipCellData.cellzs(1) tipCellData.cellzs(size(argh,3))]
tipCellData.rawCellImage = argh;
tipCellData.normCellImage = tipCellData.rawCellImage-percentile(tipCellData.rawCellImage(:), .05);
tipCellData.normCellImage = tipCellData.normCellImage/percentile(tipCellData.normCellImage(:), get( handles.cellNormalization, 'value'));
tipCellData.normCellImage = 255*tipCellData.normCellImage;
set(handles.imageFileT,'String', fullfile(dir,imPath));
tipCellData
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
% --- Executes on selection change in tipImageSelectorPM.
function tipImageSelectorPM_Callback(hObject, eventdata, handles)
% hObject handle to tipImageSelectorPM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns tipImageSelectorPM contents as cell array
% contents{get(hObject,'Value')} returns selected item from tipImageSelectorPM
tipCellData = get(handles.figure1, 'UserData');
if isfield(tipCellData,'tipLocation')
set(handles.tipReportedLocationT,'String', num2str(tipCellData.tipLocation([ 1 2 3]), '%.2f '))
end
currentSelection = get(hObject,'Value')
switch currentSelection
case 1
'image data'
imdat3D = tipCellData.rawTipImage;
mean(imdat3D(:))
axes(handles.axes1)
imagesc(squeeze(sum(imdat3D,3)));colormap gray
axes(handles.axes2)
imagesc((squeeze(sum(imdat3D,1)))');
axes(handles.axes3)
imagesc(squeeze(sum(imdat3D,2)));
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
case 2
'norm data'
imdat3D = tipCellData.normTipImage;
mean(imdat3D(:))
axes(handles.axes1)
imagesc(tipCellData.tipcols, tipCellData.tiprows,squeeze(sum(imdat3D,3)));
axes(handles.axes2)
imagesc((squeeze(sum(imdat3D,1)))');
axes(handles.axes3)
imagesc(squeeze(sum(imdat3D,2)));
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
case 3
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
feval(@locateTipB_Callback, handles.locateTipB, [], guidata(handles.locateTipB))
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
% 'segment data'
% % generate MIPs after smoothing
% get(handles.tipThreshold,'Value')
% mean(tipCellData.normTipImage(:))
% [tipCellData.im3, tipCellData.im2, tipCellData.im1] = brl_MIP_segmentation(tipCellData.normTipImage, get(handles.tipThreshold,'Value'));
% % and extract coordinates:
% tipCellData.tipdata = brl_find_tip_2(tipCellData.im3, tipCellData.im2, tipCellData.im1)
% tipCellData.tipdataStackCoordinates = brl_tipdata_to_stack(tipCellData.tipdata, tipCellData.tiprows(1), tipCellData.tipcols(1), tipCellData.tipzs(1))
%
% axes(handles.axes1)
% imagesc(tipCellData.tipcols, tipCellData.tiprows,tipCellData.im3);
% hold all, plot(max(tipCellData.tipdataStackCoordinates.tipj3),mean(tipCellData.tipdataStackCoordinates.tipi3), 'om')
% plot(tipCellData.tipdataStackCoordinates.tipj3,tipCellData.tipdataStackCoordinates.tipi3,'.g')
% hold off
% axes(handles.axes2)
% imagesc(tipCellData.tipcols, tipCellData.tipzs,(tipCellData.im1'));
% hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipi1),max(tipCellData.tipdataStackCoordinates.tipj1), 'om') ,
% plot(tipCellData.tipdataStackCoordinates.tipi1,tipCellData.tipdataStackCoordinates.tipj1,'.g')
% hold off
% axes(handles.axes3)
% imagesc(tipCellData.tipzs, tipCellData.tiprows,tipCellData.im2);
% hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipj2),mean(tipCellData.tipdataStackCoordinates.tipi2), 'om'),
% plot(tipCellData.tipdataStackCoordinates.tipj2,tipCellData.tipdataStackCoordinates.tipi2,'.g')
% hold off
%
% actualTipPixels = tipCellData.tipdata.coordinates+[tipCellData.tiprows(1) tipCellData.tipcols(1) tipCellData.tipzs(1)] -[1 1 1] ;
% tipCellData.tipMeasuredLocation = actualTipPixels;
% set(handles.tipMeasuredLocationT,'String', [sprintf('%.2f', actualTipPixels(1)), ' ', sprintf('%.2f', actualTipPixels(2)),' ',sprintf('%.2f', actualTipPixels(3))])
%
case 4 % cloak the pipet
tipCellData.tipdata.rp2
tipCellData.tipdata.ind2
% the object I want is the one that includes the centroid of the MIP pipets
coordinates3D = [tipCellData.tipdata.rp2(tipCellData.tipdata.ind2).Centroid(2), tipCellData.tipdata.rp3(tipCellData.tipdata.ind3).Centroid(1), tipCellData.tipdata.rp2(tipCellData.tipdata.ind2).Centroid(1)]
parameters.coordinates3D= round(coordinates3D);
tipCellData.tipBinary= brl_identify_tip(tipCellData.normTipImage> 255*get(handles.tipThreshold, 'Value'),parameters);
tipCellData.cloakedTipImg = brl_cloak_object(tipCellData.normTipImage, tipCellData.tipBinary);
axes(handles.axes1)
imagesc(tipCellData.tipcols, tipCellData.tiprows,squeeze(sum(tipCellData.cloakedTipImg,3)));
hold all,
plot(max(tipCellData.tipdataStackCoordinates.tipj3),mean(tipCellData.tipdataStackCoordinates.tipi3), 'om')
plot(tipCellData.tipdataStackCoordinates.tipj3,tipCellData.tipdataStackCoordinates.tipi3,'.g'),hold off
axes(handles.axes2)
imagesc(tipCellData.tipcols, tipCellData.tipzs+udat.substackSliceStart, squeeze(sum(tipCellData.cloakedTipImg,1))');
hold all,
plot(mean(tipCellData.tipdataStackCoordinates.tipi1),max(tipCellData.tipdataStackCoordinates.tipj1), 'om') ,
plot(tipCellData.tipdataStackCoordinates.tipi1,tipCellData.tipdataStackCoordinates.tipj1,'.g')
hold off
axes(handles.axes3)
imagesc(tipCellData.tipzs+udat.substackSliceStart, tipCellData.tiprows,squeeze(sum(tipCellData.cloakedTipImg,2)));
hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipj2),mean(tipCellData.tipdataStackCoordinates.tipi2), 'om'),
plot(tipCellData.tipdataStackCoordinates.tipj2,tipCellData.tipdataStackCoordinates.tipi2,'.g')
hold off
actualTipPixels = tipCellData.tipdata.coordinates+[tipCellData.tiprows(1) tipCellData.tipcols(1) tipCellData.tipzs(1)] -[1 1 1] ;
tipCellData.tipMeasuredLocation = actualTipPixels;
set(handles.tipMeasuredLocationT,'String', [sprintf('%.2f', actualTipPixels(1)), ' ', sprintf('%.2f', actualTipPixels(2)),' ',sprintf('%.2f', actualTipPixels(3))])
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
end
% --- Executes on selection change in cellImageSelectorPM.
function cellImageSelectorPM_Callback(hObject, eventdata, handles)
% hObject handle to cellImageSelectorPM (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns cellImageSelectorPM contents as cell array
% contents{get(hObject,'Value')} returns selected item from cellImageSelectorPM
tipCellData = get(handles.figure1, 'UserData');
if isfield(tipCellData, 'lastCellLocation')
set(handles.cellOriginalLocationT,'String', num2str(tipCellData.lastCellLocation([2 1 3]) ,'%.2f '))
end
udat = get(findobj(0,'name','smartACT'),'UserData')
currentSelection = get(hObject,'Value')
switch currentSelection
case 1
'image data'
imdat3D = tipCellData.rawCellImage;
mean(imdat3D(:))
axes(handles.axes4)
imagesc(squeeze(sum(imdat3D,3)));colormap gray
axes(handles.axes5)
imagesc((squeeze(sum(imdat3D,1)))');
axes(handles.axes6)
imagesc(squeeze(sum(imdat3D,2)));
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
case 2
'norm data'
imdat3D = tipCellData.normCellImage;
mean(imdat3D(:))
axes(handles.axes4)
imagesc(tipCellData.cellcols, tipCellData.cellrows,squeeze(sum(imdat3D,3)));
axes(handles.axes5)
imagesc(tipCellData.cellcols, tipCellData.cellzs, (squeeze(sum(imdat3D,1)))');
axes(handles.axes6)
imagesc(tipCellData.cellzs, tipCellData.tiprows, squeeze(sum(imdat3D,2)));
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
imdat3D = tipCellData.normCellImage;
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
case 3
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
feval(@locateCellB_Callback, handles.locateCellB, [], guidata(handles.locateCellB))
guidata(hObject, handles);
% 'segment data';
% % generate MIPs after smoothing and locate cells
%
% mean(tipCellData.normTipImage(:))
% params.big = 20;
% params.small = 2;
% params.thresh =255*get(handles.cellThreshold,'Value');
% tipCellData.locateCellStruct = brl_locate_cells(tipCellData.normCellImage,params);
% keepRegions=[];
% actualCellPixels = [];
% for i = 1:numel(tipCellData.locateCellStruct.rpdata)
% idat= tipCellData.locateCellStruct.rpdata(i);
%
% actualCellPixels(i,:) = tipCellData.locateCellStruct.rpdata(i).Centroid([2 1 3])+[tipCellData.cellrows(1) tipCellData.cellcols(1) tipCellData.cellzs(1)+udat.substackSliceStart] -[1 1 1]
% if idat.Area >100
%
% keepRegions =[keepRegions; i]
% end
%
% end
%
%
% % figure out which object is the cell of interest
%
% % 1. find the objects that are big enough to be cells
%
% if numel(keepRegions)==1
% tipCellData.cellLocationPixels = actualCellPixels(keepRegions,:);
% cellnumber=1
%
%
% else
%
% % if there is more than one of these,
% % 2. find the object whos centroid is closest to the original cell location
%
% distances = sqrt(sum((actualCellPixels(keepRegions(:),:)- repmat(tipCellData.lastCellLocation([2,1,3]), numel(keepRegions),1)).^2,2));
%
% % note that this is NOT scaled to microns, just in voxels.
%
% if min(distances)> 15 % hard coded estimate here... many ways to parameterize this if needed
% set(handles.cellMeasuredLocationT,'String','cell displacement greater than ~18 microns')
% set(handles.figure1, 'UserData', tipCellData);
% guidata(hObject, handles);
% return
% end
% % take the closest one...
% cellnumber = keepRegions(distances(:)==min(distances(:)))
% tipCellData.cellLocationPixels = actualCellPixels(cellnumber,:);
%
%
%
% end
%
% tipCellData.cellzs+udat.substackSliceStart
%
% axes(handles.axes4)
% imagesc(tipCellData.cellcols, tipCellData.cellrows,squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],3)));
% hold all, plot(actualCellPixels(:,2),actualCellPixels(:,1),'.b')
% plot(actualCellPixels(cellnumber,2),actualCellPixels(cellnumber,1),'or')
% hold off
% axes(handles.axes5)
% imagesc(tipCellData.cellcols, tipCellData.cellzs+udat.substackSliceStart,squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],1))');
% hold all,plot(actualCellPixels(:,2),actualCellPixels(:,3),'.b')
% plot(actualCellPixels(cellnumber,2),actualCellPixels(cellnumber,3),'or')
% hold off
% axes(handles.axes6)
% imagesc(tipCellData.cellzs+udat.substackSliceStart,tipCellData.cellrows, squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],2)));
% hold all, plot(actualCellPixels(:,3),actualCellPixels(:,1),'.b')
% plot(actualCellPixels(cellnumber,3),actualCellPixels(cellnumber,1),'or')
% hold off
%
%
% set(handles.cellMeasuredLocationT,'String', [sprintf('%.2f', actualCellPixels(cellnumber,1)), ' ', sprintf('%.2f', actualCellPixels(cellnumber,2)),' ',sprintf('%.2f', actualCellPixels(cellnumber,3))])
%
case 4 % cloak the pipet
% tipCellData.tipdata.rp2
% tipCellData.tipdata.ind2
%
% % the object I want is the one that includes the centroid of the MIP pipets
% coordinates3D = [tipCellData.tipdata.rp2(tipCellData.tipdata.ind2).Centroid(2), tipCellData.tipdata.rp3(tipCellData.tipdata.ind3).Centroid(1), tipCellData.tipdata.rp2(tipCellData.tipdata.ind2).Centroid(1)]
% parameters.coordinates3D= round(coordinates3D);
%
%
% tipCellData.tipBinary= brl_identify_tip(tipCellData.normTipImage> 255*get(handles.tipThreshold, 'Value'),parameters);
% tipCellData.cloakedTipImg = brl_cloak_object(tipCellData.normTipImage, tipCellData.tipBinary);
%
%
%
% axes(handles.axes1)
% imagesc(tipCellData.tipcols, tipCellData.tiprows,squeeze(sum(tipCellData.cloakedTipImg,3)));
% hold all, plot(max(tipCellData.tipdataStackCoordinates.tipj3),mean(tipCellData.tipdataStackCoordinates.tipi3), 'om'), plot(tipCellData.tipdataStackCoordinates.tipj3,tipCellData.tipdataStackCoordinates.tipi3,'.g')
% hold off
% axes(handles.axes2)
% imagesc(squeeze(sum(tipCellData.cloakedTipImg,1))');
% hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipi1),max(tipCellData.tipdataStackCoordinates.tipj1), 'om') , plot(tipCellData.tipdataStackCoordinates.tipi1,tipCellData.tipdataStackCoordinates.tipj1,'.g')
% hold off
% axes(handles.axes3)
% imagesc(squeeze(sum(tipCellData.cloakedTipImg,2)));
% hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipj2),mean(tipCellData.tipdataStackCoordinates.tipi2), 'om'), plot(tipCellData.tipdataStackCoordinates.tipj2,tipCellData.tipdataStackCoordinates.tipi2,'.g')
% hold off
%
% actualTipPixels = tipCellData.tipdata.coordinates+[tipCellData.tiprows(1) tipCellData.tipcols(1) tipCellData.tipzs(1)] -[1 1 1] ;
% tipCellData.tipMeasuredLocation = actualTipPixels;
% set(handles.tipMeasuredLocationT,'String', [sprintf('%.2f', actualTipPixels(1)), ' ', sprintf('%.2f', actualTipPixels(2)),' ',sprintf('%.2f', actualTipPixels(3))])
%
end
% --- Executes on button press in collectTipCellSubstackB.
function collectTipCellSubstackB_Callback(hObject, eventdata, handles)
% hObject handle to collectTipCellSubstackB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% This will start the process of collecting a substack
global spStackdata
udat = get(findobj(0,'name','smartACT'),'UserData')
info.si = 'not used';
info.useLastFullStack = 1
% Collect a stack with both tip and cell.
%
% This requires first:
% 1.establishing a new set of fields for latest tip and cell locations in image and manipulator coordinates
% 2.at the same time, figure out how to log ALL of the relevant approach data in one place, including the 'trajectory' of
% % measured tip locations and measured cell locations, relevant files, etc.
% 3. then I need to use brl_tif_read to read in the correct subvolumes with the correct channel
%
zTopBuffer = 15; % increased from 10, 12/9/14
zBottomBuffer = 15; %increased form 10 12/15/14
imageZCoordinate = [max(udat.currentTipImage(3)-zTopBuffer,1) udat.currentCellImage(3)+zBottomBuffer]
startz = spStackdata.origStartRelZ+(spStackdata.zStepSize*(imageZCoordinate(1)-1));
stopz = spStackdata.origStartRelZ+(spStackdata.zStepSize*(imageZCoordinate(2)-2)) ; % note that we don't include slice at z+zdepth
% because we want the stack to be zdepth slices
spStackdata.substackGrab = 1;
spStackdata.ignorePostProcessing = 0;
udat.substackSliceStart =round(imageZCoordinate(1));
udat.substackSliceEnd = round(imageZCoordinate(2));
udat.substackStartz = startz;
udat.substackStopz = stopz;
set(findobj(0,'name','smartACT'),'UserData', udat)
set(handles.okCollectStackB,'enable', 'on', 'string', '<html>OK collect<br>Tip And Cell Stack')
set(handles.cancelB,'enable', 'on')
% now print the coordinates to the GUI to allow the user to check:
set(hObject,'string',[ 'start z = ', num2str(udat.substackStartz), ' stop z = ', num2str(udat.substackStopz)], 'fontsize', 8);
%
% try
% brl_collect_SI_Stack(startz, stopz)
% catch
% set(findobj(0,'name','smartACT'),'UserData', udat)
% end
% the rest of the action will take place triggered by the OK button
udat.substackToCollect = 'tipAndCell';
set(findobj(0,'name','smartACT'),'UserData', udat)
%importstack()
guidata(hObject, handles);
% --- Executes on button press in okCollectStackB.
function okCollectStackB_Callback(hObject, eventdata, handles)
% hObject handle to okCollectStackB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
udat = get(findobj(0,'name','smartACT'),'UserData')
set(handles.okCollectStackB,'enable', 'off')
set(handles.cancelB,'enable', 'off')
switch udat.substackToCollect
case 'tipAndCell'
brl_collect_SI_Stack(udat.substackStartz, udat.substackStopz)
case 'cellOnly'
brl_collect_SI_Stack(udat.cellSubstackStartz, udat.cellSubstackStopz)
end
set(findobj(0,'name','smartACT'),'UserData', udat)
% the rest of the action will take place inside brl_sp_grab_handler, but
% use the other buttons here via feval
set(handles.collectTipCellSubstackB,'string','<html>Calculate New <br> Tip and Cell Substack');
set(handles.collectCellSubstackB,'string','<html>Calculate New <br> Cell Substack');
guidata(hObject, handles);
% --- Executes on button press in cancelB.
function cancelB_Callback(hObject, eventdata, handles)
% hObject handle to cancelB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.okCollectStackB,'enable', 'off')
set(handles.cancelB,'enable', 'off')
set(handles.collectTipCellSubstackB,'string','<html>Calculate New <br> Tip and Cell Substack');
set(handles.collectCellSubstackB,'string','<html>Calculate New <br> Cell Substack');
guidata(hObject, handles);
% --- internal function to handle reading in an existing file .
function importStack(~)
% hObject handle to anything ? (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tcuh = findobj('name','brl_tip_cell_update');
tipCellData = get(tcuh, 'UserData');
global spStackdata
if spStackdata.acquisitionRunning ==1
return
end
udat = get(findobj(0,'Name', 'smartACT'), 'UserData');
if numel(udat) ==0
return
end
tipCellData.archiveMode = 0;
%
tipCellData.file = brl_get_latest_file(udat.directory, '*.tif', 'Norm')
% this will be the last .tif file created, which should be the substack.
% there's not too much information to indicate this... I can check the last
scimdata = scim_openTif(tipCellData.file);
scimdata.acq
if udat.substackSliceEnd - udat.substackSliceStart + 1 == scimdata.acq.numberOfZSlices
'imported image is substack'
end
%tipCellData.file='E:\Data\BRLtest\tx\Cux2B002.tif'
%
% import defined substack.
%
% tip location
tipCellData.tipLocation = udat.currentTipImage([1 2 3])
tipCellData.tipSubstackLocation = [tipCellData.tipLocation]-[0 0 udat.substackSliceStart-1]
tipCellData.tiprows = round([max(tipCellData.tipSubstackLocation(1)-20,1) ,tipCellData.tipSubstackLocation(1)+20]) ;
tipCellData.tipcols = round([max(tipCellData.tipSubstackLocation(2)-20,1),tipCellData.tipSubstackLocation(2)+20 ]);
tipCellData.tipzs = round([max(tipCellData.tipSubstackLocation(3)-20,1) , tipCellData.tipSubstackLocation(3)+20]);
argh = brl_tif_read(tipCellData.file, get(udat.tipChannelh,'value'),2,tipCellData.tiprows ,tipCellData.tipcols,tipCellData.tipzs);
zlist = tipCellData.tipzs(1):tipCellData.tipzs(2);
tipCellData.tipzs =[zlist(1) zlist(size(argh,3))]
tipCellData.rawTipImage = argh;
tipCellData.normTipImage = tipCellData.rawTipImage-percentile(tipCellData.rawTipImage(:), .05);
tipCellData.normTipImage = tipCellData.normTipImage/percentile(tipCellData.normTipImage(:), get( findobj('tag','tipNormalization'), 'value'));
tipCellData.normTipImage = 255*tipCellData.normTipImage;
tipCellData.segTipImage = tipCellData.normTipImage>get(findobj('tag','tipThreshold'),'Value');
%
% import defined substack.
%
tipCellData.lastCellLocation = udat.currentCellImage([2 1 3]);
tipCellData.cellSubstackLocation = tipCellData.lastCellLocation-[0 0 udat.substackSliceStart-1]
tipCellData.cellrows = round([max(tipCellData.cellSubstackLocation(1)-20,1) tipCellData.cellSubstackLocation(1)+20]);
tipCellData.cellcols = round([max(tipCellData.cellSubstackLocation(2)-20,1) tipCellData.cellSubstackLocation(2)+20]);
tipCellData.cellzs = round([max(tipCellData.cellSubstackLocation(3)-10,1), tipCellData.cellSubstackLocation(3)+10])
argh = brl_tif_read(tipCellData.file, get(udat.cellChannelh,'value'),2,tipCellData.cellrows ,tipCellData.cellcols, tipCellData.cellzs);
size(argh)
zlist = tipCellData.cellzs(1):tipCellData.cellzs(2);
tipCellData.cellzs =[zlist(1) zlist(size(argh,3))]
tipCellData.rawCellImage = argh;
tipCellData.normCellImage = tipCellData.rawCellImage-percentile(tipCellData.rawCellImage(:), .05);
tipCellData.normCellImage = tipCellData.normCellImage/percentile(tipCellData.normCellImage(:), get( findobj('tag','cellNormalization'), 'value'));
tipCellData.normCellImage = 255*tipCellData.normCellImage;
set(findobj('tag', 'imageFileT'),'String', tipCellData.file);
set(findobj(0,'Name', 'smartACT'), 'UserData', udat);
set(tcuh, 'UserData', tipCellData);
% --- Executes on button press in locateTipB.
function locateTipB_Callback(hObject, eventdata, handles)
% hObject handle to locateTipB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
udat = get(findobj('name', 'smartACT'), 'userdata');
% recapitulate what's in the popup menu callbacks- this callback will be
% called externally
%
% feval(get(handles.tipNormalization,'Callback'), handles.tipNormalization, [])
% feval(get(handles.tipThreshold,'Callback'), handles.tipThreshold, [])
tipCellData = get(handles.figure1, 'UserData')
set(handles.tipReportedLocationT,'String', num2str(tipCellData.tipLocation([1 2 3]), '%.2f '))
% generate MIPs after smoothing
tval = get(handles.tipThreshold,'Value');
mean(tipCellData.normTipImage(:))
tipCellData.normTipImage = tipCellData.rawTipImage-percentile(tipCellData.rawTipImage(:), .05);
tipCellData.normTipImage(tipCellData.normTipImage(:)<0)=0;
tipCellData.normTipImage = tipCellData.normTipImage/percentile(tipCellData.normTipImage(:), get( handles.tipNormalization, 'value'));
tipCellData.normTipImage(tipCellData.normTipImage(:)>1)=1;
tipCellData.normTipImage = 255*tipCellData.normTipImage;
[tipCellData.im3, tipCellData.im2, tipCellData.im1] = brl_MIP_segmentation(tipCellData.normTipImage, tval);
% and extract coordinates:
tipCellData.tipdata = brl_find_tip_2(tipCellData.im3, tipCellData.im2, tipCellData.im1)
testStruct = tipCellData.tipdata
tipCellData.tipdataStackCoordinates = brl_tipdata_to_stack(tipCellData.tipdata, tipCellData.tiprows(1), tipCellData.tipcols(1), tipCellData.tipzs(1))
axes(handles.axes1)
imagesc(tipCellData.tipcols, tipCellData.tiprows,tipCellData.im3);
hold all, plot(max(tipCellData.tipdataStackCoordinates.tipj3),mean(tipCellData.tipdataStackCoordinates.tipi3), 'om'), plot(tipCellData.tipdataStackCoordinates.tipj3,tipCellData.tipdataStackCoordinates.tipi3,'.g')
hold off
axes(handles.axes2)
imagesc(tipCellData.tipcols, tipCellData.tipzs,(tipCellData.im1'));
hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipi1),max(tipCellData.tipdataStackCoordinates.tipj1), 'om') , plot(tipCellData.tipdataStackCoordinates.tipi1,tipCellData.tipdataStackCoordinates.tipj1,'.g')
hold off
axes(handles.axes3)
imagesc(tipCellData.tipzs, tipCellData.tiprows,tipCellData.im2);
hold all, plot(mean(tipCellData.tipdataStackCoordinates.tipj2),mean(tipCellData.tipdataStackCoordinates.tipi2), 'om'), plot(tipCellData.tipdataStackCoordinates.tipj2,tipCellData.tipdataStackCoordinates.tipi2,'.g')
hold off
actualTipPixels = tipCellData.tipdata.coordinates+[tipCellData.tiprows(1) tipCellData.tipcols(1) tipCellData.tipzs(1)+udat.substackSliceStart] -[1 1 1] ;
tipCellData.tipMeasuredLocation = actualTipPixels;
set(handles.tipMeasuredLocationT,'String', [sprintf('%.2f', actualTipPixels(1)), ' ', sprintf('%.2f', actualTipPixels(2)),' ',sprintf('%.2f', actualTipPixels(3))])
% now update the smartACT userdata struct with the new tip coordinates
iTip = udat.Locations.pipetTip;
% and in microns
actualTipMicrons= actualTipPixels([2 1 3]).*([udat.xScale udat.yScale udat.zScale]);
% and relative coordinates for the MP285
actualTipMP285= [iTip(1:2) -iTip(3)]+[-actualTipMicrons(1:2) actualTipMicrons(3)];
if ~isfield(udat, 'tipTraj')
udat.tipTraj=[];
end
% update a trajectory for the tip. it's ok if the last position
% repeats or something.... | prev tip pixels | prev tip Microns | prev tip mp285 | new tip pixels | new tip microns | new tip mp285
udat.tipTraj = [udat.tipTraj; [udat.currentTipImage, udat.currentTipMicrons, udat.CurrentLocation,actualTipPixels, actualTipMicrons, actualTipMP285]];
newt = udat.tipTraj ; % just to echo to command line for debugging
udat.potentialCoordinates.actualTipPixels = actualTipPixels;
udat.potentialCoordinates.actualTipMicrons = actualTipMicrons;
udat.potentialCoordinates.actualTipMP285 = actualTipMP285;
udat.potentialCoordinates.tipThreshold = get(handles.tipThreshold, 'value');
udat.potentialCoordinates.tipNorm = get(handles.tipNormalization,'value');
udat.tipUpdateWorked = 1;
set(findobj('name', 'smartACT'), 'userdata',udat);
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
% --- Executes on button press in locateCellB.
function locateCellB_Callback(hObject, eventdata, handles)
% hObject handle to locateCellB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% feval(get(handles.cellNormalization,'Callback'), handles.cellNormalization, [])
% feval(get(handles.cellThreshold,'Callback'), handles.cellThreshold, [])
udat = get(findobj('name', 'smartACT'), 'userdata');
tipCellData = get(handles.figure1, 'UserData');
set(handles.cellOriginalLocationT,'String', num2str(tipCellData.lastCellLocation([1 2 3]) ,'%.2f '))
params.big = 20;
params.small = 2;
params.thresh =255*get(handles.cellThreshold,'Value');
tipCellData.locateCellStruct = brl_locate_cells(tipCellData.normCellImage,params);
keepRegions=[];
actualCellPixels = [];
for i = 1:numel(tipCellData.locateCellStruct.rpdata)
idat= tipCellData.locateCellStruct.rpdata(i);
actualCellPixels(i,:) = tipCellData.locateCellStruct.rpdata(i).Centroid([2 1 3])+[tipCellData.cellrows(1) tipCellData.cellcols(1) tipCellData.cellzs(1)+udat.substackSliceStart] -[1 1 1]
if idat.Area > 100
keepRegions =[keepRegions; i]
end
end
% figure out which object is the cell of interest
% 1. find the objects that are big enough to be cells
distances = sqrt(sum((actualCellPixels(keepRegions(:),:)- repmat(tipCellData.lastCellLocation([1 2 3]), numel(keepRegions),1)).^2,2))
if numel(keepRegions)==1
tipCellData.cellLocationPixels = actualCellPixels(keepRegions,:);
cellnumber =1;
elseif numel(keepRegions)==0
udat.cellUpdateWorked = 0;
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
else
% if there is more than one of these,
% 2. find the object whos centroid is closest to the original cell location
distances = sqrt(sum((actualCellPixels(keepRegions(:),:)- repmat(tipCellData.lastCellLocation([1 2 3]), numel(keepRegions),1)).^2,2))
% note that this is NOT scaled to microns, just in voxels.
if min(distances)> 17 % hard coded estimate here... many ways to parameterize this if needed
set(handles.cellMeasuredLocationT,'String','cell displacement greater than ~20 microns')
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
return
end
% take the closest one...
cellnumber = keepRegions(distances(:)==min(distances(:)));
tipCellData.cellLocationPixels = actualCellPixels(cellnumber,:);
end
axes(handles.axes4)
imagesc(tipCellData.cellcols, tipCellData.cellrows,squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],3)));
hold all, plot(actualCellPixels(:,2),actualCellPixels(:,1),'.b')
plot(actualCellPixels(cellnumber,2),actualCellPixels(cellnumber,1),'or')
hold off
axes(handles.axes5)
imagesc(tipCellData.cellcols, tipCellData.cellzs+udat.substackSliceStart,squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],1))');
hold all,plot(actualCellPixels(:,2),actualCellPixels(:,3),'.b')
plot(actualCellPixels(cellnumber,2),actualCellPixels(cellnumber,3),'or')
hold off
axes(handles.axes6)
imagesc(tipCellData.cellzs+udat.substackSliceStart,tipCellData.cellrows, squeeze(max(tipCellData.locateCellStruct.labelmatrix,[],2)));
hold all, plot(actualCellPixels(:,3),actualCellPixels(:,1),'.b')
plot(actualCellPixels(cellnumber,3),actualCellPixels(cellnumber,1),'or')
hold off
set(handles.cellMeasuredLocationT,'String', [sprintf('%.2f', actualCellPixels(cellnumber,1)), ' ', sprintf('%.2f', actualCellPixels(cellnumber,2)),' ',sprintf('%.2f', actualCellPixels(cellnumber,3))])
% now update the smartACT userdata struct with the new cell coordinates
iTip = udat.Locations.pipetTip
% convert from pixels to microns
aCellMicrons= actualCellPixels(cellnumber,:).*([udat.xScale udat.yScale udat.zScale])
iTip
actualCellMicrons = aCellMicrons
% and substract iTip location to get to relative coordinates for the MP285
actualCellMP285= actualCellMicrons-iTip([2 1 3])
actualCellMP285 = [actualCellMP285([2 1]) actualCellMP285( 3)]
udat.currentCellMP285= [iTip(1:2) -iTip(3)]+[-udat.currentCellMicrons(1:2) udat.currentCellMicrons(3)];
udat.cellTraj=[]
if ~isfield(udat, 'cellTraj')
udat.cellTraj=[];
end
% udat
% actualCellPixels
% actualCellMicrons
% actualCellMP285
% this coordinate transformation is a wreck. image locations are good:
% udat.currentCellImage, vs actualCellPixels(cellnumber,[2 1 3]), and
% these are used later
udat.cellTraj = [udat.cellTraj; [udat.currentCellImage,actualCellPixels(cellnumber,[2 1 3])]];
newt = udat.cellTraj % just to echo to command line for debugging
udat.potentialCoordinates.currentCellImage = actualCellPixels(cellnumber,[2 1 3]);
udat.potentialCoordinates.cellThreshold = get(handles.cellThreshold, 'value');
udat.potentialCoordinates.cellNorm = get(handles.cellNormalization,'value');
udat.cellUpdateWorked = 1;
set(findobj('name', 'smartACT'), 'userdata',udat);
set(handles.figure1, 'UserData', tipCellData);
guidata(hObject, handles);
% --- Executes on slider movement.
function cellThreshold_Callback(hObject, eventdata, handles)
% hObject handle to cellThreshold (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
tipCellData = get(handles.figure1, 'UserData');
set(handles.cellThreshValT,'String', num2str(get(handles.cellThreshold,'value')));
tipCellData.segCellImage = tipCellData.normCellImage>255*get(handles.cellThreshold,'Value');
set(handles.cellThreshValT,'String', num2str(get(handles.cellThreshold,'value')));
set(handles.figure1, 'UserData', tipCellData);
feval( @cellImageSelectorPM_Callback,handles.cellImageSelectorPM,[], handles)
guidata(hObject, handles);
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes on slider movement.
function cellNormalization_Callback(hObject, eventdata, handles)
% hObject handle to cellNormalization (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
tipCellData = get(handles.figure1, 'UserData');
tipCellData.normCellImage = tipCellData.rawCellImage-percentile(tipCellData.rawCellImage(:), .05);
tipCellData.normCellImage(tipCellData.normCellImage(:)<0)=0;
tipCellData.normCellImage = tipCellData.normCellImage/percentile(tipCellData.normCellImage(:), get( handles.cellNormalization, 'value'));
tipCellData.normTipImage(tipCellData.normTipImage(:)>1)=1;
tipCellData.normCellImage = 255*tipCellData.normCellImage;
set(handles.cellNormValT,'String', num2str(get(handles.cellNormalization,'value')));
feval( @cellImageSelectorPM_Callback, handles.cellImageSelectorPM, [], handles)