-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventDetector.m
3970 lines (3113 loc) · 169 KB
/
eventDetector.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 = eventDetector(varargin)
% EVENTDETECTOR M-file for eventDetector.fig
% EVENTDETECTOR, by itself, creates a new EVENTDETECTOR or raises the existing
% singleton*.
%
% H = EVENTDETECTOR returns the handle to a new EVENTDETECTOR or the handle to
% the existing singleton*.
%
% EVENTDETECTOR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EVENTDETECTOR.M with the given input arguments.
%
% EVENTDETECTOR('Property','Value',...) creates a new EVENTDETECTOR or raises the
% existing singleton*. Starting from the left, property value pairs
% are
% applied to the GUI before eventDetector_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to eventDetector_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 eventDetector
% Last Modified by GUIDE v2.5 28-Dec-2009 15:28:24
%% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @eventDetector_OpeningFcn, ...
'gui_OutputFcn', @eventDetector_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 eventDetector is made visible.
function eventDetector_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 eventDetector (see VARARGIN)
% Choose default command line output for eventDetector
handles.output = hObject;
%add figure toolbar to window
%set(hObject,'toolbar','figure');
set(handles.figMain,'KeyPressFcn',@keyboardShortcuts);
set(handles.lstSweeps,'KeyPressFcn',@keyboardShortcuts);
%init values
%set dimensions of plot windows
handles.plotWidthMin = 0;
handles.plotWidthMax = 1;
handles.plotVHeightMin = 0;
handles.plotVHeightMax = 1;
handles.plotCHeightMin = 0;
handles.plotCHeightMax = 1;
handles.plotEventWidthMin = 0;
handles.plotEventWidthMax = 1;
handles.plotEventHeightMin = 0;
handles.plotEventHeightMax = 1;
handles.plotEventWidthMinDefault = 0.02;
handles.plotEventWidthMaxDefault = 20000;
% handles.plotEventHeightMinDefault = 0;
% handles.plotEventHeightMaxDefault = 80;
handles.plotEventHeightMinDefault = 3;
handles.plotEventHeightMaxDefault = 40;
%set dimensions of plot windows
handles.plotWidthMinDefault = 0;
handles.plotWidthMaxDefault = 3;
handles.plotVHeightMinDefault = -250;
handles.plotVHeightMaxDefault = 250;
handles.plotCHeightMinDefault = -100;
handles.plotCHeightMaxDefault = 100;
handles.onFigure = 0;
%init file and pathname as null arrays
handles.pathname = [];
handles.filename = [];
handles.currentFileIndex = 0;
handles.currentSweep = 1;
handles.lineBaseline = 0;
handles.firstLoad = 1;
handles.firstMeanLoad = 1;
handles.firstDiffLoad = 1;
handles.detectedEvents_ms = [];
handles.detectedEvents = [];
handles.detectedEventsVoltages = [];
handles.axes5 = 0;
handles.analyzeEvents = 0;
handles.numOpenFiles = 0;
handles.numDetectedEvents = zeros(handles.numOpenFiles,1);
handles.numEvents = zeros(handles.numOpenFiles,1);
handles.baseline = 0;
handles.fishingBaseline = 0;
handles.defaultPathname = '';
handles.filename = '';
handles.buttonUp = [0, 0];
handles.buttonDown = [0, 0];
handles.numSignals = 0;
handles.sweepsAnalyzed = [];
handles.rmsNoise = 0;
handles.fishingFile = 0;
handles.rampingFile = 0;
handles.primerFile = 0;
handles.analyzeBounds = 0;
handles.analyzeUpperBound = 1;
handles.analyzeLowerBound = 0;
handles.limitAnalysisBetweenCursors = 0;
handles.minEventTime = 0.2;
handles.probingVoltage = -20;
handles.holdingVoltage = 50;
handles.ejectVoltage = -120;
handles.cutoffEventSum = 0;
handles.runningSumCutoffEvent = 0;
handles.keepCutoffEvents = 0;
handles.currentDNAnumber = 0;
handles.oldDNAnumber = 0;
handles.currentMoleculeColor = [0,0,1];
handles.rmsThreshold = 7;
handles.filtered = 0;
handles.cutoffEventFoundRamp = [0,0];
handles.cutoffEventVoltageTimingPrimer = [0,0,0];
%zero out open files listbox
set( handles.lstOpenFiles, 'String', {} );
%initialize cutoff event numbers
handles.cutoffEventSweep = 0;
handles.cutoffEventStartTime = 0;
handles.beginHighOut = 0;
handles.vChangeStart = 0;
%calculate progress bar location above main window
tempUnits = get(handles.figMain, 'Units');
set(handles.figMain, 'Units', 'pixels');
currentMainWindowPosition = get(handles.figMain,'Position');
screenSize = get(0, 'ScreenSize');
%normalize to be less than 1
handles.progressBarPos = [currentMainWindowPosition(1)/screenSize(3),(currentMainWindowPosition(2)+currentMainWindowPosition(4)+35)/screenSize(4)];
set(handles.figMain, 'Units', tempUnits);
%zero out lstSweeps
set( handles.lstSweeps, 'String', {} );
set( handles.lstSweepsExcluded, 'String', {} );
set( handles.edtThreshold, 'String', '7' );
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes eventDetector wait for user response (see UIRESUME)
% uiwait(handles.figMain);
%% --- Outputs from this function are returned to the command line.
function varargout = eventDetector_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 selection change in lstSweeps.
function lstSweeps_Callback(hObject, eventdata, handles)
% hObject handle to lstSweeps (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns lstSweeps contents as cell array
% contents{get(hObject,'Value')} returns selected item from lstSweeps
%get selected sweep number for lstSweeps
listSweep = get(handles.lstSweeps, 'String');
indexSweep = get(handles.lstSweeps, 'Value');
selectedSweep = listSweep{indexSweep};
selectedSweepInfo = sscanf(selectedSweep, 'Sweep %d.%d');
handles.currentSweep = selectedSweepInfo(2);
handles.currentFileIndex = selectedSweepInfo(1);
%set dimensions of plot windows
handles.plotWidthMin = handles.plotWidthMinDefault;
handles.plotWidthMax = handles.plotWidthMaxDefault;
handles.plotVHeightMin = handles.plotVHeightMinDefault;
handles.plotVHeightMax = handles.plotVHeightMaxDefault;
handles.plotCHeightMin = handles.plotCHeightMinDefault;
handles.plotCHeightMax = handles.plotCHeightMaxDefault;
%update current sweep and plot
loadCurrentSweep( hObject, eventdata, handles );
%get changes to handles made in loadCurrentSweep
handles = guidata( hObject );
% Update handles structure
guidata(hObject, handles);
%% --- Executes during object creation, after setting all properties.
function lstSweeps_CreateFcn(hObject, eventdata, handles)
% hObject handle to lstSweeps (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%% --- Executes on selection change in lstSweepsExcluded.
function lstSweepsExcluded_Callback(hObject, eventdata, handles)
% hObject handle to lstSweepsExcluded (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns lstSweepsExcluded contents as cell array
% contents{get(hObject,'Value')} returns selected item from lstSweepsExcluded
%% --- Executes during object creation, after setting all properties.
function lstSweepsExcluded_CreateFcn(hObject, eventdata, handles)
% hObject handle to lstSweepsExcluded (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%% --- Executes on button press in btnExclude.
function btnExclude_Callback(hObject, eventdata, handles)
% hObject handle to btnExclude (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
listSweep = get(handles.lstSweeps, 'String');
listSweepExcluded = get(handles.lstSweepsExcluded, 'String');
indexSweep = get(handles.lstSweeps, 'Value');
if( indexSweep <= length( listSweep ) )
selectedSweep = listSweep{indexSweep};
listSweepExcluded{length(listSweepExcluded)+1} = selectedSweep;
listSweep(indexSweep) = [];
%rebuild and sort cell array
sweepsNumbers = zeros( length(listSweepExcluded), 2 );
for i = 1:length(listSweepExcluded)
sweepsNumbers(i,:) = sscanf(listSweepExcluded{i}, 'Sweep %d.%d');
end
%sort!
sweepsNumbers = sortrows( sweepsNumbers );
%rebuild cell array
for i = 1:length( listSweepExcluded );
listSweepExcluded{i} = ['Sweep ',num2str(sweepsNumbers(i,1)), '.', num2str(sweepsNumbers(i,2))];
end
%update list
set(handles.lstSweeps, 'String', listSweep );
set(handles.lstSweepsExcluded, 'String', listSweepExcluded);
set(handles.lstSweepsExcluded, 'Enable', 'on');
%if last element is selected, select new last
if( indexSweep >= length( listSweep ) && indexSweep > 1 )
indexSweep = indexSweep - 1;
set(handles.lstSweeps, 'Value', indexSweep );
end
handles.numEvents(handles.currentFileIndex) = handles.numEvents(handles.currentFileIndex) - 1; %length(listSweep);
%disp( handles.numEvents );
if( isequal( handles.sweepsAnalyzed{ handles.currentFileIndex }(handles.currentSweep) , 1 ) )
sweepEvents = find( ((handles.detectedEvents(:,5) == handles.currentSweep) & (handles.detectedEvents(:,10) == handles.currentFileIndex)) );
%load pre-calculated event info into timingInfo
timingInfo = handles.detectedEvents( sweepEvents, 2:3 );
[m,n] = size(timingInfo);
handles.numDetectedEvents(handles.currentFileIndex) = handles.numDetectedEvents(handles.currentFileIndex) - m;
set( handles.txtNumEvents, 'String', ['Detected Events: ', num2str(sum(handles.numDetectedEvents))] );
end
lstSweeps_Callback(hObject, eventdata, handles)
handles = guidata( hObject );
end
% Update handles structure
guidata(hObject, handles);
%% --- Executes on button press in btnInclude.
function btnInclude_Callback(hObject, eventdata, handles)
% hObject handle to btnInclude (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
listSweep = get(handles.lstSweeps, 'String');
listSweepExcluded = get(handles.lstSweepsExcluded, 'String');
indexSweep = get(handles.lstSweepsExcluded, 'Value');
%make sure list is non-empty
if( indexSweep <= length( listSweepExcluded ) )
selectedSweep = listSweepExcluded{indexSweep};
listSweep{length(listSweep)+1} = selectedSweep;
listSweepExcluded(indexSweep) = [];
%rebuild and sort cell array
sweepsNumbers = zeros( length(listSweep), 2 );
for i = 1:length(listSweep)
sweepsNumbers(i,:) = sscanf( listSweep{i}, 'Sweep %d.%d');
end
%sort!
sweepsNumbers = sortrows( sweepsNumbers );
%rebuild cell array
for i = 1:length( listSweep );
listSweep{i} = ['Sweep ', num2str(sweepsNumbers(i,1)), '.', num2str(sweepsNumbers(i,2))];
end
set(handles.lstSweeps, 'String', listSweep);
set(handles.lstSweepsExcluded, 'String', sort(listSweepExcluded) );
set(handles.lstSweepsExcluded, 'Enable', 'on');
%if last element is selected, select new last
if( indexSweep >= length( listSweepExcluded ) && indexSweep > 1 )
indexSweep = indexSweep - 1;
set(handles.lstSweepsExcluded, 'Value', indexSweep );
end
handles.numEvents(handles.currentFileIndex) = handles.numEvents(handles.currentFileIndex) + 1; %length(listSweep);
selectedSweepInfo = sscanf(selectedSweep, 'Sweep %d.%d');
selectedSweepNum = selectedSweepInfo(2);
selectedSweepFile = selectedSweepInfo(1);
if( isequal( handles.sweepsAnalyzed{handles.currentFileIndex}( selectedSweepNum ) , 1 ) )
sweepEvents = find( ((handles.detectedEvents(:,5) == selectedSweepNum) & (handles.detectedEvents(:,10) == selectedSweepFile)) );
%load pre-calculated event info into timingInfo
timingInfo = handles.detectedEvents( sweepEvents, 2:3 );
[m,n] = size(timingInfo);
handles.numDetectedEvents(handles.currentFileIndex) = handles.numDetectedEvents(handles.currentFileIndex) + m;
set( handles.txtNumEvents, 'String', ['Detected Events: ', num2str(sum(handles.numDetectedEvents))] );
end
end
% Update handles structure
guidata(hObject, handles);
%% --- Executes on changed of edtABFDescription
function edtABFDescription_Callback(hObject, eventdata, handles)
% hObject handle to edtABFDescription (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edtABFDescription as text
% str2double(get(hObject,'String')) returns contents of edtABFDescription as a double
%% --- Executes during object creation, after setting all properties.
function edtABFDescription_CreateFcn(hObject, eventdata, handles)
% hObject handle to edtABFDescription (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%% --- Executes on button press in btnExportEvent.
function btnExportEvent_Callback(hObject, eventdata, handles)
% hObject handle to btnExportEvent (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%disableButtons(handles);
%update baseline from edit box
handles.axes5 = figure(1);
handles.baseline = str2double( get( handles.edtBaseline, 'String') );
%init figure
set(handles.axes5, 'Position', [200 100 1000 450], 'Name', 'Detected Events Export');
%poreEventData = handles;
poreEventData.detectedEvents = handles.detectedEvents;
poreEventData.detectedEvents_ms = handles.detectedEvents_ms;
% poreEventData.listSweeps = get( handles.lstSweeps, 'String');
% poreEventData.listSweepsExcluded = get( handles.lstSweepsExcluded, 'String');
%build excluded sweep numbers
excludedSweeps = get(handles.lstSweepsExcluded, 'String');
excludedSweepsNumbers = zeros( length( excludedSweeps ), 1 );
if( ~isempty(excludedSweeps) )
for i = 1:length( excludedSweeps )
excludedSweepInfo = sscanf(excludedSweeps{i}, 'Sweep %d.%d');
excludedSweepsNumbers(i) = excludedSweepInfo(2);
excludedFileNumbers(i) = excludedSweepInfo(1);
poreEventData.sweepsAnalyzed(excludedSweepsNumbers(i)) = 0;
end
indsToDel = [];
for sweepNum = 1:size(excludedSweepsNumbers,1)
[inds, vals] = find( (handles.detectedEvents(:,1) == excludedSweepsNumbers(sweepNum)) & (handles.detectedEvents(:,10) == excludedFileNumbers(sweepNum)));
if( ~isempty( inds ) )
indsToDel = [indsToDel; inds];
end
end
%trim off un-used space due to pre-allocating
if( ~isempty(indsToDel) )
poreEventData.detectedEvents(indsToDel,:) = [];
poreEventData.detectedEvents_ms(indsToDel,:) = [];
end
end
%plot events
[m,n] = size( poreEventData.detectedEvents_ms );
if( m >= 1) %if any events have been detected
if( n >= 9 ) %dna molecule information included
numberDNAmolecules = max( poreEventData.detectedEvents_ms(:,9) );
for i = 0:numberDNAmolecules
if( i == 0 )
moleculeColor = [0,0,1];
else
moleculeColor = [rand, rand, rand];
end
try
if( handles.fishingFile == 1 )
nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) & (poreEventData.detectedEvents_ms(:,10) == 3));
% nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) );
nonCutoffEventsInitial = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) & (poreEventData.detectedEvents_ms(:,10) ~= 3));
else
% nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) & (poreEventData.detectedEvents_ms(:,10) ~= 2));
% nonCutoffEventsInitial = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) & (poreEventData.detectedEvents_ms(:,10) == 2));
% nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i));
nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) );
nonCutoffEventsInitial = [];
end
semilogx( poreEventData.detectedEvents_ms(nonCutoffEventsInitial ,4), poreEventData.detectedEvents_ms(nonCutoffEventsInitial,5), 's', 'Color', moleculeColor );
semilogx( poreEventData.detectedEvents_ms(nonCutoffEvents ,4), poreEventData.detectedEvents_ms(nonCutoffEvents,5), '.', 'Color', moleculeColor );
%nonCutoffEventsInitial = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) == i) & (poreEventData.detectedEvents_ms(:,10) == 2));
% semilogx( poreEventData.detectedEvents_ms(nonCutoffEvents ,4), poreEventData.detectedEvents_ms(nonCutoffEvents,5), '.', 'Color', moleculeColor );
%semilogx( poreEventData.detectedEvents_ms(nonCutoffEventsInitial ,4), poreEventData.detectedEvents_ms(nonCutoffEventsInitial,5), 's', 'Color', moleculeColor );
catch
semilogx( poreEventData.detectedEvents_ms(: ,4), poreEventData.detectedEvents_ms(:,5), '.', 'Color', moleculeColor );
end
if( i == 1 )
hold on;
end
end
else
try
nonCutoffEvents = find( poreEventData.detectedEvents_ms(:,8) == 0 );
semilogx( poreEventData.detectedEvents_ms(nonCutoffEvents ,4), poreEventData.detectedEvents_ms(nonCutoffEvents,5), 'b.' );
catch
semilogx( poreEventData.detectedEvents_ms(: ,4), poreEventData.detectedEvents_ms(:,5), 'b.' );
end
hold on;
end
try
cutoffEvents = find( poreEventData.detectedEvents_ms(:,8) == 1);
semilogx( poreEventData.detectedEvents_ms(cutoffEvents ,4), poreEventData.detectedEvents_ms(cutoffEvents,5), 'r.' );
catch
end
hold off;
end
% grid on;
%get number of fishing events
windowFilename = makeWindowTitleString(hObject, eventdata, handles);
if( handles.fishingFile == 1 )
%nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,10) == 3));
nonCutoffEvents = find( (poreEventData.detectedEvents_ms(:,8) == 0) & (poreEventData.detectedEvents_ms(:,9) ~= 0) );
numFishEvents = length( poreEventData.detectedEvents_ms(nonCutoffEvents ,4) )
title( { [windowFilename, ' - ', get(handles.edtABFDescription, 'String')]; [ 'baseline: ', num2str(handles.baseline), ' pA', ', ', num2str( numFishEvents ), ' total fishing events, analyzed ', date]} );
else
title( { [windowFilename, ' - ', get(handles.edtABFDescription, 'String')]; [ 'baseline: ', num2str(handles.baseline), ' pA', ', ', num2str( sum(handles.numDetectedEvents) ), ' total events, analyzed ', date]} );
end
xlabel('Mean Dwell Time (ms)');
ylabel('Amplitude (pA)');
%axis([0.02 20000 10 40]);
axis([ handles.plotEventWidthMin, handles.plotEventWidthMax, handles.plotEventHeightMin, handles.plotEventHeightMax ]);
%save figure as eps
maximize(gcf);
xlabel('Mean Dwell Time (10^x ms)');
set(gca, 'XScale', 'log')
handles.dateAnalyzed = date;
handles.dataDescription = get(handles.edtABFDescription, 'String');
descriptionLength = length( handles.dataDescription );
if( descriptionLength >= 50 )
filenameDescriptLength = 50;
elseif( descriptionLength < 50 )
filenameDescriptLength = descriptionLength;
end
windowFilename = makeWindowTitleString(hObject, eventdata, handles);
saveFilename = [windowFilename, ' - analyzed ', handles.dateAnalyzed, '_', handles.dataDescription(1:filenameDescriptLength)];
exportfig(gcf, [saveFilename, '.eps'], 'bounds', 'tight', 'FontSize', 1.8, 'Color', 'rgb');
eps2pdf([saveFilename, '.eps'], 'C:\gs\bin\gswin32.exe')
%delete eps file and leave pdf
delete([saveFilename, '.eps']);
close(gcf);
enableButtons(handles);
% Update handles structure
guidata(hObject, handles);
%% --- Executes on button press in btnExportTrace.
function btnExportTrace_Callback(hObject, eventdata, handles)
% hObject handle to btnExportTrace (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%update baseline from edit box
handles.baseline = str2double( get( handles.edtBaseline, 'String') );
%init figure
handles.axesTracePlot = figure(2);
%fprintf('[%f:%f:%f] %f total points\n', handles.plotIndexBegin, handles.plotDelta, handles.plotIndexEnd, length( handles.traceData(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd) ) );
%update baseline from edit box
handles.baseline = str2double( get( handles.edtBaseline, 'String') );
%plot voltage signal if present
if( handles.numSignals > 1 )
hVoltage = subplot(handles.numSignals,1,2);
plot( (handles.timeVector(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd)-handles.plotWidthMin)*1000, handles.traceData(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd,2), 'r-', 'HitTest', 'off' );
grid on;
ylabel('mV');
xlabel('Time (ms)');
axis([(handles.plotWidthMin-handles.plotWidthMin)*1000, (handles.plotWidthMax-handles.plotWidthMin)*1000, handles.plotVHeightMin, handles.plotVHeightMax]);
%hold off
end
%plot first sweep
%make current plot active
%plot current signal
hCurrent = subplot(handles.numSignals,1,1);
plot( (handles.timeVector(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd)-handles.plotWidthMin).*1000, handles.traceData(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd,1), 'r-', 'HitTest', 'off' );
ylabel('pA');
if( handles.numSignals == 1 )
xlabel('Time (ms)');
end
axis([(handles.plotWidthMin-handles.plotWidthMin)*1000, (handles.plotWidthMax-handles.plotWidthMin)*1000, handles.plotCHeightMin, handles.plotCHeightMax]);
grid on;
hold on;
% %plot calculated baseline
% if( handles.baseline > handles.plotCHeightMin && handles.baseline < handles.plotCHeightMax)
% handles.lineBaseline = line( [handles.plotWidthMin handles.plotWidthMax], [handles.baseline handles.baseline], 'LineStyle', '--', 'Color', 'k' );
% end
%%%%%%%%%%%%%%%%%%%%%%%%
%loop over data and apply exponential mean filter
%calculate the exponentially weighted moving average
if( isequal(get(handles.chkShowMean, 'Value'), 1) )
subplot(handles.numSignals,1,1), plot( (handles.timeVector(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd)-handles.plotWidthMin).*1000, handles.meanArray(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd,1), 'b', 'HitTest', 'off' );
end
%end exp filter
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
%calculate finite difference
if( isequal(get( handles.chkShowDiff, 'Value'), 1) )
subplot(handles.numSignals,1,1),plot( (handles.timeVector(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd)-handles.plotWidthMin).*1000, handles.diffArray(handles.plotIndexBegin:handles.plotDelta:handles.plotIndexEnd,1), 'g-', 'HitTest', 'off' );
end
%end finite difference
%%%%%%%%%%%%%%%%%%%%%%%%%%
%resize figures (values are percentages of figure window)
%and adjust axes label (e.g. remove it)
if( handles.numSignals > 1 )
set(hCurrent, 'Position',[0.1300 0.3406 0.7750 0.5844], 'XTickLabel','');
set(hVoltage, 'Position',[0.1300 0.1100 0.7750 0.1706]);
end
hold off;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot detected events if previously calculated
% if( isequal(handles.sweepsAnalyzed( handles.currentSweep ), 1) )
% %use single sweep analyze callback
% btnAnalyze_Callback(hObject, eventdata, handles)
% %get changes to handles made in btnAnalyze_Callback
% handles = guidata( hObject );
% else
% set( handles.txtCurrentPlot, 'String', 'Current Signal Trace (Not Analyzed)' );
% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%save figure as eps
maximize(gcf);
handles.dateAnalyzed = date;
handles.dataDescription = get(handles.edtABFDescription, 'String');
descriptionLength = length( handles.dataDescription );
if( descriptionLength >= 50 )
filenameDescriptLength = 50;
elseif( descriptionLength < 50 )
filenameDescriptLength = descriptionLength;
end
windowFilename = makeWindowTitleString(hObject, eventdata, handles);
saveFilename = [windowFilename, ' - analyzed ', handles.dateAnalyzed, '_', num2str(handles.plotWidthMin), 'ms-', num2str(handles.plotWidthMax), 'ms Sweep ', num2str(handles.currentSweep), ' ', handles.dataDescription];
exportfig(gcf, [saveFilename, '.eps'], 'bounds', 'tight', 'FontSize', 1.8, 'Color', 'rgb');
eps2pdf([saveFilename, '.eps'], 'C:\gs\bin\gswin32.exe')
%delete eps file and leave pdf
delete([saveFilename, '.eps']);
close(handles.axesTracePlot);
%save trace data to mat file
timingInfo = handles.timeVector(handles.plotIndexBegin:handles.plotIndexEnd)';
currentData = handles.traceData(handles.plotIndexBegin:handles.plotIndexEnd,1);
if( handles.numSignals >= 2 )
voltageData = handles.traceData(handles.plotIndexBegin:handles.plotIndexEnd,2);
end
save([saveFilename '.mat'], 'timingInfo', 'currentData', 'voltageData');
clear timingInfo;
clear currentData;
clear voltageData;
enableButtons(handles);
% Update handles structure
guidata(hObject, handles);
%% --- Executes on button press in btnAnalyze.
function btnAnalyze_Callback(hObject, eventdata, handles)
% hObject handle to btnAnalyze (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%update baseline from edit box
handles.baseline = str2double( get( handles.edtBaseline, 'String') );
%set flag to show either events or current trace depending on what is
%visible
if( strcmp( get( handles.axes6, 'Visible'), 'on' ) )
showEventPlot = 1;
axes( handles.axes6 );
else
showEventPlot = 0;
end
%extract events out of current sweep only if they haven't been analyzed
%before
if( isequal(handles.sweepsAnalyzed{handles.currentFileIndex}(handles.currentSweep), 0) )
handles.minEventTime = str2double( get( handles.edtMinEventTime, 'String' ) );
handles.holdingVoltage = str2double( get( handles.edtHoldingVoltage, 'String' ) );
handles.probingVoltage = str2double( get( handles.edtProbingVoltage, 'String' ) );
handles.ejectVoltage = str2double( get( handles.edtEjectVoltage, 'String' ) );
if isnan( handles.minEventTime )
handles.minEventTime = 0;
end
if( handles.fishingFile == 0 ) handles.fishingBaseline = -250; end
if( handles.rampingFile == 1 ) handles.fishingBaseline = -500; end
if( handles.primerFile == 1 ) handles.fishingBaseline = -750; end
%check if in multisweep analyze mode
if( isequal(handles.analyzeEvents, 0) )
handles.cutoffEventSweep = 0;
handles.cutoffEventStartTime = 0;
end
%bound event check to between cursors
if( get(handles.chkAnalyzeBounds, 'Value') == 1 )
%send only amount of trace that is selected
analyzeStart = round(handles.analyzeLowerBound / handles.samplePeriod);
analyzeEnd = round(handles.analyzeUpperBound / handles.samplePeriod);
[timingInfo, cutoffEventSweep, cutoffEventStartTime, currentDNAnumber, beginHighOut, cutoffVChangeStart,cutoffEventFoundRamp, cutoffEventFoundPrimer, eventVoltageTimingPrimer] ...
= parseEvents( handles.traceData(analyzeStart:analyzeEnd,:), handles.samplePeriod, handles.baseline, handles.rmsNoise, handles.minEventTime, handles.fishingBaseline, handles.currentSweep, 0, 0, 0, 0, 0, 0, handles.rmsThreshold, handles.holdingVoltage, handles.probingVoltage, handles.ejectVoltage );
%add on cutoff event flag and DNA number for events and
%classification
if( ~isempty(timingInfo) )
timingInfo = [timingInfo, zeros(length(timingInfo(:,1)),4)];
end
%put in if cutoffEventSweep and cutoffEventStartTime are non-zero
%then an event has been cutoff, flag accordingly
if( handles.keepCutoffEvents == 1 && cutoffEventSweep ~= 0 && cutoffEventStartTime ~= 0 )
timingInfo = [timingInfo; cutoffEventStartTime, analyzeEnd-(analyzeStart-1), cutoffEventSweep, cutoffEventSweep, 1, cutoffVChangeStart, 0, 0, 0, 0, 0, 0, 0];
end
if( ~isempty(timingInfo) )
%re-bias to starting time equal to zero;
timingInfo(:,1:2) = timingInfo(:,1:2) + (analyzeStart-1);
end
else
% fprintf( '%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n', handles.samplePeriod, handles.baseline, handles.rmsNoise, handles.minEventTime, handles.fishingBaseline, handles.currentSweep, handles.cutoffEventSweep, handles.cutoffEventStartTime, handles.currentDNAnumber, handles.beginHighOut, handles.vChangeStart, handles.rmsThreshold);
[timingInfo, cutoffEventSweep, cutoffEventStartTime, currentDNAnumber, beginHighOut, cutoffVChangeStart,cutoffEventFoundRamp, cutoffEventFoundPrimer, eventVoltageTimingPrimer] ...
= parseEvents( handles.traceData, handles.samplePeriod, handles.baseline, handles.rmsNoise, handles.minEventTime, handles.fishingBaseline, handles.currentSweep, handles.cutoffEventSweep, handles.cutoffEventStartTime, handles.currentDNAnumber, handles.beginHighOut, handles.vChangeStart, handles.cutoffEventFoundRamp, handles.cutoffEventVoltageTimingPrimer, handles.rmsThreshold, handles.holdingVoltage, handles.probingVoltage, handles.ejectVoltage );
handles.currentDNAnumber = currentDNAnumber;
handles.beginHighOut = beginHighOut;
handles.vChangeStart = cutoffVChangeStart;
%add on cutoff event flag and DNA number for events
if( ~isempty(timingInfo) )
timingInfo = [timingInfo(:,1:4), zeros(length(timingInfo(:,1)),1), timingInfo(:,5:8)];
end
%if sweep info is the same, continued sweep event
if( (isequal( cutoffEventSweep, 0 ) && isequal( cutoffEventStartTime, 0 )) )
%previous cutoff event possible ended
%save for amp calculation
handles.cutoffEventSum = handles.runningSumCutoffEvent;
handles.runningSumCutoffEvent = 0;
elseif( (isequal( cutoffEventSweep, handles.cutoffEventSweep ) && isequal( cutoffEventStartTime, handles.cutoffEventStartTime )) )
%add sweep sum to running total
handles.runningSumCutoffEvent = handles.runningSumCutoffEvent + sum( handles.traceData(:,1) );
else %cutoff event info changes (new cutoff event)
%previous cutoff event possible ended
%save for amp calculation
handles.cutoffEventSum = handles.runningSumCutoffEvent;
%start new running total
handles.runningSumCutoffEvent = sum( handles.traceData( cutoffEventStartTime-cutoffVChangeStart:end, 1 ) );
end
handles.cutoffEventSweep = cutoffEventSweep;
handles.cutoffEventStartTime = cutoffEventStartTime;
handles.cutoffEventFoundRamp = cutoffEventFoundRamp;
handles.cutoffEventVoltageTimingPrimer = cutoffEventFoundPrimer;
end
else
%just load the previously saved results
%get indices of events from current sweep
try
%find what found events are in currentSweep
% temp = handles.detectedEvents;
% disp(temp)
sweepEvents = find( ((handles.detectedEvents(:,1) == handles.currentSweep) & (handles.detectedEvents(:,10) == handles.currentFileIndex)) | ((handles.detectedEvents(:,4) == handles.currentSweep) & (handles.detectedEvents(:,10) == handles.currentFileIndex)) | ((handles.detectedEvents(:,5) == handles.currentSweep) & (handles.detectedEvents(:,10) == handles.currentFileIndex)) );
%load pre-calculated event info into timingInfo
timingInfo = [handles.detectedEvents( sweepEvents, 2:3 ), handles.detectedEvents( sweepEvents, 4:11 )];
%go through
catch
lasterror
timingInfo = [];
end
end
%set current signal plot active
%axes(handles.axesCurrent);
%loop over detected events for current sweep and annotate figure
[m,n] = size(timingInfo);
%get number of events that end in the current sweep
%use that to associate event with sweep
if( m > 0 )
numEventsInSweep = length( find(timingInfo(:,4) == handles.currentSweep) );
else
numEventsInSweep = 0;
end
%update detected event count
set( handles.txtCurrentPlot, 'String', ['Current Signal Trace (', num2str(numEventsInSweep),' detected events)'] );
for i = 1:m
eventStart = timingInfo(i,1)*handles.samplePeriod;
eventEnd = timingInfo(i,2)*handles.samplePeriod;
%set start/end of event for current sweep
eventStartSamples = timingInfo(i,1);
eventEndSamples = timingInfo(i,2);
%check to see if event data has start and stop sweeps (old mat files
%won't
if( n >= 4 )
% disp( timingInfo(i,:) )
%calculate dwell time for events ending in this sweep
if( timingInfo(i,3) ~= timingInfo(i,4) )
%add in sweep time if event crosses one whole sweep before
%ending
if( (timingInfo(i,4)-timingInfo(i,3)) > 1 ) %event continues through whole sweep
eventDwellSamples = ( (timingInfo(i,4)-timingInfo(i,3)-1).*handles.numSamples + (eventEndSamples) + (handles.numSamples-eventStartSamples+1) );
else
%don't add in extra sweep lengths
eventDwellSamples = ( (eventEndSamples) + (handles.numSamples-eventStartSamples+1) );
end
%calculate amplitude for cutoff events
avgAmplitude = (handles.cutoffEventSum + sum( handles.traceData( 1:eventEndSamples,1 ) )) ./ eventDwellSamples;
%calculate dwell time
eventDwellTime = eventDwellSamples*handles.samplePeriod;
% fprintf('eventDwellTime: %f, sum(traceData): %d, end sweep: %d\n', eventDwellTime, sum( handles.traceData(1:eventEndSamples,1 ) ), timingInfo(i,4) );
else
%events are in same sweep
% avgAmplitude = mean( handles.traceData(eventStartSamples:eventEndSamples, 1) );
%iqrAmplitudeIndices = find( (handles.traceData(eventStartSamples:eventEndSamples,1) >= prctile(handles.traceData(eventStartSamples:eventEndSamples,1),25)) & (handles.traceData(eventStartSamples:eventEndSamples,1) <= prctile(handles.traceData(eventStartSamples:eventEndSamples,1),75)) );
%avgAmplitude = mean( handles.traceData( iqrAmplitudeIndices, 1 ) );
avgAmplitude = mean( handles.traceData(eventStartSamples+timingInfo(i,8):eventEndSamples, 1) );
eventDwellTime = (eventEnd - eventStart);
end
%adjust start and end indices for plotting purposes
if( timingInfo(i,3) < handles.currentSweep )
eventStartSamples = 1; %event starts in previous sweep
elseif( timingInfo(i,4) > handles.currentSweep )
eventEndSamples = handles.numSamples; %event starts in next sweep
end
%calculate current event length
% eventDwellTime = ( ((timingInfo(i,4)-timingInfo(i,3)).*handles.numSamples) + (eventEndSamples-eventStartSamples) )*handles.samplePeriod;
else
% avgAmplitude = mean( handles.traceData(eventStartSamples:eventEndSamples, 1) );
%iqrAmplitudeIndices = find( (handles.traceData(eventStartSamples:eventEndSamples,1) >= prctile(handles.traceData(eventStartSamples:eventEndSamples,1),25)) & (handles.traceData(eventStartSamples:eventEndSamples,1) <= prctile(handles.traceData(eventStartSamples:eventEndSamples,1),75)) );
%avgAmplitude = mean( handles.traceData( iqrAmplitudeIndices, 1 ) );
%offset amplitue calculation by the size of the
%capacitive transient, timingInfo(i,8)
avgAmplitude = mean( handles.traceData(eventStartSamples+timingInfo(i,8):eventEndSamples, 1) );
eventDwellTime = (eventEnd - eventStart);
end
% if( ~isempty(timingInfo) )
% fprintf('event [%d,%d], cutoff event: %d\n', timingInfo(i,1), timingInfo(i,2), timingInfo(i,5) )
% end
%color detected events
hold on;
if( (isequal(handles.analyzeEvents, 0) || isequal(get(handles.chkReview, 'Value'), 1)) && (showEventPlot == 0) ) %only show events if doing single sweep analysis or review events is on
if( isequal(get(handles.chkShowMean, 'Value'), 1) )
%plot mean of detected event
plot( handles.timeVector(eventStartSamples:handles.plotDelta:eventEndSamples), handles.meanArray(eventStartSamples:handles.plotDelta:eventEndSamples), 'm-', 'HitTest', 'off');
else
if( timingInfo(i,7) == 2 || timingInfo(i,7) == 0 || timingInfo(i,7) == 4 || timingInfo(i,7) == 10 )
plot( handles.timeVector(eventStartSamples:handles.plotDelta:eventEndSamples), handles.traceData(eventStartSamples:handles.plotDelta:eventEndSamples, 1), 'b-', 'HitTest', 'off');
elseif (timingInfo(i,7) == 11)
%Plot eject primer events as green
plot( handles.timeVector(eventStartSamples:handles.plotDelta:eventEndSamples), handles.traceData(eventStartSamples:handles.plotDelta:eventEndSamples, 1), 'g-', 'HitTest', 'off');
else
%plot raw signal of detected event
plot( handles.timeVector(eventStartSamples:handles.plotDelta:eventEndSamples), handles.traceData(eventStartSamples:handles.plotDelta:eventEndSamples, 1), 'm-', 'HitTest', 'off');
end
end
end
%make matrix of detected event statistics
if( isequal(handles.sweepsAnalyzed{handles.currentFileIndex}(handles.currentSweep), 0) ) %if events haven't been detected yet (first time through)
%plot fitted curve
%avgAmplitude = plotFittedEventCurve( hObject, eventdata, handles, timingInfo(i,1), timingInfo(i,2) );
if( showEventPlot == 0 )
line( [handles.timeVector(eventStartSamples), handles.timeVector(eventEndSamples)], [avgAmplitude, avgAmplitude], 'LineStyle','--', 'Color', 'g','HitTest', 'off');
% line( [handles.timeVector(eventStartSamples+timingInfo(i,8)), handles.timeVector(eventStartSamples+timingInfo(i,8))], [avgAmplitude-5, avgAmplitude+5], 'LineStyle','--', 'Color', 'c','HitTest', 'off');
else
%plot event on event plot
hold on;
if( timingInfo(i,5) )
%plot cutoff event red
semilogx( eventDwellTime*1000, avgAmplitude, 'r.' );
else
%get appropriate color based on DNA molecule number
% if( timingInfo(i,6) ~= handles.oldDNAnumber && handles.fishingFile == 1 )
% %new DNA molecule, change color
% handles.lastMoleculeColor = handles.currentMoleculeColor;
% handles.currentMoleculeColor = [ rand, rand, rand ];
% else
% %color regular events blue
% handles.currentMoleculeColor = [ 0, 0, 1 ];
% end
%color events by min amplitude
if(timingInfo(i,9) < -20)
handles.currentMoleculeColor = [0,1,0];
else
handles.currentMoleculeColor = [1,1,0];
end
%save "old" DNA molecule number
handles.oldDNAnumber = timingInfo(i,6);
if( (timingInfo(i,7) == 3 ) && (handles.fishingFile == 1) )
semilogx( eventDwellTime*1000, avgAmplitude, '.', 'Color', handles.currentMoleculeColor );
% if( timingInfo(i,6) > 0 )
% timingInfo(i,6) = timingInfo(i,6) - 1;
% end
else
semilogx( eventDwellTime*1000, avgAmplitude, 's', 'Color', handles.currentMoleculeColor );
end
end
end
handles.detectedEvents = [handles.detectedEvents; handles.currentSweep, timingInfo(i,1), timingInfo(i,2), timingInfo(i,3), timingInfo(i,4), timingInfo(i,5), timingInfo(i,6), timingInfo(i,7), timingInfo(i,8), handles.currentFileIndex, timingInfo(i,9)];
handles.detectedEvents_ms = [handles.detectedEvents_ms; handles.currentSweep, eventStart*1000, eventEnd*1000, eventDwellTime*1000, avgAmplitude, timingInfo(i,3), timingInfo(i,4), timingInfo(i,5), timingInfo(i,6), timingInfo(i,7), timingInfo(i,8), handles.currentFileIndex];
handles.detectedEventsVoltages = [handles.detectedEventsVoltages; eventVoltageTimingPrimer(i,:)];
else %events have been found, just bplot saved amplitude
if( showEventPlot == 0 )
%plot saved avg amplitude for each event
line( [handles.timeVector(eventStartSamples), handles.timeVector(eventEndSamples)], [handles.detectedEvents_ms( sweepEvents(i), 5), handles.detectedEvents_ms( sweepEvents(i), 5)], 'LineStyle','--', 'Color', 'g','HitTest', 'off');
% line( [handles.timeVector(eventStartSamples+timingInfo(i,8)), handles.timeVector(eventStartSamples+timingInfo(i,8))], [avgAmplitude-5, avgAmplitude+5], 'LineStyle','--', 'Color', 'c','HitTest', 'off');
else
%plot event on event plot
if( handles.detectedEvents(i,5) == handles.currentSweep && handles.detectedEvents(i,11) == handles.currentFileIndex)
if( handles.detectedEvents_ms(i,7) )
%plot cutoff event red
semilogx( eventDwellTime*1000, handles.detectedEvents_ms( sweepEvents(i), 5), 'r.' );
else
%get appropriate color based on DNA molecule number
if( timingInfo(i,6) ~= handles.oldDNAnumber )
%new DNA molecule, change color
handles.currentMoleculeColor = [ rand, rand, rand ];
end
%save "old" DNA molecule number
handles.oldDNAnumber = timingInfo(i,6);