-
Notifications
You must be signed in to change notification settings - Fork 5
/
Hyscorean.m
1497 lines (1348 loc) · 57.1 KB
/
Hyscorean.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 = Hyscorean(varargin)
%==========================================================================
% HYSCOREAN (HYSCORE ANALYSIS) - GUI CALLBACKS
%==========================================================================
% This function is responsible for the generation and execution of the
% fitting module of Hyscorean. This module employs EasySpin for fitting the
% spectra processed via Hyscorean. This function allows the fitting of
% several HYSCORE spectra at the same time e.g. at different field
% positions. The spectra are simulated via the saffron function and then
% processed by the same functions employed by Hyscorean during the
% processing.
% (See the Hyscorean manual for further details)
%==========================================================================
%
% Copyright (C) 2019 Luis Fabregas, Hyscorean 2019
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License 3.0 as published by
% the Free Software Foundation.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <https://www.gnu.org/licenses/>.
%==========================================================================
%Check that the license has been accepted, otherwise kill the startup
if ispref('hyscorean','LGPL_license')
if ~getpref('hyscorean','LGPL_license')
w = warndlg('Hyscorean''s GNU LGPL 3.0 license agreement not accepted. Please run setup_hyscorean again and accept the license agreemen.','Warning','modal');
waitfor(w)
return
end
else
w = warndlg('Hyscorean''s GNU LGPL 3.0 license agreement not found. Please run setup_hyscorean again and accept the license agreemen.','Warning','modal');
waitfor(w)
return
end
GraphicalSettings = getpref('hyscorean','graphicalsettings');
if ~isfield(GraphicalSettings,'ColormapName')
GraphicalSettings.ColormapName = 'parula';
setpref('hyscorean','graphicalsettings',GraphicalSettings);
end
%GUIDE-specific startup code
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Hyscorean_OpeningFcn, ...
'gui_OutputFcn', @Hyscorean_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
%==========================================================================
%==========================================================================
function Hyscorean_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
warning('off','all')
Path = fileparts(which('Hyscorean'));
jFrame=get(hObject,'javaframe');
jicon=javax.swing.ImageIcon(fullfile(Path, 'bin', 'logo.png'));
jFrame.setFigureIcon(jicon);
handles.output = hObject;
warning('on','all')
guidata(hObject, handles);
%==========================================================================
%==========================================================================
function varargout = Hyscorean_OutputFcn(hObject, eventdata, handles)
%Plot auxiliary lines on the main display
plot(handles.mainPlot,-50:1:50,abs(-50:1:50),'k-.'),grid(handles.mainPlot,'on')
hold(handles.mainPlot,'on')
plot(handles.mainPlot,zeros(length(0:50),1),abs(0:50),'k-')
hold(handles.mainPlot,'off')
set(handles.mainPlot,'xticklabel',[],'yticklabel',[])
%Load and set the Hyscorean logo
axes(handles.Icon)
Path = fileparts(which('Hyscorean'));
[matlabImage,~,Alpha] = imread(fullfile(Path, 'bin', 'logo.png'));
image(matlabImage,'AlphaData',Alpha)
axis off
axis image
%Do not give the user acces to this handle
set(handles.Icon,'HandleVisibility','off')
%Get a dummy plot for the signal display
plot(handles.signal_t1,-50:1:50,abs(-50:0.5:0),'k-',-50:1:50,abs(0:0.5:50),'k-')
set(handles.signal_t1,'xticklabel',[],'yticklabel',[])
%Force rendering now
drawnow
varargout{1} = handles.output;
return
%==========================================================================
%==========================================================================
function resetPlots(handles)
%Reset main display plot as in the beginning
plot(handles.mainPlot,-50:1:50,abs(-50:1:50),'k-.'),grid(handles.mainPlot,'on')
hold(handles.mainPlot,'on')
plot(handles.mainPlot,zeros(length(0:50),1),abs(0:50),'k-')
hold(handles.mainPlot,'off')
set(handles.mainPlot,'xticklabel',[],'yticklabel',[])
%Reset signal plot as in the beginning
cla(handles.signal_t1,'reset')
set(handles.signal_t1,'xtick',[],'ytick',[])
hold(handles.mainPlot,'on')
plot(handles.signal_t1,-50:1:50,abs(-50:0.5:0),'k-',-50:1:50,abs(0:0.5:50),'k-')
set(handles.signal_t1,'xticklabel',[],'yticklabel',[])
return
%==========================================================================
%==========================================================================
function LoadButton_Callback(hObject, eventdata, handles)
%Inform the user that loading is under progress
set(handles.LoadedData, 'String', 'Loading...');drawnow;
%Ask the user to load the files via OS window
[handles.FileNames,handles.FilePaths,CancelFlag] = multiload_mod;
%If laoding canceled just break the function
if CancelFlag
set(handles.LoadedData,'String','Loading canceled');drawnow;
return;
else
set(handles.DisplayLoadedFiles,'enable','on')
end
%If data has been reloaded and there exists and old processed spectrum,
%remove all the associated data
if isfield(handles,'Processed')
handles = rmfield(handles,'Processed');
end
%Reset/Disable graphical handles so that no errors appear if called
set(handles.PreProcessedTrace,'visible','off')
set(handles.ImaginaryTrace,'visible','off')
set(handles.NonCorrectedTrace,'visible','off')
set(handles.PlotApodizationWindow,'visible','off')
set(handles.DetachSignalPlot,'visible','off')
set(handles.ChangeSignalPlotDimension,'visible','off')
set(handles.t1_Slider,'enable','off')
set(handles.ImposeBlindSpots,'enable','off')
set(handles.EasyspinFitButton,'enable','off')
set(handles.AddHelpLine,'enable','off')
set(handles.TransititonType,'enable','off')
set(handles.Validation_Button,'enable','off')
set(handles.AddTagList,'enable','off')
set(handles.ClearTags,'enable','off')
set(handles.FieldOffsetTag,'enable','off')
set(handles.GPS_button,'visible','off')
set(handles.ZoomButton,'visible','off')
set(handles.ZoomOutButton,'visible','off')
set(handles.ProcessButton,'enable','off')
set(handles.SaveReportButton,'enable','off')
set(handles.FieldOffset,'enable','off')
set(findall(handles.GraphicsPanel, '-property', 'enable'), 'enable', 'off')
set(handles.trace2Info,'string','')
handles.TauSelectionSwitch = true;
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
handles.MountDataSwitch = true;
set(handles.TauSelectionCheck,'visible','off')
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
set(handles.TauSelectionWaiting,'visible','off')
set(handles.BackgroundCorrectionWaiting,'visible','off')
enableDisableGUI(handles,'NUSReconstruction','off')
drawnow
%Inform the user of how many files have been loaded
set(handles.LoadedData, 'String', sprintf('%d File(s) Loaded',length(handles.FileNames)));drawnow;
%Reset all plots to its startup form and inform
resetPlots(handles);
%Remove handles of auxiliary tags and lines if exist
if isfield(handles,'AddedLines')
handles = rmfield(handles,'AddedLines');
end
if isfield(handles,'AddedTags')
handles = rmfield(handles,'AddedTags');
end
%Mount the data
try
handles.Data = mountHYSCOREdata(handles.FileNames,handles);
catch Error
%If something fails then inform the user and return
f = errordlg(sprintf('Loading failed due to errors: \n\n %s ',Error.message),'Error','modal');
set(handles.LoadedData, 'String', 'Loading failed');drawnow;
set(handles.ProcessingInfo, 'String', 'Status: Loading failed');drawnow
waitfor(f)
return
end
%Get the tau values found during the mounting
TauValues = handles.Data.TauValues;
%Get all possible combinations
[handles.Selections,handles.Data.Combinations] = getTauCombinations(TauValues);
%Set the combination to the corresponding UI element
set(handles.MultiTauDimensions,'enable','on');
set(handles.MultiTauDimensions,'Value',1)
set(handles.MultiTauDimensions,'String',handles.Selections);
%Set Freq. Axis Limit
XUpperLimit_dt = handles.Data.TimeStep1;
if XUpperLimit_dt ~= 0
XUpperLimit = round(1/(2*XUpperLimit_dt)/10)*10;
set(handles.XUpperLimit,'String',num2str(XUpperLimit));
end
%Set the edit boxes depending on the signal size to the corresponding value
set(handles.ZeroFilling1,'String',size(handles.Data.TauSignals,2));
set(handles.ZeroFilling2,'String',size(handles.Data.TauSignals,3));
set(handles.ZeroFilling1_Text,'String',sprintf('t1: %i +',size(handles.Data.TauSignals,2)))
set(handles.ZeroFilling2_Text,'String',sprintf('t2: %i +',size(handles.Data.TauSignals,3)))
set(handles.WindowLength1,'String',size(handles.Data.TauSignals,2));
set(handles.WindowLength2,'String',size(handles.Data.TauSignals,3));
%Check if data is NUS and activate the panels in the GUI
if handles.Data.NUSflag
enableDisableGUI(handles,'NUSReconstruction','on')
end
%Enable the process button and inform the user
set(handles.ProcessButton,'enable','on')
set(handles.ProcessingInfo, 'String', 'Status: Ready');drawnow
% Save the handles structure.
guidata(hObject,handles)
return
%==========================================================================
%==========================================================================
function ProcessButton_Callback(hObject, eventdata, handles)
%Check if data is loaded (should always be like that just in case)
if ~isfield(handles,'Data')
set(handles.ProcessingInfo,'String','Error: No data loaded.')
return
end
%Launch the HYSCORE processing and update the GUI with the results
try
set(handles.ProcessingInfo, 'String', 'Status: Processing...');drawnow;
[handles] = processHYSCORE(handles);
[handles] = updateHyscoreanGUI(handles,handles.Processed);
catch Error
%Should some error occur inform the user and return
w = errordlg(sprintf('The processing stopped due to an error : \n %s \n Please check your input. If this error persists restart the program.',Error.message),'Error','modal');
waitfor(w);
set(handles.ProcessingInfo,'String','Ready')
return
end
%Enable the post-processing UI elements
set(handles.ImposeBlindSpots,'enable','on')
set(handles.AddHelpLine,'enable','on')
set(handles.TransititonType,'enable','on')
set(handles.AddTagList,'enable','on')
set(handles.ClearTags,'enable','on')
set(handles.FieldOffsetTag,'enable','on')
set(handles.FieldOffset,'enable','on')
set(handles.ZoomButton,'visible','on')
set(handles.GPS_button,'visible','on')
set(handles.ZoomOutButton,'visible','on')
set(handles.Validation_Button,'enable','on')
%Enable the Fitting module only if EasySpin is installed
if getpref('hyscorean','easyspin_installed')
set(handles.EasyspinFitButton,'enable','on')
end
set(findall(handles.GraphicsPanel, '-property', 'enable'), 'enable', 'on')
set(handles.SaveReportButton,'enable','on')
guidata(hObject, handles)
return
%==========================================================================
%==========================================================================
function t1_Slider_Callback(hObject, eventdata, handles)
handles.slider_t1=get(hObject,'Value');
Processed = handles.Processed;
handles.PlotProcessedSignal = true;
HyscoreanSignalPlot(handles,Processed)
guidata(hObject,handles)
return
%==========================================================================
%==========================================================================
function SaveReportButton_Callback(hObject, eventdata, handles)
%If there is data to be saved then launch the save and report protocol
if ~isfield(handles,'Processed')
Window = warndlg('There is no processed data to be saved','Warning');
return
end
saveHyscorean(handles);
return
%==========================================================================
%==========================================================================
function DisplayLoadedFiles_Callback(hObject, eventdata, handles)
%Display a list with all loaded files in the program
try
[handles.FileNames,handles.FilePaths,CancelFlag] = listLoadedFiles(handles.FileNames,handles.FilePaths);
if CancelFlag
%If data has been reloaded and there exists and old processed spectrum, remove all the associated data
if isfield(handles,'Processed')
handles = rmfield(handles,'Processed');
end
%Reset/Disable graphical handles so that no errors appear if called
set(handles.PreProcessedTrace,'visible','off')
set(handles.NonCorrectedTrace,'visible','off')
set(handles.PlotApodizationWindow,'visible','off')
set(handles.DetachSignalPlot,'visible','off')
set(handles.ChangeSignalPlotDimension,'visible','off')
set(handles.t1_Slider,'enable','off')
set(handles.ImposeBlindSpots,'enable','off')
set(handles.AddHelpLine,'enable','off')
set(handles.TransititonType,'enable','off')
set(handles.AddTagList,'enable','off')
set(handles.ClearTags,'enable','off')
set(handles.FieldOffsetTag,'enable','off')
set(handles.FieldOffset,'enable','off')
set(findall(handles.GraphicsPanel, '-property', 'enable'), 'enable', 'off')
set(handles.trace2Info,'string','')
handles.TauSelectionSwitch = true;
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
handles.MountDataSwitch = true;
set(handles.TauSelectionCheck,'visible','off')
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
set(handles.TauSelectionWaiting,'visible','off')
set(handles.BackgroundCorrectionWaiting,'visible','off')
enableDisableGUI(handles,'NUSReconstruction','off')
%Reset maind and signal plots to its startup state
resetPlots(handles);
%Force rendering of the GUI
drawnow
%Inform the user of the remaining files
set(handles.LoadedData, 'String', sprintf('%d File(s) Loaded',length(handles.FileNames)));drawnow;
%Mount data again and get tau values
handles.Data = mountHYSCOREdata(handles.FileNames,handles);
TauValues = handles.Data.TauValues;
%Get again combinations and set the corresponding UI element values
[handles.Selections,handles.Data.Combinations] = getTauCombinations(TauValues);
set(handles.MultiTauDimensions,'enable','on');
set(handles.MultiTauDimensions,'String',handles.Selections);
set(handles.ZeroFilling1,'String',2*size(handles.Data.TauSignals,2));
set(handles.ZeroFilling2,'String',2*size(handles.Data.TauSignals,3));
set(handles.WindowLength1,'String',size(handles.Data.TauSignals,2));
set(handles.WindowLength2,'String',size(handles.Data.TauSignals,3));
%Inform the user and return
set(handles.ProcessingInfo, 'String', 'Status: Ready'); drawnow;
end
catch
end
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function SaveSettingsButton_Callback(hObject, eventdata, handles)
saveSettings(handles)
return
%==========================================================================
%==========================================================================
function LoadSettings_Callback(hObject, eventdata, handles)
handles = loadSettingsHyscorean(handles);
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function NonCorrectedTrace_Callback(hObject, eventdata, handles)
handles.PlotProcessedSignal = true;
HyscoreanSignalPlot(handles,handles.Processed)
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function PreProcessedTrace_Callback(hObject, eventdata, handles)
handles.PlotProcessedSignal = true;
HyscoreanSignalPlot(handles,handles.Processed)
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function SaverSettings_Callback(hObject, eventdata, handles)
setappdata(0,'SaverSettings',handles.SaveHyscoreanSettings)
%Make the window appear relative to the Hyscorean window
Position = handles.HyscoreanFigure.Position;
ScreenSize = get(0,'ScreenSize');
Position(1) = Position(1)/ScreenSize(3) + 0.2;
Position(2) = Position(2)/ScreenSize(4) + 0.2;
Position(3) = 451.0/ScreenSize(3);
Position(4) = 177.0/ScreenSize(4);
%Call saver settings GUI
Hyscorean_saveSettings('Units','normalized','Position',Position)
uiwait(Hyscorean_saveSettings)
handles.SaveHyscoreanSettings = getappdata(0,'SaverSettings');
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function XUpperLimit_Callback(hObject, eventdata, handles)
[handles] = updateHyscoreanGUI(handles,handles.Processed)
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function InvertCorrection_Callback(hObject, eventdata, handles)
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function BackgroundMethod1_Callback(hObject, eventdata, handles)
switch get(hObject,'Value')
case 1
set(handles.BackgroundParameterText1,'String','')
set(handles.BackgroundParameter1,'visible','off')
case 2
set(handles.BackgroundParameterText1,'String','Fractal Dimension')
set(handles.BackgroundParameter1,'visible','on')
set(handles.BackgroundParameter1,'enable','on')
set(handles.BackgroundParameter1,'String','1')
case 3
set(handles.BackgroundParameterText1,'String','Polynomial Order')
set(handles.BackgroundParameter1,'String','1')
set(handles.BackgroundParameter1,'visible','on')
set(handles.BackgroundParameter1,'enable','on')
case 4
set(handles.BackgroundParameterText1,'String','Exponential Order')
set(handles.BackgroundParameter1,'enable','on')
set(handles.BackgroundParameter1,'visible','on')
set(handles.BackgroundParameter1,'String','1')
end
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function BackgroundMethod2_Callback(hObject, eventdata, handles)
switch get(hObject,'Value')
case 1
set(handles.BackgroundParameterText2,'String','')
set(handles.BackgroundParameter2,'visible','off')
case 2
set(handles.BackgroundParameterText2,'String','Fractal Dimension')
set(handles.BackgroundParameter2,'enable','on')
set(handles.BackgroundParameter2,'visible','on')
set(handles.BackgroundParameter2,'String','1')
case 3
set(handles.BackgroundParameterText2,'String','Polynomial Order')
set(handles.BackgroundParameter2,'String','1')
set(handles.BackgroundParameter2,'visible','on')
set(handles.BackgroundParameter2,'enable','on')
case 4
set(handles.BackgroundParameterText2,'String','Exponential Order')
set(handles.BackgroundParameter2,'enable','on')
set(handles.BackgroundParameter2,'visible','on')
set(handles.BackgroundParameter2,'String','1')
end
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function BackgroundParameter1_Callback(hObject, eventdata, handles)
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function BackgroundParameter2_Callback(hObject, eventdata, handles)
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function ReconstructionAlgorithm_Callback(hObject, eventdata, handles)
handles.ReconstructionSwitch = true;
set(handles.ReconstructionCheck,'visible','off')
switch get(hObject,'Value')
case 1
set(handles.MaxEntLagrangianMultiplier,'enable','on')
set(handles.LagrangeMultiplierText,'enable','on')
set(handles.BackgroundParameterText,'enable','on')
set(handles.MaxEntBackgroundParameter,'enable','on')
case {2,3,4}
set(handles.MaxEntLagrangianMultiplier,'enable','off')
set(handles.LagrangeMultiplierText,'enable','off')
set(handles.BackgroundParameterText,'enable','on')
set(handles.MaxEntBackgroundParameter,'enable','on')
otherwise
set(handles.MaxEntLagrangianMultiplier,'enable','off')
set(handles.LagrangeMultiplierText,'enable','off')
set(handles.BackgroundParameterText,'enable','off')
set(handles.MaxEntBackgroundParameter,'enable','off')
end
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function MaxEntBackgroundParameter_Callback(hObject, eventdata, handles)
handles.ReconstructionSwitch = true;
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function MaxEntLagrangianMultiplier_Callback(hObject, eventdata, handles)
handles.ReconstructionSwitch = true;
set(handles.ReconstructionCheck,'visible','off')
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function plotNUSgrid_Callback(hObject, eventdata, handles)
displayNUSreconstructionResults(handles)
return
%==========================================================================
%==========================================================================
function detachMainContour_Callback(hObject, eventdata, handles)
%Find figure, close it and open it again
Figure = findobj('Tag','mainContourDetached');
if isempty(Figure)
Figure = figure('Tag','mainContourDetached','WindowStyle','normal');
else
figure(Figure);
clf(Figure);
end
%Make the window appear relative to the Hyscorean window
ScreenSize = get(0,'ScreenSize');
Position = handles.HyscoreanFigure.Position;
Position(1) = Position(1)/ScreenSize(3)+0.1;
Position(2) = Position(2)/ScreenSize(4);
%Copy object as it is
AxesHandles = copyobj(handles.mainPlot,Figure);
GraphicalSettings = getpref('hyscorean','graphicalsettings');
set(Figure,'NumberTitle','off','Name','Hyscorean: HYSCORE spectrum',...
'Units','normalized','Position',[Position(1) Position(2) 776/ScreenSize(3) 415/ScreenSize(4)]);
set(AxesHandles,'Position',[0.07 0.12 0.9 0.85]);
colormap(AxesHandles,GraphicalSettings.ColormapName)
%Use Hyscorean window logo
warning('off','all')
Path = fileparts(which('Hyscorean'));
jFrame=get(Figure,'javaframe');
jicon=javax.swing.ImageIcon(fullfile(Path, 'bin', 'logo.png'));
jFrame.setFigureIcon(jicon);
warning('on','all')
%If the blindspots are being superimposed then switch to the hot colormap
if get(handles.ImposeBlindSpots,'value')
colormap(AxesHandles,'hot')
end
return
%==========================================================================
%==========================================================================
function detachMainSurface_Callback(hObject, eventdata, handles)
%Find figure, close it and open it again
Figure = findobj('Tag','mainSurfaceDetached');
if isempty(Figure)
Figure = figure('Tag','mainSurfaceDetached','WindowStyle','normal');
else
figure(Figure);
clf(Figure);
end
%Use Hyscorean window logo
warning('off','all')
Path = fileparts(which('Hyscorean'));
jFrame=get(Figure,'javaframe');
jicon=javax.swing.ImageIcon(fullfile(Path, 'bin', 'logo.png'));
jFrame.setFigureIcon(jicon);
warning('on','all')
%Make the window appear relative to the Hyscorean window
ScreenSize = get(0,'ScreenSize');
Position = handles.HyscoreanFigure.Position;
Position(1) = Position(1)/ScreenSize(3)+0.1;
Position(2) = Position(2)/ScreenSize(4);
ScreenSize = get(0,'ScreenSize');
set(Figure,'NumberTitle','off','Name','Hyscorean: HYSCORE Surface',...
'Units','normalized','Position',[Position(1) Position(2) 776/ScreenSize(3) 415/ScreenSize(4)]);
if handles.GraphicalSettings.Absolute
spectrum2 = abs(handles.Processed.spectrum);
elseif handles.GraphicalSettings.Real
spectrum2 = abs(handles.Processed.spectrum);
elseif handles.GraphicalSettings.Imaginary
spectrum2 = imag(handles.Processed.spectrum);
end
surf(handles.Processed.axis1,handles.Processed.axis2,spectrum2)
colormap(handles.GraphicalSettings.ColormapName)
shading('flat'),colorbar
XupperLimit = str2double(get(handles.XUpperLimit,'string'));
xlim([-XupperLimit XupperLimit]),ylim([0 XupperLimit])
xlabel('\nu_1 [MHz]'), ylabel('\nu_2 [MHz]')
return
%==========================================================================
%==========================================================================
function DetachProjectionPlot_Callback(hObject, eventdata, handles)
%Find figure, close it and open it again
Figure = findobj('Tag','mainProjectionDetached');
if isempty(Figure)
Figure = figure('Tag','mainProjectionDetached','WindowStyle','normal');
else
figure(Figure);
clf(Figure);
end
%Use Hyscorean window logo
warning('off','all')
Path = fileparts(which('Hyscorean'));
jFrame=get(Figure,'javaframe');
jicon=javax.swing.ImageIcon(fullfile(Path, 'bin', 'logo.png'));
jFrame.setFigureIcon(jicon);
warning('on','all')
%Make the window appear relative to the Hyscorean window
Position = handles.HyscoreanFigure.Position;
Position(1) = Position(1)+500;
Position(2) = Position(2)+60;
options.figsize = [500 500 790 450];
set(Figure,'NumberTitle','off','Name','Hyscorean: Projection Contour','Units','pixels','Position',options.figsize);
XUpperLimit=str2double(get(handles.XUpperLimit,'string'));
options.xaxs = [-XUpperLimit XUpperLimit]; options.yaxs = [0 XUpperLimit];
options.xlabel = '\nu_1 [MHz]'; options.ylabel = '\nu_2 [MHz]';
options.levels=handles.GraphicalSettings.Levels;
options.Linewidth=handles.GraphicalSettings.LineWidth;
options.nonewfig = true;
options.MinimalContourLevel = str2double(get(handles.MinimalContourLevel,'string'));
options.MaximalContourLevel = str2double(get(handles.MaximalContourLevel,'string'));
colormap(handles.GraphicalSettings.ColormapName)
if handles.GraphicalSettings.Absolute
spectrum2 = abs(handles.Processed.spectrum);
elseif handles.GraphicalSettings.Real
spectrum2 = real(handles.Processed.spectrum);
elseif handles.GraphicalSettings.Imaginary
spectrum2 = imag(handles.Processed.spectrum);
end
Hyscore_correlation_plot(handles.Processed.axis2,handles.Processed.axis1,spectrum2,options)
return
%==========================================================================
%==========================================================================
function GraphicalSettingsButton_Callback(hObject, eventdata, handles)
setappdata(0,'GraphicalSettings',handles.GraphicalSettings)
%Make the window appear relative to the Hyscorean window
Position = handles.HyscoreanFigure.Position;
ScreenSize = get(0,'ScreenSize');
Position(1) = Position(1)/ScreenSize(3) + 0.2;
Position(2) = Position(2)/ScreenSize(4) + 0.2;
Position(3) = 451.0/ScreenSize(3);
Position(4) = 177.0/ScreenSize(4);
%Call graphical settings GUI
Hyscorean_GraphicalSettings('Units','normalized','Position',Position)
uiwait(Hyscorean_GraphicalSettings)
handles.GraphicalSettings = getappdata(0,'GraphicalSettings');
switch handles.GraphicalSettings.Colormap
case 1
handles.GraphicalSettings.ColormapName = 'parula';
case 2
handles.GraphicalSettings.ColormapName = 'jet';
case 3
handles.GraphicalSettings.ColormapName = 'hsv';
case 4
handles.GraphicalSettings.ColormapName = 'hot';
case 5
handles.GraphicalSettings.ColormapName = 'cool';
case 6
handles.GraphicalSettings.ColormapName = 'spring';
case 7
handles.GraphicalSettings.ColormapName = 'summer';
case 8
handles.GraphicalSettings.ColormapName = 'autumn';
case 9
handles.GraphicalSettings.ColormapName = 'winter';
case 10
handles.GraphicalSettings.ColormapName = 'gray';
end
set(handles.ProcessingInfo, 'String', 'Status: Rendering...');drawnow;
try
[handles] = updateHyscoreanGUI(handles,handles.Processed)
catch
end
set(handles.ProcessingInfo, 'String', 'Status: Finished');drawnow;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function MultiTauDimensions_Callback(hObject, eventdata, handles)
handles.TauSelectionSwitch = true;
handles.backgroundCorrectionSwitch = true;
handles.ReconstructionSwitch = true;
set(handles.TauSelectionCheck,'visible','off')
set(handles.BackgroundCorrectionCheck,'visible','off')
set(handles.ReconstructionCheck,'visible','off')
set(handles.Validation_Button,'enable','off')
guidata(hObject,handles)
return
%==========================================================================
%==========================================================================
function GraphicalSettingsButton_CreateFcn(hObject, eventdata, handles)
handles.GraphicalSettings = getpref('hyscorean','graphicalsettings');
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function ImposeBlindSpots_Callback(hObject, eventdata, handles)
if handles.Data.exptype == '6pHYSCORE'
warndlg('Blindspot simulation uses only 2nd tau-value of loaded 6pHYSCORE and gives blindspots of a 4pHYSCORE','warning');
end
[handles] = updateHyscoreanGUI(handles,handles.Processed);
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function AddHelpLine_Callback(hObject, eventdata, handles)
%Get gyromagnetic ratio from selected nuclei
gyromagneticRatio = getgyro_Hyscorean(get(handles.AddTagList,'Value'),handles.IsotopeTags);
%Get center field in gauss
try
if isfield(handles.Data,'BrukerParameters')
CenterField = handles.Data.BrukerParameters.CenterField;
%Remove units character and convert to double
CenterField = str2double(CenterField(1:end-2));
elseif isfield(handles.Data,'AWG_Parameters')
CenterField = handles.Data.AWG_Parameters.B;
end
catch
errordlg('The experimental parameters could not be extracted from the loaded file.','File Error');
end
%convert to tesla
CenterField = CenterField*1e-4;
%Get field offset
Offset = get(handles.FieldOffset,'string');
Offset = str2double(Offset)*1e-4;
%Get type of transition and corresponding multiplier
FrequencyMultiplier = handles.FrequencyMultiplier;
%get Larmor frequency in MHz
Larmorfrequency = FrequencyMultiplier*gyromagneticRatio*(CenterField + Offset);
X = Larmorfrequency;
Y = abs(Larmorfrequency);
Xaxis = handles.Processed.axis1;
if X>0
Xaxis = Xaxis(Xaxis>0);
Slope = -1;
else
Xaxis = Xaxis(Xaxis>0);
Slope = -1;
end
switch FrequencyMultiplier
case 1
color = 'k';
case 2
color = 'r';
case 4
color = 'b';
end
Yaxis = Y + Slope*(Xaxis - abs(X));
hold(handles.mainPlot,'on')
LineHandle = plot(handles.mainPlot,Xaxis,Yaxis,'-.','LineWidth',1.5,'Color',color);
hold(handles.mainPlot,'off')
if isfield(handles,'AddedLines')
size = length(handles.AddedLines);
else
size = 0;
end
handles.AddedLines{size +1}.x = Xaxis;
handles.AddedLines{size +1}.y = Yaxis;
handles.AddedLines{size +1}.handle = LineHandle;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function TransititonType_Callback(hObject, eventdata, handles)
switch get(hObject,'Value')
case 1
FrequencyMultiplier = 1;
case 2
FrequencyMultiplier = 2;
case 3
FrequencyMultiplier = 4;
end
handles.FrequencyMultiplier = FrequencyMultiplier;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function TransititonType_CreateFcn(hObject, eventdata, handles)
handles.FrequencyMultiplier = 1;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function AddTagList_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
data = ReadDataTable_Hyscorean;
set(hObject,'string',data.Element);
data.Element = get(hObject,'string');
Colors = white(length(data.Element))-1;
j = 1;
for i=1:length(data.Element)
if (data.Spin(i) ~= 0) && (data.Nucleons(i) ~= 0)
IsotopeTags(j).isotope = num2str(data.Nucleons(i));
IsotopeTags(j).name = data.Element{i};
IsotopeTags(j).Color = uint8(Colors(i,:) * 255 + 0.5);
IsotopeTags(j).gn = data.gn(i);
j = j + 1;
end
end
ListBoxStrings = cell(numel( IsotopeTags ),1);
for i = 1:numel( IsotopeTags )
String = ['<HTML><FONT color=' reshape( dec2hex( IsotopeTags(i).Color,2 )',1, 6) '></FONT><SUP>' IsotopeTags(i).isotope '</SUP>' IsotopeTags(i).name '</HTML>'];
ListBoxStrings{i} = String;
end
set(hObject,'string',ListBoxStrings);
handles.IsotopeTags = IsotopeTags;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function SaverSettings_CreateFcn(hObject, eventdata, handles)
handles.SaveHyscoreanSettings.IdentifierName = 'Hyscorean_save';
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function ClearTags_Callback(hObject, eventdata, handles)
try
for i=1:length(handles.AddedLines)
delete(handles.AddedLines{i}.handle)
end
handles = rmfield(handles,'AddedLines');
catch
end
try
for i=1:length(handles.AddedTags)
delete(handles.AddedTags{i}.handle)
end
handles = rmfield(handles,'AddedTags');
catch
end
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function Lorentz2GaussCheck_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
enableDisableGUI(handles,'Lorent2Gauss','on')
else
enableDisableGUI(handles,'Lorent2Gauss','off')
end
return
%==========================================================================
%==========================================================================
function PlotApodizationWindow_Callback(hObject, eventdata, handles)
handles.PlotProcessedSignal = true;
HyscoreanSignalPlot(handles,handles.Processed)
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function ChangeSignalPlotDimension_Callback(hObject, eventdata, handles)
HyscoreanSignalPlot(handles,handles.Processed)
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function DetachSignalPlot_Callback(hObject, eventdata, handles)
setappdata(0,'Processed',handles.Processed)
setappdata(0,'Data',handles.Data)
setappdata(0,'InvertCorrection',get(handles.InvertCorrection,'value'))
setappdata(0,'ZeroFilling1',str2double(get(handles.ZeroFilling1,'String')))
setappdata(0,'ZeroFilling2',str2double(get(handles.ZeroFilling2,'String')))
setappdata(0,'WindowLength1',get(handles.WindowLength1,'String'))
setappdata(0,'WindowLength2',get(handles.WindowLength2,'String'))
setappdata(0,'WindowType',get(handles.WindowType,'Value'))
%Call graphical settings GUI
handles.SignalPlotIsDetached = true;
guidata(hObject, handles);
ScreenSize = get(0,'ScreenSize');
Position = handles.HyscoreanFigure.Position;
Position(1) = Position(1)/ScreenSize(3) + 0.1;
Position(2) = Position(2)/ScreenSize(4) + 0.1;
Position(3) = 790.0/ScreenSize(3);
Position(4) = 463.0/ScreenSize(4);
uiwait(Hyscorean_detachedSignalPlot('Units','normalized','Position',Position))
handles.SignalPlotIsDetached = false;
guidata(hObject, handles);
return
%==========================================================================
%==========================================================================
function MinimalContourLevel_Callback(hObject, eventdata, handles)
if str2double(get(hObject,'String')) < 0
set(hObject,'String',0)
end
if str2double(get(hObject,'String')) >= str2double(get(handles.MaximalContourLevel,'String'))
set(hObject,'String',str2double(get(handles.MaximalContourLevel,'String'))-0.5)
end
[handles] = updateHyscoreanGUI(handles,handles.Processed)