-
Notifications
You must be signed in to change notification settings - Fork 5
/
mStat.m
1203 lines (960 loc) · 43.3 KB
/
mStat.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
%-----------------MEANDER STATISTICS TOOLBOX. MStaT------------------------
%
% Meander Statistics Toolbox (MStaT), is a packaging of codes developed on
% MATLAB, which allows the quantification of parameters dexscriptors of
% meandering channels (sinuosity, arc-wavelength, amplitude, curvature,
% inflection point, among other). To obtain all the meander parameters
% MStaT uses the function of wavelet transform to decompose the signail
% (centerline). The toolbox obtains the Wavelet Spectrum, Curvature and
% Angle Variation and the Global Wavelet Spectrum. The input data to use
% MStaT is the Centerline (in a Coordinate System) and the average Width of
% the study Channels. MStaT can analize a large number of bends in a short
% calculation time. Also MStaT allows calculate the migration of a period,
% and analyzes the migration signature. Finally MStaT has a Confluence
% Module that allow calculate the influence due the presence of the
% tributary channel on the main channel.
%% Collaborations
% Lucas Dominguez. UNL, Argentina
% Kensuke Naito. UTEC, Peru
% Jorge Abad. UTEC, Peru
% Ronald Gutierrez. Universidad Pontificia de Peru
%
% Citation: (In progress)
% Meander Statistics Toolbox (MStaT): A Toolbox for Geometry
% Characterization of Bends in Large Meandering Channels
% Dominguez Ruben, L., Naito, K., Gutierrez, R. R., Szupiany, R.
% and Abad, J. D.
%--------------------------------------------------------------------------
% Begin initialization code - DO NOT EDIT.
function varargout = mStat(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mStat_OpeningFcn, ...
'gui_OutputFcn', @mStat_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% If ERROR, write a txt file with the error dump info
try
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
catch err
if isdeployed
errLogFileName = fullfile(pwd,...
['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
('Error details are being written to the following file: ');...
errLogFileName},...
'MStaT Status: Unexpected Error',...
'error');
fid = fopen(errLogFileName,'W');
fwrite(fid,err.getReport('extended','hyperlinks','off'));
fclose(fid);
rethrow(err)
else
close force
msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
'MStaT Status: Unexpected Error',...
'error');
rethrow(err);
end
end
%--------------------------------------------------------------------------
function mStat_OpeningFcn(hObject, eventdata, handles, varargin)
% This function executes just before mStat is made
% visible. This function has no output arguments (see OutputFcn),
% however, the following input arguments apply.
addpath utils
handles.output = hObject;
handles.mStat_version='v1.1';
% Set the name and version
set(handles.figure1,'Name',['Meander Statistics Toolbox (MStaT) ' handles.mStat_version], ...
'DockControls','off')
set_enable(handles,'init')
%%%%%%%%%
%scalebar
%%%%%%%%%
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%----------- ' datestr(now) ' ------------%'];...
'LETs START!!!'};
statusLogging(handles.LogWindow, log_text)
handles.start=1;
guidata(hObject, handles);% Updates handles structure.
%--------------------------------------------------------------------------
function varargout = mStat_OutputFcn(hObject, eventdata, handles)
% Output arguments from this function are returned to the command line.
% Input arguments from this function are defined as below.
%
varargout{1} = handles.output;
% --- Executes when figure1 is resized.
function figure1_ResizeFcn(hObject, eventdata, handles)
pos = get(handles.mStatBackground,'position');
axes(handles.mStatBackground);
% if ~isdeployed
X = imread('MStaT_background.png');
imdisp(X,'size',[pos(4) pos(3)]) % Avoids problems with users not having Image Processing TB
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% Hint: delete(hObject) closes the figure
who_called = get(hObject,'tag');
close_button = questdlg(...
'You are about to exit MStaT. Any unsaved work will be lost. Are you sure?',...
'Exit MStaT?','No');
switch close_button
case 'Yes'
delete(hObject)
close all hidden
otherwise
return
end
%--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%
%MENU PANEL
%%%%%%%%%%%%%%%%
% -------------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
%Empty
% -------------------------------------------------------------------------
function newproject_Callback(hObject, eventdata, handles)
%New project function
axes(handles.pictureReach)
cla(handles.pictureReach,'reset')
set(gca,'xtick',[])
set(gca,'ytick',[])
clear geovar
clc
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'NEW PROJECT!'};
statusLogging(handles.LogWindow, log_text)
set_enable(handles,'init')
% -------------------------------------------------------------------------
function openfunction_Callback(hObject, eventdata, handles)
%open function
set_enable(handles,'init')
handles.Module = 1;
%This function incorporate the initial data input
handles.multisel='on';
handles.first=1;
guidata(hObject,handles)
mStat_ReadInputFiles(handles);
% --------------------------------------------------------------------
function singlefile_Callback(hObject, eventdata, handles)
%empty
% --------------------------------------------------------------------
function multifiles_Callback(hObject, eventdata, handles)
%empty
% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
close
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Export function
% --------------------------------------------------------------------
function exportfunction_Callback(hObject, eventdata, handles)
%Empty
%Matlab Export
% --------------------------------------------------------------------
function exportmat_Callback(hObject, eventdata, handles)
saveDataCallback(hObject, eventdata, handles)
function saveDataCallback(hObject, eventdata, handles)
[fileMAT,pathMAT] = uiputfile('*.mat','Save .mat file');
if fileMAT==0
else
str=['Exporting' fileMAT];
hwait = waitbar(0,str,'Name','MStaT');
Parameters.PathFileName = fullfile(pathMAT,fileMAT);
Parameters.geovar = getappdata(0,'geovar');
waitbar(0.5,hwait)
save([pathMAT fileMAT], 'Parameters');
waitbar(1,hwait)
delete(hwait)
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Export .mat File Succesfully!'};
statusLogging(handles.LogWindow, log_text)
end
%Excel Export
% --------------------------------------------------------------------
function exportexcelfile_Callback(hObject, eventdata, handles)
savexlsDataCallback(hObject, eventdata, handles)
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Export .xlsx File succesfully!'};
statusLogging(handles.LogWindow, log_text)
function savexlsDataCallback(hObject, eventdata, handles)
%Read data
geovar = getappdata(0,'geovar');
close_button = questdlg(...
'Do you like export all channel analyzed?', 'MStaT: Export Excel Data',...
'All Data','Only Selected');
switch close_button
case 'All Data'
for i=1:length(geovar)
mStat_ExportExcel(geovar{i})
end
case 'Only Selected'
mStat_ExportExcel(geovar{handles.ChannelSel})
end
%Google Export
% --------------------------------------------------------------------
function exportkmlfile_Callback(hObject, eventdata, handles)
geovar = getappdata(0,'geovar');
ReadVar = getappdata(0,'ReadVar');
%This function esport the kmzfile for Google Earth
[file,path] = uiputfile('*.kml','Save .kml File');
if file==0
else
str=['Exporting' file];
hwait = waitbar(0,str,'Name','MStaT');
namekml=(fullfile(path,file));
% 3 file export function
%first
[xcoord,ycoord]=utm2deg(ReadVar{handles.ChannelSel}.xCoord,...
ReadVar{handles.ChannelSel}.yCoord,char(ReadVar{handles.ChannelSel}.utmzone(:,1:4)));
latlon1=[xcoord ycoord];
%second
for i=1:length(geovar{handles.ChannelSel}.xValleyCenter)
utmzoneva(i,1)=cellstr(ReadVar{handles.ChannelSel}.utmzone(1,1:4));
end
utmva=char(utmzoneva);
waitbar(0.5,hwait)
[xvalley,yvalley]=utm2deg(geovar{handles.ChannelSel}.xValleyCenter,...
geovar{handles.ChannelSel}.yValleyCenter,char(utmzoneva));
latlon2=[xvalley yvalley];
%third
for i=1:length(geovar{handles.ChannelSel}.inflectionX)
utmzoneinf(i,1)=cellstr(ReadVar{handles.ChannelSel}.utmzone(1,1:4));
end
[xinflectionY,yinflectionY]=utm2deg(geovar{handles.ChannelSel}.inflectionX,...
geovar{handles.ChannelSel}.inflectionY,char(utmzoneinf));
latlon3=[xinflectionY yinflectionY];
% Write latitude and longitude into a KML file
mStat_ExportKml(namekml,latlon1,latlon2,latlon3);
waitbar(1,hwait)
delete(hwait)
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Export .kml File succesfully!'};
statusLogging(handles.LogWindow, log_text)
end
%Export Figures
% --------------------------------------------------------------------
function exportfiguregraphics_Callback(hObject, eventdata, handles)
%export figure function
[file,path] = uiputfile('*.tif','Save .tif File');
if file==0
else
F = getframe(handles.pictureReach);
Image = frame2im(F);
imwrite(Image, fullfile(path,file),'Resolution',[1080,960])
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Export .tif File succesfully!'};
statusLogging(handles.LogWindow, log_text)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%
%Tools
%%%%%%%%%%
% --------------------------------------------------------------------
function tools_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function evaldecomp_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function waveletanalysis_Callback(hObject, eventdata, handles)
%Wavelet analysis
geovar=getappdata(0,'geovar');
handles.getWaveStats = mStat_WaveletAnalysis(geovar{handles.ChannelSel});
% --------------------------------------------------------------------
function riverstatistics_Callback(hObject, eventdata, handles)
% This function executes when the user presses the getRiverStats button
% and requires the following input arguments.
geovar=getappdata(0,'geovar');
handles.getRiverStats = mStat_StatisticsVariables(geovar{handles.ChannelSel});
% --------------------------------------------------------------------
function backgroundimage_Callback(hObject, eventdata, handles)
% Add backgroud image
[handles.FileImage,handles.PathImage] = uigetfile({'*.tif';'*.*'},'Select Graphic File');
guidata(hObject,handles)
if handles.FileImage==0
else
axes(handles.pictureReach);
hold on;
mapshow(fullfile(handles.PathImage,handles.FileImage))
hold on;
geovar=getappdata(0, 'geovar');
sel=get(handles.selector,'Value')-1;%Decomposition method
%Begin plot
mStat_plotplanar(geovar{handles.ChannelSel}.equallySpacedX, geovar{handles.ChannelSel}.equallySpacedY,...
geovar{handles.ChannelSel}.inflectionPts, geovar{handles.ChannelSel}.x0,...
geovar{handles.ChannelSel}.y0, geovar{handles.ChannelSel}.x_sim,...
geovar{handles.ChannelSel}.newMaxCurvX, geovar{handles.ChannelSel}.newMaxCurvY,...
handles.pictureReach,sel);
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'Background Image read succesfully!'};
statusLogging(handles.LogWindow, log_text)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%
%Modules
%%%%%%%%%%
% --------------------------------------------------------------------
function modules_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
% --------------------------------------------------------------------
function migrationanalyzer_Callback(hObject, eventdata, handles)
%Migration Analyzer Tool
mStat_MigrationAnalyzer;
% --------------------------------------------------------------------
function confluencesanalyzer_Callback(hObject, eventdata, handles)
%Confluences and Bifurcation Tools
mStat_ConfluencesAnalyzer;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
%Settings
%%%%%%%%%%%%%%
% --------------------------------------------------------------------
function setti_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
% function unitsfunction_Callback(hObject, eventdata, handles)
% % Empty
%
%
% % --------------------------------------------------------------------
% function metricunits_Callback(hObject, eventdata, handles)
% % Metric factor function
% if handles.start==0
% munits=1/0.3048;
% else
% munits=1;
% end
% handles.geovar.lengthCurved=handles.geovar.lengthCurved*munits;
% handles.geovar.wavelengthOfBends=handles.geovar.wavelengthOfBends*munits;
% handles.geovar.amplitudeOfBends=handles.geovar.amplitudeOfBends*munits;
% handles.geovar.downstreamSlength=handles.geovar.downstreamSlength*munits;
% handles.geovar.upstreamSlength=handles.geovar.upstreamSlength*munits;
% handles.width=handles.width*munits;
% guidata(hObject,handles)
%
% set(handles.widthinput,'String',handles.width)
%
% % Retrieve the selected bend ID number from the "bendSelect" listbox.
% selectedBend = get(handles.bendSelect,'Value');
%
% % -------------------------------------------------------------------------
%
% % Assign the bend statistics to an output array.
% matrixOfBendStatistics = [handles.geovar.sinuosityOfBends(selectedBend),...
% handles.geovar.lengthStraight(selectedBend),handles.geovar.lengthCurved(selectedBend),...
% handles.geovar.wavelengthOfBends(selectedBend), handles.geovar.amplitudeOfBends(selectedBend),...
% handles.geovar.downstreamSlength(selectedBend),handles.geovar.upstreamSlength(selectedBend)];
%
% matrixOfBendStatistics = matrixOfBendStatistics';
%
% % Setappdata is a function which allows the matrix of bend statistics
% % to be accessed by multiple GUI windows.
% setappdata(0, 'matrixOfBendStatistics', matrixOfBendStatistics);
% guidata(hObject, handles);
%
% % Set the statistics to the "IndividualStats" table in
% % the main GUI.
% set(handles.sinuosity, 'String', round(handles.geovar.sinuosityOfBends(selectedBend),2));
% set(handles.curvaturel, 'String', round(handles.geovar.lengthCurved(selectedBend),2));
% set(handles.wavel, 'String', round(handles.geovar.wavelengthOfBends(selectedBend),2));
% set(handles.amplitude, 'String', round(handles.geovar.amplitudeOfBends(selectedBend),2));
% set(handles.dstreamL, 'String', round(handles.geovar.downstreamSlength(selectedBend),2));
% set(handles.ustreamL, 'String', round(handles.geovar.upstreamSlength(selectedBend),2));
% handles.munits=1;
% guidata(hObject, handles);
%
%
% % --------------------------------------------------------------------
% function englishunits_Callback(hObject, eventdata, handles)
% % English units
%
% eunits=0.3048;
%
% handles.geovar.lengthCurved=handles.geovar.lengthCurved*eunits;
% handles.geovar.wavelengthOfBends=handles.geovar.wavelengthOfBends*eunits;
% handles.geovar.amplitudeOfBends=handles.geovar.amplitudeOfBends*eunits;
% handles.geovar.downstreamSlength=handles.geovar.downstreamSlength*eunits;
% handles.geovar.upstreamSlength=handles.geovar.upstreamSlength*eunits;
% handles.width=handles.width*eunits;
% guidata(hObject,handles)
%
% set(handles.widthinput,'String',handles.width)
%
% % Retrieve the selected bend ID number from the "bendSelect" listbox.
% selectedBend = get(handles.bendSelect,'Value');
%
% % -------------------------------------------------------------------------
%
% % Assign the bend statistics to an output array.
% matrixOfBendStatistics = [handles.geovar.sinuosityOfBends(selectedBend),...
% handles.geovar.lengthStraight(selectedBend),handles.geovar.lengthCurved(selectedBend),...
% handles.geovar.wavelengthOfBends(selectedBend), handles.geovar.amplitudeOfBends(selectedBend),...
% handles.geovar.downstreamSlength(selectedBend),handles.geovar.upstreamSlength(selectedBend)];
%
% matrixOfBendStatistics = matrixOfBendStatistics';
%
% % Setappdata is a function which allows the matrix of bend statistics
% % to be accessed by multiple GUI windows.
% setappdata(0, 'matrixOfBendStatistics', matrixOfBendStatistics);
% guidata(hObject, handles);
%
% % Set the statistics to the "IndividualStats" table in
% % the main GUI.
% set(handles.sinuosity, 'String', round(handles.geovar.sinuosityOfBends(selectedBend),2));
% set(handles.curvaturel, 'String', round(handles.geovar.lengthCurved(selectedBend),2));
% set(handles.wavel, 'String', round(handles.geovar.wavelengthOfBends(selectedBend),2));
% set(handles.amplitude, 'String', round(handles.geovar.amplitudeOfBends(selectedBend),2));
% set(handles.dstreamL, 'String',round(handles.geovar.downstreamSlength(selectedBend),2));
% set(handles.ustreamL, 'String', round(handles.geovar.upstreamSlength(selectedBend),2));
% handles.eunits=0.3048;
% guidata(hObject, handles);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Help
% --------------------------------------------------------------------
function helpfunction_Callback(hObject, eventdata, handles)
% Empty
% --------------------------------------------------------------------
function usersguide_Callback(hObject, eventdata, handles)
%Send to web page with code modufy to github
try
web('https://meanderstatistics.blogspot.com/p/tutorials.html')
catch err %#ok<NASGU>
if isdeployed
errLogFileName = fullfile(pwd,...
['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
['Error details are being written to the following file: '];...
errLogFileName},...
'MStaT Status: Unexpected Error',...
'error');
fid = fopen(errLogFileName,'W');
fwrite(fid,err.getReport('extended','hyperlinks','off'));
fclose(fid);
rethrow(err)
else
msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
'MStaT Status: Unexpected Error',...
'error');
rethrow(err);
end
end
% --------------------------------------------------------------------
function checkforupdates_Callback(hObject, eventdata, handles)
%Send to web page for updates
try
web('https://meanderstatistics.blogspot.com/p/download.html')
catch err %#ok<NASGU>
if isdeployed
errLogFileName = fullfile(pwd,...
['errorLog' datestr(now,'yyyymmddHHMMSS') '.txt']);
msgbox({['An unexpected error occurred. Error code: ' err.identifier];...
['Error details are being written to the following file: '];...
errLogFileName},...
'MStaT Status: Unexpected Error',...
'error');
fid = fopen(errLogFileName,'W');
fwrite(fid,err.getReport('extended','hyperlinks','off'));
fclose(fid);
rethrow(err)
else
msgbox(['An unexpected error occurred. Error code: ' err.identifier],...
'MStaT Status: Unexpected Error',...
'error');
rethrow(err);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%
%MENU TOOLBAR
%%%%%%%%%%%%%%%%%%
% --------------------------------------------------------------------
function zoomextendedT_ClickedCallback(hObject, eventdata, handles)
geovar=getappdata(0, 'geovar');
sel=get(handles.selector,'Value')-1;%Decomposition method
%Begin plot
axes(handles.pictureReach)
cla(handles.pictureReach)
mStat_plotplanar(geovar{handles.ChannelSel}.equallySpacedX, geovar{handles.ChannelSel}.equallySpacedY,...
geovar{handles.ChannelSel}.inflectionPts, geovar{handles.ChannelSel}.x0,...
geovar{handles.ChannelSel}.y0, geovar{handles.ChannelSel}.x_sim,...
geovar{handles.ChannelSel}.newMaxCurvX, geovar{handles.ChannelSel}.newMaxCurvY,...
handles.pictureReach,sel);
% --------------------------------------------------------------------
function panT_OnCallback(hObject, eventdata, handles)
axes(handles.pictureReach)
scalebar OFF
% --------------------------------------------------------------------
function panT_OffCallback(hObject, eventdata, handles)
axes(handles.pictureReach)
scalebar
% --------------------------------------------------------------------
function panT_ClickedCallback(hObject, eventdata, handles)
pan
% --------------------------------------------------------------------
function rulerT_ClickedCallback(hObject, eventdata, handles)
%empty
% --------------------------------------------------------------------
function newprojectT_ClickedCallback(hObject, eventdata, handles)
newproject_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function savematfileT_ClickedCallback(hObject, eventdata, handles)
exportmat_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function openT_ClickedCallback(hObject, eventdata, handles)
openfunction_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function rulerT_OnCallback(hObject, eventdata, handles)
axes(handles.pictureReach)
%imdistline(hparent)
axis manual
handles.Figruler = imline(gca);
% Get original position
pos = getPosition(handles.Figruler);
% Get updated position as the ruler is moved around
id = addNewPositionCallback(handles.Figruler,@(pos) title(mat2str(pos,3)));
x=pos(:,1);
y=pos(:,2);
handles.ruler=imdistline(handles.pictureReach,x,y);
guidata(hObject,handles)
% --------------------------------------------------------------------
function rulerT_OffCallback(hObject, eventdata, handles)
delete(handles.ruler)
delete(handles.Figruler)
% --------------------------------------------------------------------
function datacursorT_OnCallback(hObject, eventdata, handles)
axes(handles.pictureReach);
%data cursor type
dcm_obj = datacursormode(gcf);
set(dcm_obj,'UpdateFcn',@mStat_myupdatefcn);
set(dcm_obj,'Displaystyle','Window','Enable','on');
pos = get(0,'userdata');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
%Initial Panel
%%%%%%%%%%%%%%%%%%%
% --- Executes during object creation, after setting all properties.
function popupChannel_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupChannel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on key press with focus on popupChannel and none of its controls.
function popupChannel_KeyPressFcn(hObject, eventdata, handles)
%empty
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over popupChannel.
function popupChannel_ButtonDownFcn(hObject, eventdata, handles)
%empty
% --- Executes on button press in advancedsetting.
function advancedsetting_Callback(hObject, eventdata, handles)
mStat_AdvancedSetting(handles.ChannelSel)
% --- Executes on button press in recalculate.
function recalculate_Callback(hObject, eventdata, handles)
%Recalculate using a New Width
% clear figures and data
axes(handles.pictureReach)
cla(handles.pictureReach)
clear selectBend
clc
guidata(hObject,handles)
mStat_Calculate(handles)
set_enable(handles,'results')
% --- Executes on selection change in popupChannel.
function popupChannel_Callback(hObject, eventdata, handles)
handles.ChannelSel=get(handles.popupChannel,'Value')-1;
guidata(hObject, handles);
sel=get(handles.selector,'Value')-1;%Decomposition method
geovar=getappdata(0, 'geovar');
if handles.ChannelSel==0
% set_enable(handles,'init')
else
set_enable(handles,'loadfiles')
% %put the bend on the table
bendListStr = geovar{handles.ChannelSel}.bendID1';
set (handles.bendSelect, 'string', bendListStr);
% Write the width
%set(handles.widthinput, 'String', ReadVar{handles.ChannelSel}.width,'Enable','on');
% Retrieve the selected bend ID number from the "bendSelect" listbox.
selectedBend = get(handles.bendSelect,'Value');
handles.selectedBend = num2str(selectedBend);
% setappdata is a function which allows the selected bend
% to be accessed by multiple GUI windows.
setappdata(0, 'selectedBend', handles.selectedBend);
guidata(hObject, handles);
% Start by retreiving the selected bend given the user input from the
% "bendSelect" listbox.
handles.selectedBend = getappdata(0, 'selectedBend');
handles.selectedBend = str2double(handles.selectedBend);
guidata(hObject, handles);
%Begin plot
axes(handles.pictureReach)
cla(handles.pictureReach)
mStat_plotplanar(geovar{handles.ChannelSel}.equallySpacedX, geovar{handles.ChannelSel}.equallySpacedY,...
geovar{handles.ChannelSel}.inflectionPts, geovar{handles.ChannelSel}.x0,...
geovar{handles.ChannelSel}.y0, geovar{handles.ChannelSel}.x_sim,...
geovar{handles.ChannelSel}.newMaxCurvX, geovar{handles.ChannelSel}.newMaxCurvY,...
handles.pictureReach,sel);
% enable results
set_enable(handles,'results')
% Push messages to Log Window:
% ----------------------------
log_text = {...
'';...
['%--- ' datestr(now) ' ---%'];...
'MStaT Summary';...
'Width [m]:';[cell2mat({geovar{handles.ChannelSel}.width(end,1)})];...
'Total Length Analyzed [km]:';[round(cell2mat({geovar{handles.ChannelSel}.intS(end,1)/1000}),2)];...
'Bends Found:';[cell2mat({geovar{handles.ChannelSel}.nBends})];...
'Mean Sinuosity:';[round(cell2mat({nanmean(geovar{handles.ChannelSel}.sinuosityOfBends)}),2)];...
'Mean Amplitude [m]:';[round(cell2mat({nanmean(geovar{handles.ChannelSel}.amplitudeOfBends)}),2)];...
'Mean Arc-Wavelength [m]:';[round(cell2mat({nanmean(geovar{handles.ChannelSel}.lengthCurved)}),2)];...
'Mean Wavelength [m]:';[round(cell2mat({nanmean(geovar{handles.ChannelSel}.wavelengthOfBends)}),2)]};
statusLogging(handles.LogWindow, log_text)
end
% --------------------------------------------------------------------
function bendstatistics_Callback(hObject, eventdata, handles)
% empty
% --- Executes on button press in selectData.
function selectData_Callback(hObject, eventdata, handles)
%Empty
function bendSelect_Callback(hObject, eventdata, handles)
% This function executes when the user presses the Get Bend Statistics
% button and requires the following input arguments.
geovar=getappdata(0, 'geovar');
%cla(handles.pictureReach)
guidata(hObject,handles)
% Retrieve the selected bend ID number from the "bendSelect" listbox.
selectedBend = get(handles.bendSelect,'Value');
% setappdata is a function which allows the handles.Channeled bend
% to be accessed by multiple GUI windows.
setappdata(0, 'selectedBend', handles.selectedBend);
guidata(hObject, handles);
% Start by retreiving the selected bend given the user input from the
% "bendSelect" listbox.
handles.selectedBend = getappdata(0, 'selectedBend');
handles.selectedBend = str2double(handles.selectedBend);
guidata(hObject, handles);
% -------------------------------------------------------------------------
% Assign the bend statistics to an output array.
matrixOfBendStatistics = [geovar{handles.ChannelSel}.sinuosityOfBends(selectedBend),...
geovar{handles.ChannelSel}.lengthStraight(selectedBend),geovar{handles.ChannelSel}.lengthCurved(selectedBend),...
geovar{handles.ChannelSel}.wavelengthOfBends(selectedBend), geovar{handles.ChannelSel}.amplitudeOfBends(selectedBend),...
geovar{handles.ChannelSel}.downstreamSlength(selectedBend),geovar{handles.ChannelSel}.upstreamSlength(selectedBend)];
matrixOfBendStatistics = matrixOfBendStatistics';
% Setappdata is a function which allows the matrix of bend statistics
% to be accessed by multiple GUI windows.
setappdata(0, 'matrixOfBendStatistics', matrixOfBendStatistics);
guidata(hObject, handles);
% Set the statistics to the "IndividualStats" table in
% the main GUI.
set(handles.sinuosity, 'String', round(geovar{handles.ChannelSel}.sinuosityOfBends(selectedBend),2));
set(handles.curvaturel, 'String', round(geovar{handles.ChannelSel}.lengthCurved(selectedBend),2));
set(handles.wavel, 'String', round(geovar{handles.ChannelSel}.wavelengthOfBends(selectedBend),2));
set(handles.amplitude, 'String', round(geovar{handles.ChannelSel}.amplitudeOfBends(selectedBend),2));
set(handles.dstreamL, 'String',round(geovar{handles.ChannelSel}.downstreamSlength(selectedBend),2));
set(handles.ustreamL, 'String', round(geovar{handles.ChannelSel}.upstreamSlength(selectedBend),2));
set(handles.condition, 'String', geovar{handles.ChannelSel}.condition(selectedBend));
guidata(hObject, handles);
uiresume(gcbf);
%--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Panel Selection
% --- Executes during object creation, after setting all properties.
function uipanelselect_CreateFcn(hObject, eventdata, handles)
%Empty
function bendSelect_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), ...
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%--------------------------------------------------------------------------
function selectData_CreateFcn(hObject, eventdata, handles)
set(hObject,'enable','off')
% --- Executes on selection change in selector.
function selector_Callback(hObject, eventdata, handles)
%This function select the bend and shows the parameters results
axes(handles.pictureReach)
cla(handles.pictureReach)
guidata(hObject,handles)
mStat_Calculate(handles)
% --- Executes during object creation, after setting all properties.
function selector_CreateFcn(hObject, eventdata, handles)
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
%--------------------------------------------------------------------------
% --- Executes on button press in gobend.
function gobend_Callback(hObject, eventdata, handles)
%This function go to bend selected and replot the picture
geovar=getappdata(0, 'geovar');
sel=get(handles.selector,'Value')-1;%Decomposition method
cla(handles.pictureReach)
mStat_plotplanar(geovar{handles.ChannelSel}.equallySpacedX, geovar{handles.ChannelSel}.equallySpacedY,...
geovar{handles.ChannelSel}.inflectionPts,geovar{handles.ChannelSel}.x0,...
geovar{handles.ChannelSel}.y0, geovar{handles.ChannelSel}.x_sim,...
geovar{handles.ChannelSel}.newMaxCurvX, geovar{handles.ChannelSel}.newMaxCurvY, ...
handles.pictureReach,sel);
zoom out
selectedBend = get(handles.bendSelect,'Value');
if geovar{handles.ChannelSel}.amplitudeOfBends(selectedBend)~=0 | isfinite(geovar{handles.ChannelSel}.upstreamSlength)
% selectdata text labels for all bends.
axes(handles.pictureReach);
set(gca, 'Color', 'w')
%axis normal;
loc = find(geovar{handles.ChannelSel}.newMaxCurvS == geovar{handles.ChannelSel}.bend(selectedBend,2));
zoom out
zoomcenter(geovar{handles.ChannelSel}.newMaxCurvX(loc),geovar{handles.ChannelSel}.newMaxCurvY(loc),2)
else
end
% Call the "userSelectBend" function to get the index of intersection
% points and the highlighted bend limits.
[handles.highlightX, handles.highlightY, ~] = userSelectBend(geovar{handles.ChannelSel}.intS, selectedBend,...
geovar{handles.ChannelSel}.equallySpacedX,geovar{handles.ChannelSel}.equallySpacedY,...
geovar{handles.ChannelSel}.newInflectionPts,geovar{handles.ChannelSel}.sResample);
axes(handles.pictureReach);
% hold on
handles.highlightPlot = line(handles.highlightX(1,:), handles.highlightY(1,:), 'color', 'y', 'LineWidth',8);
guidata(hObject,handles)
%--------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Planar Parameters Display
function sinuosity_Callback(hObject, eventdata, handles)
%Empty
% --- Executes during object creation, after setting all properties.
function sinuosity_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function curvaturel_Callback(hObject, eventdata, handles)
%Empty
% --- Executes during object creation, after setting all properties.
function curvaturel_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function wavel_Callback(hObject, eventdata, handles)
% Empty
% --- Executes during object creation, after setting all properties.
function wavel_CreateFcn(hObject, eventdata, handles)
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function amplitude_Callback(hObject, eventdata, handles)
% Empty
% --- Executes during object creation, after setting all properties.
function amplitude_CreateFcn(hObject, eventdata, handles)
% 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