-
Notifications
You must be signed in to change notification settings - Fork 2
/
reviewFISHClassification.m
executable file
·1328 lines (1118 loc) · 68.9 KB
/
reviewFISHClassification.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 = reviewFISHClassification(varargin) %nameMod
%% =============================================================
% Name: reviewFISHClassification.m
% Version: 2.5.4, 9th Aug. 2014
% Authors: Allison Wu, Scott Rifkin
% Command: reviewFISHClassification(stackName*) *Optional Input
% Description: reviewFISHClassification.m is a gui to browse the results of the spot finding algorithm, estimate and/or correct errors, and retraing the classifier if specified.
% - Input Argument:
% * stackName, or {dye}_{stackSuffix} pair e.g. tmr_Pos1.tif, tmr001.stk, tmr_001, tmr_Pos1
% * If absent, it will ask you for the stackName.
% - The program brings up 4 image panes and several buttons:
% * The big one on the left has the evaluated maxima arranged left to right, top to bottom in order of probability estimates predicted.
% * The big one on the right has the zoomable image centered around the potential spot.
% * Two smaller ones on the bottom left have zooms of the region around a spot with the raw data and a laplace filtered image of the same region.
% * The 7x7 spot context (along with neighboring slices) is shown in the middle (3D intensity histograms).
% * In the left image pane:
% > Maxima that are classified as spots are bordered by blue.
% > Maxima that are rejected as spots are bordered in yellow.
% > Maxima that are in the training set have a cross on them.
% > Maxima that are manually curated but not in the
% training set have a single diagnol slash through them.
% > The current maximum is marked by a red box.
% > Maxima that are curated at this time are marked
% with light blue border and cross/slash.
% - Possible actions:
% * Click on the grey background of the gui.
% > If you are going to use keystrokes, it is necessary to focus the computer's attention on the gui.
% > Clicking on the grey background changes the focus to the gui and makes the program interpret keystrokes as the gui tells it to.
% * Click the 'Done w/ specimen' button.
% > Done fixing this specimen.
% > Saves all the changes and move on to the next specimen.
% * Page up/down keys. $
% > The left image pane is 25x25 but often more potential spots are evaluated. Page up and down move you up or down to the next page of potential spots.
% * Left/right/up/down arrow.
% > Used to move around the left image pane.
% * Bad specimen toggle button. $
% > If you don't like the looks of the specimen, flag it as bad and move on.
% * Click 'Good Spot' button
% > If you're on a good spot: this spot will be added to the training set. (With a light blue X)
% > If you're on a bad spot: this spot will be curated to a good spot but it will not be added to the training set. (With a single light blue slash)
% * Click 'Not a Spot' button
% > If you're on a bad spot: this spot will be added to the training set. (With a light blue X)
% > If you're on a good spot: this spot will be curated to a bad spot but it will not be added to the training set. (With a single light blue slash)
% * Click 'Add to training set' button
% > Add the spot to the training set without changing the classification.
% * Toggle add corrected spot to trainingSet (On) or Not (off, default)
% > Changes the behavior of the 'Good Spot' and 'Not a Spot' buttons to add to training set in addition to correcting (light blue X).
% * Scrollbar under the right image $
% > Change the zoom of the right image. The number under it displays the current zoom
% * Click 'Undo the Last Spot' button:
% > undo the action on the last spot you curated
% * Click 'Undo All' button:
% > clear all the unsaved (light blue) spot curation.
% * Toggle arrow to spot radio button $
% > There is a little red arrow that points to the current spot in the right image. This toggles it on and off if it is disturbing you.
% * Toggle On=Slice;Off=merge radio button $
% > Changes the right image to just the slice that includes the spot (On) or a max merge of the stack (Off)
% * 'Redo classifySpots' button
% > This retrains the random forest classifier with the new training set.
% > Redo classifySpots on this specimen and output the new results to the GUI.
% * Checkbox in the lower right. $
% > If checked, this means that the user has gone through and corrected this file and is satisfied with it.
%
% Files required: the corresponding **_segStacks.mat, **_wormGaussianFit.mat, trainingSet_**.mat, **_spotStats.mat
% Files generated: overwrites all the files mentioned above except for **_segStacks.mat
%
% Updates:
% - 2012 Aug 13th, small bug fixes
% - 2013 Mar 19th, small bug fixes
% - 2013 May 19th, fix 'index exceeds matrix' problem caused by
% including 'edge spots'.
% - 2014 Aug 9th, make redo mach Learn button run faster by not choosing variables and nFeatures again
% Attribution: Rifkin SA., Identifying fluorescently labeled single molecules in image stacks using machine learning. Methods Mol Biol. 2011;772:329-48.
% License: Apache 2.0, http://www.apache.org/licenses
% Website: http://www.biology.ucsd.edu/labs/rifkin/software/spotFindingSuite
% Email for comments, questions, bugs, requests: sarifkin at ucsd dot edu
%% =============================================================
% reviewFISHClassification M-file for reviewFISHClassification.fig %nameMod
% reviewFISHClassification, by itself, creates a new reviewFISHClassification or %nameMod
% raises the existing
% singleton*.
%
% H = reviewFISHClassification returns the handle to a new reviewFISHClassification or the handle to %nameMod
% the existing singleton*.
%
% reviewFISHClassification('CALLBACK',hObject,eventData,handles,...) calls the %nameMod
% local
% function named CALLBACK in reviewFISHClassification.M with the given input arguments. %nameMod
%
% reviewFISHClassification('Property','Value',...) creates a new reviewFISHClassification or raises the %nameMod
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before reviewFISHClassification_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
% application
% stop. All inputs are passed to reviewFISHClassification_OpeningFcn via
% varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
%
%19April2011 - Removed reliance on stack extent
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help reviewFISHClassification %nameMod
% Last Modified by GUIDE v2.5 08-Aug-2014 15:03:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @reviewFISHClassification_OpeningFcn, ... %nameMod
'gui_OutputFcn', @reviewFISHClassification_OutputFcn, ... %nameMod
'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 reviewFISHClassification is made visible. %nameMod
function reviewFISHClassification_OpeningFcn(hObject, eventdata, handles, varargin) %nameMod
% 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 reviewFISHClassification (see VARARGIN) %nameMod
% Choose default command line output for reviewFISHClassification %nameMod
handles.output = hObject;
handles.figure_handle=get(0,'CurrentFigure');
set(handles.figure_handle,'KeyPressFcn',@figure1_KeyPressFcn);
handles.spotsCurated=[];
%import info and make spot pictures (background subtracted - essentially
%the code from saveSpotPictures
if isempty(varargin)
stackName=input('Please enter the stack name (e.g. tmr001.stk, tmr_Pos1.tif, tmr_001):\n','s');
findTraining=input('Are you using a training set derived from this batch of data? [yes[1]/no[0]]\n ');
elseif length(varargin)==1
stackName=varargin{1};
findTraining=1;
else
stackName=varargin{1};
findTraining=varargin{2};
end
if ~findTraining
trainingSet.sameBatchFlag=zeros(length(trainingSet.spotInfo),1);
end
run('Aro_parameters.m');
handles.WormGaussianFitDir=WormGaussianFitDir;
handles.SpotStatsDir=SpotStatsDir;
handles.SegStacksDir=SegStacksDir;
handles.TrainingSetDir=TrainingSetDir;
handles.nestedOrFlatDirectoryStructure=nestedOrFlatDirectoryStructure;
[dye, stackSuffix, wormGaussianFitName, segStacksName,spotStatsFileName]=parseStackNames(stackName);
handles.findTraining=findTraining;
handles.dye=dye;
handles.stackSuffix=stackSuffix;
handles.posNum=str2num(cell2mat(regexp(stackSuffix,'\d+','match')));
handles.goodColor=[.3 .3 .7];
handles.badColor=[.5 .5 .1];
handles.wormsFileName=wormGaussianFitName;
fprintf('Loading %s ... \n',wormGaussianFitName);
switch nestedOrFlatDirectoryStructure
case 'flat'
load(wormGaussianFitName);
case 'nested'
load(fullfile(WormGaussianFitDir,dye,wormGaussianFitName));
end;
handles.worms=worms;
clear worms
fprintf('Loading %s ... \n', spotStatsFileName)
switch nestedOrFlatDirectoryStructure
case 'flat'
load(spotStatsFileName)
case 'nested'
load(fullfile(SpotStatsDir,dye,spotStatsFileName));
end;
handles.spotStats=spotStats;
handles.spotStatsFileName=spotStatsFileName;
clear spotStats
fprintf('Loading %s ... \n', segStacksName)
switch nestedOrFlatDirectoryStructure
case 'flat'
load(segStacksName)
case 'nested'
load(fullfile(SegStacksDir,dye,segStacksName));
end;
handles.segStacks=segStacks;
handles.segMasks=segMasks;
clear segStacks segMasks
set(handles.fileName_button,'String', wormGaussianFitName);
if ~isempty(handles.worms)
load(handles.spotStats{1}.trainingSetName); %directory structure already incorporated into it
handles.trainingSet=trainingSet;
clear trainingSet
else
disp('Breaking execution');
return%this should break the execution
end
disp('Training set loaded.');
handles.wormImageMaxMerge={};
for wi=1:length(handles.worms)
%bb=regionprops(double(currpolys{wi}),'BoundingBox');
%handles.wormBBs{wi}=bb.BoundingBox;
for zi=1:size(handles.segStacks{wi},3)
handles.segStacks{wi}(:,:,zi)=imscale(handles.segStacks{wi}(:,:,zi),99.995);%.*handles.segMasks{wi};%added the scaling here instead of later
end;
stackH=size(handles.segStacks{wi},3);
handles.wormImageMaxMerge{wi}=imscale(max(handles.segStacks{wi}(:,:,floor(stackH/8):ceil(stackH*7/8)),[],3));
handles.laplaceWorm{wi}=laplaceFISH(handles.segStacks{wi},1);
handles.laplaceWormImageMaxMerge{wi}=imscale(max(handles.laplaceWorm{wi}(:,:,floor(stackH/8):ceil(stackH*7/8)),[],3));
%also take care of goodWorms
if ~isfield(handles.worms{wi},'goodWorm')
handles.worms{wi}.goodWorm=1;
end;
%added nuclear information 3/31/11
if isfield(handles,'nuclearInformation')
if eq(handles.nuclearInformation(wi,2),-1)
handles.worms{wi}.goodWorm=0;
set(handles.badWorm_button,'Value',1);
guidata(hObject,handles);
end;
end;
end;
handles.spotSize=[7 7];
handles.offset=floor((handles.spotSize-1)/2);
handles.iCurrentWorm=1;
if ~isfield(handles.worms{handles.iCurrentWorm},'spotsFixed')
handles.worms{handles.iCurrentWorm}.spotsFixed=0;
end;
set(handles.fileName_button,'Value',handles.worms{handles.iCurrentWorm}.spotsFixed);
handles=drawTheLeftPlane(handles);
handles.nGoodToRejected=0;
handles.nRejectedToGood=0;
nGood=sum(handles.allLocs(:,5));
guidata(hObject, handles);
displayImFull(hObject,handles,0);
% UIWAIT makes reviewFISHClassification wait for user response (see UIRESUME)
uiwait(handles.figure1);%%%function lineBox makes xdata and ydata for lines out of rectangle
%%%position - goes clockwise from NW
function [xdata,ydata]=lineBox(position)
NW=position(1:2);
xdata=[NW(1),NW(1)+position(3),NW(1)+position(3),NW(1),NW(1)];
ydata=[NW(2),NW(2),NW(2)+position(4),NW(2)+position(4),NW(2)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%displayImFull
function displayImFull(hObject,handles,drawSpotResults)
data=guidata(hObject);
set(data.nGoodToRejected_txt,'String',[num2str(data.nGoodToRejected) ' good -> rejected']);
set(data.nRejectedToGood_txt,'String',[num2str(data.nRejectedToGood) ' rejected -> good']);
set(data.nGoodSpots_txt,'String',[num2str(sum(data.allLocs(:,5))) ' good spots']);
set(data.nRejectedSpots_txt,'String',[num2str(sum(data.allLocs(:,5)~=1)) ' rejected spots']);
set(data.iCurrentWorm_txt,'String',['Specimen: ' num2str(data.iCurrentWorm) ' of ' num2str(length(data.worms))]);
set(data.RandomForestResult_txt,'String',['Probability Estimate: ' num2str(data.allLocs(data.iCurrentSpot_allLocs,7)*100) '%']);
set(data.scdValue_txt,'String',['scd: ' num2str(data.worms{data.iCurrentWorm}.spotDataVectors.scd(data.iCurrentSpot_worms))]);
set(data.iCurrentSpot_worms_txt,'String',['Index of spot: ' num2str(data.iCurrentSpot_worms)]);
set(data.badWorm_button,'Value',abs(data.worms{data.iCurrentWorm}.goodWorm-1));%changes good 1,0 to bad 1,0
currentZ=data.allLocs(data.iCurrentSpot_allLocs,3);
set(data.currentSlice_txt,'String',['Slice ' num2str(currentZ) ' of ' num2str(size(data.segStacks{data.iCurrentWorm},3))]);
currentSlice=data.segStacks{data.iCurrentWorm}(:,:,currentZ);
zoom(data.spotResultsImage,'factor',data.vertSideSize/(1+data.horizSideSize));
spotBoxesTotalWidth=data.horizSideSize*data.spotSize(1);
xlim(data.spotResults,[colToX(1) colToX(spotBoxesTotalWidth)]);
currentSpotY=data.spotBoxLocations(data.iCurrentSpot_allLocs,2);%N edge of spotBox
spotPage=ceil(currentSpotY/(spotBoxesTotalWidth));
set(data.spotPage_txt,'String',sprintf('Spot page %d of %d',spotPage,ceil(data.vertSideSize/data.horizSideSize)));
ylim(data.spotResults,[rowToY((spotPage-1)*spotBoxesTotalWidth+1) rowToY(spotPage*spotBoxesTotalWidth)]);
if drawSpotResults %this doesn't appear to ever be true as of 5Mar15
for si=1:size(data.allLocs,1)
if data.allLocs(si,5)==1 %good spots
edgeColor=[.1,.1,.5];
else %bad spots
edgeColor=[.5,.5,.1];
end
rectangle('Position',[data.outLines(si,:) data.spotSize],'EdgeColor',edgeColor);
%for si=1:size(data.goodOutlines,1)
% rectangle('Position',[data.goodOutlines(si,:) data.spotSize],'EdgeColor',[.1,.1,.5]);
%end;
%rejected = yellow rectangles
%for si=1:size(data.rejectedOutlines,1)
% rectangle('Position',[data.rejectedOutlines(si,:) data.spotSize],'EdgeColor',[.5,.5,.1]);
%end;
if data.Curated(:,3)==1 % Curated to good spot
rectangle('Position',[data.Curated(si,1:2) data.spotSize],'EdgeColor',[0,.7,.7]);
elseif data.Curated(:,3)==0 % Curated to bad spot
rectangle('Position',[data.Curated(si,1:2) data.spotSize],'EdgeColor',[1,.5,0]);
end
end
end
%currentSpot
set(data.currentSpotRectangle,'Position',[data.spotBoxLocations(data.iCurrentSpot_allLocs,1)+1,data.spotBoxLocations(data.iCurrentSpot_allLocs,2)+1 data.spotSize-2],'EdgeColor',[1 0 0]);
%%%%%%%%%%%%
set(data.figure_handle,'CurrentAxes',data.spotContext);
%equalize the sides (fill in with black)
sz=size(currentSlice);
spotContextIm=zeros(max(sz));
boundaryIm=zeros(max(sz));
if get(data.sliceMerge_button,'Value')==1
if get(data.laplaceFilter_button,'Value')==1
spotContextIm(1:sz(1),1:sz(2))=imscale(data.laplaceWorm{data.iCurrentWorm}(:,:,currentZ),99.995);
else
spotContextIm(1:sz(1),1:sz(2))=imscale(currentSlice,99.995);%(currentSlice-min(currentSlice(:)))/getCurrentGoodMax(data);%imscale(currentSlice);
end;
else%merge
if get(data.laplaceFilter_button,'Value')==1
spotContextIm(1:sz(1),1:sz(2))=scale(data.laplaceWormImageMaxMerge{data.iCurrentWorm});
else
spotContextIm(1:sz(1),1:sz(2))=scale(data.wormImageMaxMerge{data.iCurrentWorm});
end;
end;
boundary=bwmorph(data.segMasks{data.iCurrentWorm},'remove');
boundaryIm(1:sz(1),1:sz(2))=boundary;
%need to fill with black so that it matches the size of spotContextIM
spotContextIm_withBoundary=cat(3,max(0,spotContextIm-.4*boundaryIm),spotContextIm,max(0,spotContextIm-.4*boundaryIm));
data.spotContext=imshow(spotContextIm_withBoundary);
%Note that if there is a very bright pixel in this, it will tend to make
%everything else very dark
zoomFactor=get(data.spotContextSlider,'Value');
currentSpotX=data.spotBoxPositions(data.iCurrentSpot_allLocs,1)+data.offset(2);
currentSpotY=data.spotBoxPositions(data.iCurrentSpot_allLocs,2)+data.offset(1);
origXLim=get(gca,'XLim'); origWidth=origXLim(2)-origXLim(1);
origYLim=get(gca,'YLim'); origHeight=origYLim(2)-origYLim(1);
if get(data.arrowSpot_button,'Value')%data.arrowToSpotOnEmbryo
if data.allLocs(data.iCurrentSpot_allLocs,5)==1 %good spots
arrowColor=[0,1,1];
else %bad spots
arrowColor=[1,1,0];
end
line('Xdata',[currentSpotX+4, currentSpotX+3, currentSpotX+4, currentSpotX+3,currentSpotX+6],'Ydata',[currentSpotY-1+.5, currentSpotY+.5,currentSpotY+1+.5,currentSpotY+.5,currentSpotY+.5],'color',arrowColor);
%rectangle('Position',[currentSpotX-7 currentSpotY-7 15 15],'EdgeColor',[.8 .4 0],'LineStyle','--');
%Note that the rectangle was intrusive - it focused attention on the
%putative spot and brought out its spotness even if it was no different from
%garbage around it. The arrow visually preserves its context
end;
zoom(zoomFactor);
currContextX=max(1,currentSpotX-floor(.5*origWidth/(zoomFactor)));
currContextX=min(currContextX,origWidth-origWidth/zoomFactor);
currContextY=max(1,currentSpotY-floor(.5*origHeight/(zoomFactor)));
currContextY=min(currContextY,origHeight-origHeight/zoomFactor);
xlim(get(data.figure_handle,'CurrentAxes'),[currContextX currContextX+origWidth/zoomFactor]);
ylim(get(data.figure_handle,'CurrentAxes'),[currContextY currContextY+origHeight/zoomFactor]);
%%%%%%%%%%%%
set(data.figure_handle,'CurrentAxes',data.spotZoomLaplaceFiltered);
%This is from when I had it display the raw data matrix in blue with pink
%marking the maximum
rc=imregionalmax(currentSlice);
data.spotZoomRaw=imshow(cat(3,.75*imscale(currentSlice,99.995)+imscale(currentSlice,99.995).*rc,imscale(currentSlice,99.995),imscale(currentSlice,99.995)));
%%%
data.spotZoomLaplaceFiltered=imshow(imscale(data.laplaceWorm{data.iCurrentWorm}(:,:,currentZ),99.995));
zoomFactorX=origWidth/data.spotSize(2);
zoomFactorY=origHeight/data.spotSize(1);
zoomFactor=max(zoomFactorX,zoomFactorY);
zoom(zoomFactor);
xlim(get(data.figure_handle,'CurrentAxes'),[currentSpotX-data.offset(2) currentSpotX+data.offset(2)+1]);%because want to include that last pixel not have it be the edge
ylim(get(data.figure_handle,'CurrentAxes'),[currentSpotY-data.offset(1) currentSpotY+data.offset(1)+1]);
%%%%%%%%%%%%
set(data.figure_handle,'CurrentAxes',data.spotZoomBkgdSub);
%Need the check wehther on edge
rows=(yToRow(currentSpotY)-data.offset(2)):(yToRow(currentSpotY)+data.offset(2));
cols=(xToCol(currentSpotX)-data.offset(1)):(xToCol(currentSpotX)+data.offset(1));
if rows(1)<1
rows=rows+(1-rows(1));
elseif rows(end)>size(currentSlice,1)
rows=rows-(rows(end)-size(currentSlice,1));
end;
if cols(1)<1
cols=cols+(1-cols(1));
elseif cols(end)>size(currentSlice,2)
cols=cols-(cols(end)-size(currentSlice,2));
end;
dataMat=currentSlice(rows,cols);
minDataMat=min(dataMat(:));
scaledSlice=currentSlice-minDataMat;
scaledSlice=scaledSlice.*(scaledSlice>0);
data.spotZoomBkgdSub=imshow(imscale(scaledSlice,99.995));
zoomFactorX=origWidth/data.spotSize(2);
zoomFactorY=origHeight/data.spotSize(1);
zoomFactor=min(zoomFactorX,zoomFactorY);
zoom(zoomFactor);
xlim(get(data.figure_handle,'CurrentAxes'),[currentSpotX-data.offset(2) currentSpotX+data.offset(2)+1]);
ylim(get(data.figure_handle,'CurrentAxes'),[currentSpotY-data.offset(1) currentSpotY+data.offset(1)+1]);
%%%%%%%%%%%%
surfWidth=7;
surfNR=max(1,yToRow(currentSpotY)-surfWidth);
surfWC=max(1,xToCol(currentSpotX)-surfWidth);
surfEC=min(origWidth,xToCol(currentSpotX)+surfWidth);
surfSR=min(origHeight,yToRow(currentSpotY)+surfWidth);
%fprintf('%d %d %d %d\n',surfWC,surfNR,surfEC,surfSR);
surfColumn=data.segStacks{data.iCurrentWorm}(surfNR:surfSR,surfWC:surfEC,:);
%freezeColors;
for i=1:3
if currentZ+(i-2)<=size(data.segStacks{data.iCurrentWorm},3) && currentZ+(i-2)>=1
tex=sc(surfColumn(:,:,currentZ+(i-2)),'hsv');
set(data.figure_handle,'CurrentAxes',data.surfPlots{i});
surf(surfColumn(:,:,currentZ+(i-2)),tex);
set(data.surfPlots{i},'YDir','reverse','XTick',[],'ZLim',[0 1],'YTick',[],'ZTick',[],'Visible','off','Color',get(data.figure_handle,'Color'));
end;
end;
%this is the function that will record the center of the spot
set(data.spotResults,'ButtonDownFcn',@spotResults_ButtonDownFcn);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%guidata(hObject,data);
% --- Outputs from this function are returned to the command line.
function varargout = reviewFISHClassification_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)
%disp('in OutputFcn');
% Get default command line output from handles structure
varargout{1} = handles.output;
%rerun the randomForest with the trainingSet as it currently stands after
%review disp(handles);
disp('Spot fixing done. Saving changes');
button = questdlg('Do you want to re-train the classifier now?','Re-train?','No');
switch button
case {'No'}
button = questdlg('Do you want to save the training set and updated spot data when exiting?','Save when exiting?','Yes');
switch button
case {'No'}
delete(handles.figure1)
case {'Yes'}
disp('Saving the training set and updated spot stats....')
trainingSet=handles.trainingSet;
save(handles.trainingSet.FileName,'trainingSet'); %directory structure already in it
worms=handles.worms;
spotStats=handles.spotStats;
switch handles.nestedOrFlatDirectoryStructure
case 'flat'
save(handles.wormsFileName,'worms');
save(handles.spotStatsFileName,'spotStats');
case 'nested'
save(fullfile(handles.WormGaussianFitDir,handles.dye,handles.wormsFileName),'worms');
save(fullfile(handles.SpotStatsDir,handles.dye,handles.spotStatsFileName),'spotStats');
end; disp(spotStats{1});
disp(handles.spotStatsFileName);
delete(handles.figure1)
end
case {'Yes'}
disp('Saving the training set and updated spot stats....')
trainingSet=handles.trainingSet;
save(handles.trainingSet.FileName,'trainingSet');%directory structure already in it
worms=handles.worms;
spotStats=handles.spotStats;
%disp(spotStats{1});
switch handles.nestedOrFlatDirectoryStructure
case 'flat'
save(handles.wormsFileName,'worms');
save(handles.spotStatsFileName,'spotStats');
case 'nested'
save(fullfile(handles.WormGaussianFitDir,handles.dye,handles.wormsFileName),'worms');
save(fullfile(handles.SpotStatsDir,handles.dye,handles.spotStatsFileName),'spotStats');
end; delete(handles.figure1)
disp('Rerunning randomForest with the latest amendments');
handles.trainingSet=trainRFClassifier(handles.trainingSet); %nameMod
disp('Redo classification of the spots for this stack...')
handles.spotStats=classifySpots(handles.worms,handles.trainingSet);
end
disp('output fcn done');
%pos_size = get(handles.figure1,'Position');
% --- Executes on slider movement.
function spotContextSlider_Callback(hObject, eventdata, handles)
% hObject handle to spotContextSlider (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
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes during object creation, after setting all properties.
function spotContextSlider_CreateFcn(hObject, eventdata, handles)
% hObject handle to spotContextSlider (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 button press in goodSpot_button.
function goodSpot_button_Callback(hObject, eventdata, handles)
% hObject handle to goodSpot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
goodLineColor=[0 .7 .7];
currentSpotClassification=handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,:);
handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,3)=1;
handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,1)=1;
handles.allLocs(handles.iCurrentSpot_allLocs,4)=1;
handles.allLocs(handles.iCurrentSpot_allLocs,5)=1;
rectposition=get(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'Position');
newSpotRow=[handles.posNum handles.iCurrentWorm handles.iCurrentSpot_worms 1];
handles.spotsCurated=[handles.spotsCurated;[newSpotRow currentSpotClassification(3)]];
if currentSpotClassification(3)~=1%it was not manually marked as good
disp(sprintf('Accepting rejected spot %d',handles.iCurrentSpot_worms));
handles.nRejectedToGood=handles.nRejectedToGood+1;
%modify image
NW=handles.spotBoxLocations(handles.iCurrentSpot_allLocs,:);
if currentSpotClassification(1)~=-1
disp('This spot already was manually marked as bad and now we are changing it to good');
handles.allLocs(handles.iCurrentSpot_allLocs,4)=1;
if handles.findTraining
[~,~,iCurrentSpot_trainingSet]=intersect(newSpotRow(1:3),handles.trainingSet.spotInfo(:,1:3),'rows'); %Check to see if the spot is in the training set
else
iCurrentSpot_trainingSet=[];
end
if isempty(iCurrentSpot_trainingSet) % not in the training set
disp('This spot is not in the training set. It is manually curated but not added to the training set.')
else
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',goodLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end
elseif get(handles.addCorrToTS_button,'Value') %it is a bad spot but was not manually marked as good and add corrections to training set button is on
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
disp('This spot is added into the training set.')
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',goodLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end;
else % It is already a good spot. Add to training set.
disp('This spot is already classified as good spot. Adding this spot into the training set....')
handles.allLocs(handles.iCurrentSpot_allLocs,4)=1;
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
disp('This spot is added into the training set.')
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',goodLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.curationLine=line('Xdata',[rectposition(1)+1,rectposition(1)+handles.spotSize(1)-1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',goodLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
set(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'EdgeColor',handles.goodColor);
handles.iCurrentSpot_allLocs=min(size(handles.spotBoxLocations,1),handles.iCurrentSpot_allLocs+1);
handles.iCurrentSpot_worms=handles.allLocs(handles.iCurrentSpot_allLocs,6);
%setfocus(handles.spotResults);
%uicontrol(gcbf);
set(handles.arrowSpot_button,'Value',1)
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes on button press in rejectedSpot_button.
function rejectedSpot_button_Callback(hObject, eventdata, handles)
% hObject handle to rejectedSpot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
badLineColor=[.7 .7 0];
currentSpotClassification=handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,:);
handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,3)=0;
handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,1)=0;
handles.allLocs(handles.iCurrentSpot_allLocs,5)=0;
handles.allLocs(handles.iCurrentSpot_allLocs,4)=0;
rectposition=get(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'Position');
newSpotRow=[handles.posNum handles.iCurrentWorm handles.iCurrentSpot_worms 0];
handles.spotsCurated=[handles.spotsCurated;[newSpotRow currentSpotClassification(3)]];
if currentSpotClassification(3)~=0
disp(sprintf('Rejected an accepted spot %d',handles.iCurrentSpot_worms));
handles.nGoodToRejected=handles.nGoodToRejected+1;
%modify image
NW=handles.spotBoxLocations(handles.iCurrentSpot_allLocs,:);
if currentSpotClassification(1)~=-1
disp('This spot already was manually marked as bad and now we are changing it to good');
if handles.findTraining
[~,~,iCurrentSpot_trainingSet]=intersect(newSpotRow(1:3),handles.trainingSet.spotInfo(:,1:3),'rows'); %Check to see if the spot is in the training set
else
iCurrentSpot_trainingSet=[];
end
if isempty(iCurrentSpot_trainingSet) % not in the training set
disp('This spot is not in the training set. It is manually curated but not added to the training set.')
else
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',badLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end
elseif get(handles.addCorrToTS_button,'Value') %it is a bad spot but was not manually marked as good and add corrections to training set button is on
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
disp('This spot is added into the training set.')
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',badLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end;
else % It is already a bad spot. Add to training set.
disp('This spot is already classified as bad spot. Adding this spot into the training set....')
handles.allLocs(handles.iCurrentSpot_allLocs,4)=0;
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
disp('This spot is added into the training set.')
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',badLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
end
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.curationLine=line('Xdata',[rectposition(1)+1,rectposition(1)+handles.spotSize(1)-1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',badLineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
set(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'EdgeColor',handles.badColor);
handles.iCurrentSpot_allLocs=min(size(handles.spotBoxLocations,1),handles.iCurrentSpot_allLocs+1);
handles.iCurrentSpot_worms=handles.allLocs(handles.iCurrentSpot_allLocs,6);
%setfocus(handles.spotResults);
%uicontrol(gcbf);
set(handles.arrowSpot_button,'Value',1);
guidata(hObject,handles);
displayImFull(hObject,handles,0);
%--adds final spot information
function specimen = recordFinalClassification(specimen)
%records the final spot count and adds field 'final' to the classification
specimen.nSpotsFinal=0;
for si=1:size(specimen.spotInfo,2)
%remember that some of the spots were not classified but were thrown
%out
if isfield(specimen.spotInfo{si},'classification')
if isfield(specimen.spotInfo{si}.classification,'manual')
specimen.spotInfo{si}.classification.final=specimen.spotInfo{si}.classification.manual;
else
specimen.spotInfo{si}.classification.final=specimen.spotInfo{si}.classification.MachLearn{1};
end;
specimen.nSpotsFinal=specimen.nSpotsFinal+specimen.spotInfo{si}.classification.final;
end;
end;
% --- Executes on button press in done_button.
function done_button_Callback(hObject, eventdata, handles)
% hObject handle to done_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data=guidata(hObject);
data.spotStats{data.iCurrentWorm}.spotsFixed=1;
data.spotStats{data.iCurrentWorm}=updateSpotStats(data.spotStats{data.iCurrentWorm});
set(data.arrowSpot_button,'Value',1)
guidata(hObject,data);
if data.iCurrentWorm<length(data.worms)
data.iCurrentWorm=data.iCurrentWorm+1;%go to the next specimen
while ~data.worms{data.iCurrentWorm}.goodWorm%if the specimen is bad
data.iCurrentWorm=data.iCurrentWorm+1;%go to the next specimen
end
if ~isfield(data.worms{data.iCurrentWorm},'spotsFixed')
data.worms{data.iCurrentWorm}.spotsFixed=0;
end
set(data.fileName_button,'Value',data.worms{data.iCurrentWorm}.spotsFixed);
data=drawTheLeftPlane(data);
nGood=sum(data.allLocs(:,5));
guidata(hObject, data);
else%then completely done-write training set and new spotFile, 21April2011 and goldSpots and rejectedSpots files
uiresume(gcbf);
end
displayImFull(hObject,data,0);
% --- Executes on mouse press over axes background.
function spotResults_ButtonDownFcn(currhandle, eventdata)
% hObject handle to spotResults (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%get location of mouse click
data=guidata(currhandle);
%disp('Mouse button clicked');
pt = get(data.spotResults,'currentpoint');
pixel_c=xToCol(pt(1,1));
pixel_r=yToRow(pt(1,2));
%disp(pt);
%assign it to some spot
%disp(data.spotIndexImage);
spotIndex=data.spotIndexImage(pixel_r,pixel_c);
if spotIndex>0
data.iCurrentSpot_allLocs=spotIndex;
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
end;
set(data.arrowSpot_button,'Value',1)
guidata(currhandle,data);
displayImFull(currhandle,data,0);
% --- Executes during object creation, after setting all properties.
function spotResults_CreateFcn(hObject, eventdata, handles)
% hObject handle to spotResults (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate spotResults
% --- Executes on key press with focus on figure1 and no controls selected.
function figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%eventdata.Key
data=guidata(hObject);
if strcmp(eventdata.Key,'leftarrow')
data.iCurrentSpot_allLocs=max(data.iCurrentSpot_allLocs-1,1);
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
elseif strcmp(eventdata.Key,'rightarrow')
data.iCurrentSpot_allLocs=min(size(data.spotBoxLocations,1),data.iCurrentSpot_allLocs+1);
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
elseif strcmp(eventdata.Key,'uparrow')
data.iCurrentSpot_allLocs=max(1,data.iCurrentSpot_allLocs-data.horizSideSize);
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
elseif strcmp(eventdata.Key,'downarrow')
data.iCurrentSpot_allLocs=min(size(data.spotBoxLocations,1),data.iCurrentSpot_allLocs+data.horizSideSize);
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
elseif strcmp(eventdata.Key,'pagedown')
data.iCurrentSpot_allLocs=min(size(data.spotBoxLocations,1),data.iCurrentSpot_allLocs+(data.horizSideSize^2)+1);
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
elseif strcmp(eventdata.Key,'pageup')
data.iCurrentSpot_allLocs=max(1,data.iCurrentSpot_allLocs-(data.horizSideSize^2));
data.iCurrentSpot_worms=data.allLocs(data.iCurrentSpot_allLocs,6);
end;
set(data.arrowSpot_button,'Value',1)
guidata(hObject,data);
displayImFull(hObject,data,0);
% --- Executes on key press with focus on rejectedSpot_button and none of its controls.
function rejectedSpot_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to rejectedSpot_button (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
%keypress = get(handles.figure_handle,'CurrentCharacter');%handles.figure1
figure1_KeyPressFcn(hObject, eventdata, handles);
% --- Executes on key press with focus on goodSpot_button and none of its controls.
function goodSpot_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to goodSpot_button (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
figure1_KeyPressFcn(hObject, eventdata, handles);
% --- Executes on key press with focus on done_button and none of its controls.
function done_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to done_button (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% % Character: characte interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
figure1_KeyPressFcn(hObject, eventdata, handles);
% --- Executes on key press with focus on redoMachLearn_button and none of its controls.
function redoMachLearn_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to rejectedSpot_button (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
%keypress = get(handles.figure_handle,'CurrentCharacter');%handles.figure1
figure1_KeyPressFcn(hObject, eventdata, handles);
% --- Executes on button press in redoMachLearn_button.
function redoMachLearn_button_Callback(hObject, eventdata, handles)
% hObject handle to redoMachLearn_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.trainingSet=trainRFClassifier(handles.trainingSet,'runVarFeatureSel',false); %use old variables and nFeatures
handles.spotStats=classifySpots(handles.worms,handles.trainingSet);
handles.iCurrentWorm=1;
handles=drawTheLeftPlane(handles);
nGood=sum(handles.allLocs(:,5));
set(handles.arrowSpot_button,'Value',1)
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes on button press in badWorm_button.
function badWorm_button_Callback(hObject, eventdata, handles)
% hObject handle to badWorm_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.worms{handles.iCurrentWorm}.goodWorm=0;
set(handles.badWorm_button,'Value',1)
guidata(hObject,handles);
done_button_Callback(hObject,eventdata,handles);
% --- Executes on key press with focus on badWorm_button and none of its controls.
function badWorm_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to badWorm (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
%keypress = get(handles.figure_handle,'CurrentCharacter');%handles.figure1
figure1_KeyPressFcn(hObject, eventdata, handles);
function spotPage = currentSpotPage(horizSideSize,spotSize,spotBoxLocations,iCurrentSpot)
spotBoxesTotalWidth=horizSideSize*spotSize;
currentSpotY=spotBoxLocations(iCurrentSpot,2);%N edge of spotBox
spotPage=ceil(currentSpotY/(spotBoxesTotalWidth));
function m=getCurrentGoodMax(handles)
%create vector of goodLoc values
goodIntensities=[];
goodIndices=find(handles.spotStatus==1);
for ai=1:length(goodIndices)
loc=handles.allLocs(goodIndices(ai),1:3);
goodIntensities=[goodIntensities handles.segStacks{handles.iCurrentWorm}(loc(1),loc(2),loc(3))];
end;
m=max(goodIntensities);
% --- Executes on button press in arrowSpot_button.
function arrowSpot_button_Callback(hObject, eventdata, handles)
% hObject handle to arrowSpot_button (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 arrowSpot_button
%checkboxStatus = 0, if the box is unchecked,
%checkboxStatus = 1, if the box is checked
%handles.rectangleAroundSpotOnEmbryo = get(handles.arrowSpot_button,'Value');
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes during object creation, after setting all properties.
function fileName_button_CreateFcn(hObject, eventdata, handles)
% hObject handle to fileName_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in fileName_button.
function fileName_button_Callback(hObject, eventdata, handles)
% hObject handle to fileName_button (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 fileName_button
%if the user unchecks the handle, then the state of "spotsFixed" changes so
%that user can redo. the program reads the value of spotsFixed before it
%decides to save/update or not
if handles.worms{handles.iCurrentWorm}.spotsFixed> get(hObject,'Value')
handles.worms{handles.iCurrentWorm}.spotsFixed=get(hObject,'Value');
end;
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes on button press in addToTrainingSet_button.
function addToTrainingSet_button_Callback(hObject, eventdata, handles)
% hObject handle to addToTrainingSet_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('Adding this spot into the training set....')
currentSpotClassification=handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,:);
if currentSpotClassification(3)==1
lineColor=[0 .7 .7];
else
lineColor=[.7 .7 0];
end;
handles.spotStats{handles.iCurrentWorm}.classification(handles.iCurrentSpot_worms,1)=currentSpotClassification(3);
handles.allLocs(handles.iCurrentSpot_allLocs,4)=currentSpotClassification(3);
spotIndex=[handles.posNum handles.iCurrentWorm handles.iCurrentSpot_worms];
newSpotRow=[spotIndex currentSpotClassification(3)];
handles.spotsCurated=[handles.spotsCurated;[newSpotRow currentSpotClassification(3)]];
handles.trainingSet=updateTrainingSet(handles.trainingSet,handles.worms,newSpotRow);
rectposition=get(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'Position');
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.trainingLine=line('Xdata',[rectposition(1)+handles.spotSize(1)-1,rectposition(1)+1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',lineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
handles.rectangleHandles{handles.iCurrentSpot_allLocs}.curationLine=line('Xdata',[rectposition(1)+1,rectposition(1)+handles.spotSize(1)-1],'Ydata',[rectposition(2)+1,rectposition(2)+handles.spotSize(2)-1],'Color',lineColor,'LineWidth',2,'HitTest','off','Parent',handles.spotResults);
%set(handles.rectangleHandles{handles.iCurrentSpot_allLocs}.rect,'EdgeColor',[0,.7,.7]); %leave the rectangle alone
handles.iCurrentSpot_allLocs=min(size(handles.spotBoxLocations,1),handles.iCurrentSpot_allLocs+1);
handles.iCurrentSpot_worms=handles.allLocs(handles.iCurrentSpot_allLocs,6);
%setfocus(handles.spotResults);
%uicontrol(gcbf);
set(handles.arrowSpot_button,'Value',1)
guidata(hObject,handles);
displayImFull(hObject,handles,0);
% --- Executes on key press with focus on addToTrainingSet_button and none
% of its controls. added 2/17/10
function addToTrainingSet_button_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to addToTrainingSet_button (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
figure1_KeyPressFcn(hObject, eventdata, handles);
% --- Executes on button press in sliceMerge_button.
function sliceMerge_button_Callback(hObject, eventdata, handles)
% hObject handle to sliceMerge_button (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 sliceMerge_button
guidata(hObject,handles);