-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOryx.m
3446 lines (3032 loc) · 159 KB
/
Oryx.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
classdef Oryx < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Panel1 matlab.ui.container.Panel
ChoTextArea matlab.ui.control.TextArea
ChoTextAreaLabel matlab.ui.control.Label
NotesTextArea matlab.ui.control.TextArea
NAATextArea matlab.ui.control.TextArea
NAATextAreaLabel matlab.ui.control.Label
LipTextArea matlab.ui.control.TextArea
LipTextAreaLabel matlab.ui.control.Label
LacTextArea matlab.ui.control.TextArea
LacTextAreaLabel matlab.ui.control.Label
InsTextArea matlab.ui.control.TextArea
InsTextAreaLabel matlab.ui.control.Label
GluGlnTextArea matlab.ui.control.TextArea
GluGlnTextAreaLabel matlab.ui.control.Label
CrTextArea matlab.ui.control.TextArea
CrTextAreaLabel matlab.ui.control.Label
ChemicalShiftDirFHButtonGroup matlab.ui.container.ButtonGroup
FButton matlab.ui.control.RadioButton
HButton matlab.ui.control.RadioButton
ChemicalShiftDirLRButtonGroup matlab.ui.container.ButtonGroup
RButton matlab.ui.control.RadioButton
LButton matlab.ui.control.RadioButton
RFOVDirButtonGroup matlab.ui.container.ButtonGroup
APButton matlab.ui.control.RadioButton
RLButton matlab.ui.control.RadioButton
ReferenceMetabolite matlab.ui.container.ButtonGroup
refmetppm matlab.ui.control.NumericEditField
ppmEditFieldLabel matlab.ui.control.Label
refmetname matlab.ui.control.EditField
NameEditField_2Label matlab.ui.control.Label
Userdefrefmet matlab.ui.control.RadioButton
LacLipButton matlab.ui.control.RadioButton
ChoButton matlab.ui.control.RadioButton
CrButton matlab.ui.control.RadioButton
NAAButton matlab.ui.control.RadioButton
H2OButton matlab.ui.control.RadioButton
ChemicalShiftDirAPButtonGroup matlab.ui.container.ButtonGroup
PButton matlab.ui.control.RadioButton
AButton matlab.ui.control.RadioButton
TextArea_3 matlab.ui.control.TextArea
Label matlab.ui.control.Label
SelectaSPARfileButton matlab.ui.control.Button
Oryxlogo matlab.ui.control.Image
TextArea_2 matlab.ui.control.TextArea
ChemicalshiftcorrectionButtonGroup matlab.ui.container.ButtonGroup
OffButton matlab.ui.control.RadioButton
OnButton matlab.ui.control.RadioButton
DoneButton matlab.ui.control.Button
FWHMEditField matlab.ui.control.NumericEditField
SNREditField matlab.ui.control.NumericEditField
CRLBEditField matlab.ui.control.NumericEditField
fcsfEditField matlab.ui.control.NumericEditField
RFecho2BWEditField matlab.ui.control.NumericEditField
RFechoBWEditField matlab.ui.control.NumericEditField
RFexBWEditField matlab.ui.control.NumericEditField
Range01EditField matlab.ui.control.NumericEditField
FWHMLabel matlab.ui.control.Label
SNRLabel matlab.ui.control.Label
CRLBLabel matlab.ui.control.Label
CutoffvaluesforexclusioncriteriaLabel matlab.ui.control.Label
fCSFLabel matlab.ui.control.Label
RFBandwidthofthesystemLabel matlab.ui.control.Label
RFecho2BWEditFieldLabel matlab.ui.control.Label
RFechoBWEditFieldLabel matlab.ui.control.Label
RFexBWEditFieldLabel matlab.ui.control.Label
MRSIacquiredafterButtonGroup matlab.ui.container.ButtonGroup
T2wMRIButton matlab.ui.control.RadioButton
T1wMRIButton matlab.ui.control.RadioButton
MetaboliteMapListppmButtonGroup matlab.ui.container.ButtonGroup
PredefinedmapsAboveButton matlab.ui.control.RadioButton
choppm matlab.ui.control.NumericEditField
naappm matlab.ui.control.NumericEditField
lipppm matlab.ui.control.NumericEditField
lacppm matlab.ui.control.NumericEditField
insppm matlab.ui.control.NumericEditField
gluglnppm matlab.ui.control.NumericEditField
crppm matlab.ui.control.NumericEditField
userdefmapppm matlab.ui.control.NumericEditField
userdefmapname matlab.ui.control.EditField
NameEditFieldLabel matlab.ui.control.Label
UserdefinedmapButton matlab.ui.control.RadioButton
Panel2 matlab.ui.container.Panel
Panel matlab.ui.container.Panel
axialap matlab.ui.control.Slider
ILabel matlab.ui.control.Label
coronalsi matlab.ui.control.Slider
SLabel matlab.ui.control.Label
LLabel matlab.ui.control.Label
axialrl matlab.ui.control.Slider
RLabel matlab.ui.control.Label
PLabel matlab.ui.control.Label
ALabel matlab.ui.control.Label
AdjustrangeButton_3 matlab.ui.control.Button
MaxEditField_3 matlab.ui.control.NumericEditField
MaxEditField_3Label matlab.ui.control.Label
MinEditField_3 matlab.ui.control.NumericEditField
MinEditField_3Label matlab.ui.control.Label
AdjustrangeButton_2 matlab.ui.control.Button
MaxEditField_2 matlab.ui.control.NumericEditField
MaxEditField_2Label matlab.ui.control.Label
MinEditField_2 matlab.ui.control.NumericEditField
MinEditField_2Label matlab.ui.control.Label
MaxEditField matlab.ui.control.NumericEditField
MaxEditFieldLabel matlab.ui.control.Label
MinEditField matlab.ui.control.NumericEditField
MinEditFieldLabel matlab.ui.control.Label
AdjustrangeButton matlab.ui.control.Button
RegionNameDropDown matlab.ui.control.DropDown
RegionNameDropDownLabel matlab.ui.control.Label
EditSpectralquality matlab.ui.control.Button
which_map matlab.ui.container.ButtonGroup
CSFcorrectedconcetrationmaptoCrPCrratio matlab.ui.control.RadioButton
CSFcorrectedconcentrationmaptoInsratio matlab.ui.control.RadioButton
CSFcorrectedconcentrationmap matlab.ui.control.RadioButton
concentrationmaptoCrPCrratio matlab.ui.control.RadioButton
concentrationmaptoInsRatio matlab.ui.control.RadioButton
concentrationmap matlab.ui.control.RadioButton
WhichMetaboliteButtonGroup matlab.ui.container.ButtonGroup
UserdefinedmetaboliteButton matlab.ui.control.RadioButton
NAANAAGButton matlab.ui.control.RadioButton
Lip13aLip13bButton matlab.ui.control.RadioButton
Lip13bButton matlab.ui.control.RadioButton
Lip13aButton matlab.ui.control.RadioButton
LacButton matlab.ui.control.RadioButton
InsButton matlab.ui.control.RadioButton
GPCPChButton matlab.ui.control.RadioButton
GluGlnButton matlab.ui.control.RadioButton
CrPCrButton matlab.ui.control.RadioButton
TabGroup matlab.ui.container.TabGroup
MeanTab matlab.ui.container.Tab
meantable matlab.ui.control.Table
MedianTab matlab.ui.container.Tab
mediantable matlab.ui.control.Table
STDTab matlab.ui.container.Tab
stdtable matlab.ui.control.Table
DistributionsButton matlab.ui.control.Button
BackButton matlab.ui.control.Button
Image matlab.ui.control.Image
DataButtonGroup matlab.ui.container.ButtonGroup
AbsButton matlab.ui.control.RadioButton
ImagButton matlab.ui.control.RadioButton
RealButton matlab.ui.control.RadioButton
ROIAtlasLabel matlab.ui.control.Label
RegionNetworkExclusionEditField matlab.ui.control.NumericEditField
RegionNetworkExclusionEditFieldLabel matlab.ui.control.Label
ROIatlasDropDown matlab.ui.control.DropDown
Panel_2 matlab.ui.container.Panel
AdjustPlotButton matlab.ui.control.Button
YmaxEditField matlab.ui.control.NumericEditField
YmaxEditFieldLabel matlab.ui.control.Label
YminEditField matlab.ui.control.NumericEditField
YminEditFieldLabel matlab.ui.control.Label
XmaxEditField matlab.ui.control.NumericEditField
XmaxEditFieldLabel matlab.ui.control.Label
XminEditField matlab.ui.control.NumericEditField
XminEditFieldLabel matlab.ui.control.Label
pubmed matlab.ui.control.Image
SliceNumberLabel matlab.ui.control.Label
Slider matlab.ui.control.Slider
VisualizationoptionButtonGroup matlab.ui.container.ButtonGroup
CoordfilevisualizationButton matlab.ui.control.RadioButton
RawdatavisualizationButton matlab.ui.control.RadioButton
ExitButton matlab.ui.control.Button
github matlab.ui.control.Image
ROIAnalyzeButton matlab.ui.control.Button
RegistrationButton matlab.ui.control.Button
MetabolitemapsButton matlab.ui.control.Button
SpectralqualityButton matlab.ui.control.Button
CRLBFWHMSNRButton matlab.ui.control.Button
SegmentationButton matlab.ui.control.Button
CoregistrationButton matlab.ui.control.Button
LoadDataButton matlab.ui.control.Button
oryxlogo matlab.ui.control.Image
end
properties (Access = public)
SFile='';
SPath='';
Pinfo='';
Fused_cr='';
Fused_lac='';
Fused_all='';
chem_shift_ex='';
chem_shift_echo='';
chem_shift_echo2='';
Metabolites='';
AllNumStd='';
AllConc='';
AllFWHM='';
AllSNR='';
Metname='';
outmat='';
includedvoxels='';
coreg_path='';
fcsf='';
fgm='';
fwm='';
currentslider='';
currentmodule='';
meanTab='';
medianTab='';
stdTab='';
coreg_status='';
seg_status='';
allvoxels='';
metmap_status='';
regist_status='';
spardone='';
mloaddata='';
mcoregistration='';
msegmentation='';
mfhwmsnr='';
mcrlb='';
mincludedvoxels='';
mmetabolitemaps='';
mregistration='';
mroianalyze='';
roi_status='';
atlaspath='';
refnii='';
vis_map='';
tabledata;
metabs;
corrMatrix;
sp;
bg;
fit;
coord_filename;
ReferenceMetabolite2='';
RFOV_dir='RL'; %Jan 19, 2024
chem_shift_dir_AP='A'; %Jan 19, 2024
chem_shift_dir_LR='L'; %Jan 19, 2024
chem_shift_dir_FH='F'; %Jan 19, 2024
refppm='';
backtrig='0';
ext='';
userrefmetppm='1';
edit='0';
rowno='0';
colno='0';
WhichMetabNoD='';
end
properties (Access = private)
% Description
Property52 % Description
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
warning('off','all')
set(app.DoneButton,'Enable','off');
set(app.refmetppm,'Enable','off');
set(app.refmetname,'Enable','off');
set(app.userdefmapname,'Enable','off');
set(app.userdefmapppm,'Enable','off');
app.MinEditField.Visible='off';
app.MaxEditField.Visible='off';
app.AdjustrangeButton.Visible='off';
app.AdjustrangeButton_2.Visible='off';
app.AdjustrangeButton_3.Visible='off';
app.MinEditFieldLabel.Visible='off';
app.MaxEditFieldLabel.Visible='off';
app.axialrl.Visible='off';
app.axialap.Visible='off';
app.coronalsi.Visible='off';
app.ILabel.Visible='off';
app.SLabel.Visible='off';
app.ALabel.Visible='off';
app.PLabel.Visible='off';
app.RLabel.Visible='off';
app.LLabel.Visible='off';
app.EditSpectralquality.Visible='off';
app.RegionNameDropDown.Visible='off';
app.RegionNameDropDownLabel.Visible='off';
app.MinEditField_2.Visible='off';
app.MaxEditField_2.Visible='off';
% app.MinEditFieldLabel_2.Visible='off';
% app.MaxEditFieldLabel_2.Visible='off';
% app.MinEditField_3.Visible='off';
% app.MaxEditField_3.Visible='off';
% app.MinEditFieldLabel_3.Visible='off';
%app.MaxEditFieldLabel_3.Visible='off';
% app.AdjustrangeButton_2.Visible='off';
% app.AdjustrangeButton3.Visible='off';
end
% Size changed function: Panel1
function Panel1SizeChanged(app, event)
position = app.Panel1.Position;
end
% Button pushed function: SelectaSPARfileButton
function SelectaSPARfileButtonPushed(app, event)
[app.SFile,app.SPath]=uigetfile({'*.SPAR;*.spar;*.nii;*.nii.gz';'*.*'},'Select an SPAR / a NIfTI-MRS file');figure(app.UIFigure);
if app.SFile~=0
app.spardone=1;
set(app.DoneButton,'Enable','on');
end
end
% Button pushed function: DoneButton
function DoneButtonPushed(app, event)
if app.spardone=='0'
selection = uiconfirm(app.UIFigure,'Select an Spar / a NIfTI-MRS file','Confirm Close','Options',{'Ok'},...
'Icon','warning');
return
end
app.Panel2.Visible = 'on';
app.EditSpectralquality.Visible='off';
app.Panel1.Visible = 'off';
app.TabGroup.Visible='off';
app.VisualizationoptionButtonGroup.Visible='off';
app.ROIatlasDropDown.Visible='off';
app.ROIAtlasLabel.Visible='off';
app.RegionNetworkExclusionEditField.Visible='off';
app.RegionNetworkExclusionEditFieldLabel.Visible='off';
app.SliceNumberLabel.Visible='off';
app.Slider.Visible='off';
app.WhichMetaboliteButtonGroup.Visible='off';
app.Panel_2.Visible='off';
app.coreg_status=0;
app.seg_status=0;
app.metmap_status=0;
app.regist_status=0;
app.roi_status=0;
set(app.CoregistrationButton,'Enable','off');
set(app.SegmentationButton,'Enable','off');
set(app.CRLBFWHMSNRButton,'Enable','off');
set(app.SpectralqualityButton,'Enable','off');
set(app.MetabolitemapsButton,'Enable','off');
set(app.RegistrationButton,'Enable','off');
set(app.ROIAnalyzeButton,'Enable','off');
set(app.DistributionsButton,'Enable','off');
app.userrefmetppm=app.refmetppm.Value;
app.RegionNameDropDown.Visible='off';
app.RegionNameDropDownLabel.Visible='off';
app.MinEditField_2.Visible='off';
app.MaxEditField_2.Visible='off';
app.MinEditField_2Label.Visible='off';
app.MaxEditField_2Label.Visible='off';
app.MinEditField_3.Visible='off';
app.MaxEditField_3.Visible='off';
app.MinEditField_3Label.Visible='off';
app.MaxEditField_3Label.Visible='off';
app.AdjustrangeButton_2.Visible='off';
app.AdjustrangeButton_3.Visible='off';
app_Path=app.SPath;
app_File=app.SFile;
app.DataButtonGroup.Visible='off';
if app.backtrig == '0'
if app.spardone==1
[fpath,fname,ext] = fileparts([app.SPath,app.SFile]);
if strcmp(ext,'.nii')
app.Pinfo.ext='0';
else
app.Pinfo.ext='1';
[app.Pinfo]= loadfile(app_File,app_Path);
end
%[app.Pinfo]= loadfile(app_File,app_Path);
end
else
answer = questdlg('Would you like to change the setted parameters?', ...
' ', ...
'No','Yes','Yes');
% Handle response
switch answer
case 'No'
% disp([answer 'The analysis will continue'])
app.LoadDataButtonPushed(app);
case 'Yes'
% disp([answer 'The parameters are setted up and the previous files will delete!'])
app.LoadDataButtonPushed(app);
end
%Give an allert and delete the previous outputs
if app.spardone==1
[fpath,fname,ext] = fileparts([app.SPath,app.SFile]);
if strcmp(ext,'.nii')
app.Pinfo.ext='0';
else
[app.Pinfo]= loadfile(app_File,app_Path);
app.Pinfo.ext='1';
end
end
end
end
% Selection changed function: MRSIacquiredafterButtonGroup
function MRSIacquiredafterButtonGroupSelectionChanged(app, event)
app.MRSIacquiredafterButtonGroup.SelectedObject;
switch app.ChemicalshiftcorrectionButtonGroup.SelectedObject.Text
case 'Off'
set(app.ChemicalShiftDirAPButtonGroup,'Enable','off');
set(app.ChemicalShiftDirLRButtonGroup,'Enable','off');
set(app.ChemicalShiftDirFHButtonGroup,'Enable','off');
set(app.RFOVDirButtonGroup,'Enable','off');
set(app.RFexBWEditField,'Enable','off');
set(app.RFechoBWEditField,'Enable','off');
set(app.RFecho2BWEditField,'Enable','off');
set(app.RFBandwidthofthesystemLabel,'Enable','off');
set(app.RFecho2BWEditFieldLabel,'Enable','off');
set(app.RFechoBWEditFieldLabel,'Enable','off');
set(app.RFexBWEditFieldLabel,'Enable','off');
otherwise
set(app.ChemicalShiftDirAPButtonGroup,'Enable','on');
set(app.ChemicalShiftDirLRButtonGroup,'Enable','on');
set(app.ChemicalShiftDirFHButtonGroup,'Enable','on');
set(app.RFOVDirButtonGroup,'Enable','on');
set(app.RFexBWEditField,'Enable','on');
set(app.RFechoBWEditField,'Enable','on');
set(app.RFecho2BWEditField,'Enable','on');
set(app.RFBandwidthofthesystemLabel,'Enable','on');
set(app.RFecho2BWEditFieldLabel,'Enable','on');
set(app.RFechoBWEditFieldLabel,'Enable','on');
set(app.RFexBWEditFieldLabel,'Enable','on');
end
end
% Selection changed function: ChemicalshiftcorrectionButtonGroup
function ChemicalshiftcorrectionButtonGroupSelectionChanged(app, event)
app.ChemicalshiftcorrectionButtonGroup.SelectedObject;
switch app.ChemicalshiftcorrectionButtonGroup.SelectedObject.Text
case 'Off'
set(app.ChemicalShiftDirAPButtonGroup,'Enable','off');
set(app.ChemicalShiftDirLRButtonGroup,'Enable','off');
set(app.ChemicalShiftDirFHButtonGroup,'Enable','off');
set(app.RFOVDirButtonGroup,'Enable','off');
set(app.RFexBWEditField,'Enable','off');
set(app.RFechoBWEditField,'Enable','off');
set(app.RFecho2BWEditField,'Enable','off');
set(app.RFBandwidthofthesystemLabel,'Enable','off');
set(app.RFecho2BWEditFieldLabel,'Enable','off');
set(app.RFechoBWEditFieldLabel,'Enable','off');
set(app.RFexBWEditFieldLabel,'Enable','off');
set(app.ReferenceMetabolite,'Enable','off');
otherwise
set(app.ChemicalShiftDirAPButtonGroup,'Enable','on');
set(app.ChemicalShiftDirLRButtonGroup,'Enable','on');
set(app.ChemicalShiftDirFHButtonGroup,'Enable','on');
set(app.RFOVDirButtonGroup,'Enable','on');
set(app.RFexBWEditField,'Enable','on');
set(app.RFechoBWEditField,'Enable','on');
set(app.RFecho2BWEditField,'Enable','on');
set(app.RFBandwidthofthesystemLabel,'Enable','on');
set(app.RFecho2BWEditFieldLabel,'Enable','on');
set(app.RFechoBWEditFieldLabel,'Enable','on');
set(app.RFexBWEditFieldLabel,'Enable','on');
set(app.ReferenceMetabolite,'Enable','on');
end
end
% Value changed function: Range01EditField
function Range01EditFieldValueChanged(app, event)
app.Range01EditField.Value;
end
% Value changed function: RFexBWEditField
function RFexBWEditFieldValueChanged(app, event)
app.RFexBWEditField.Value;
end
% Value changed function: RFechoBWEditField
function RFechoBWEditFieldValueChanged(app, event)
app.RFechoBWEditField.Value;
end
% Value changed function: RFecho2BWEditField
function RFecho2BWEditFieldValueChanged(app, event)
app.RFecho2BWEditField.Value;
end
% Value changed function: fcsfEditField
function fcsfEditFieldValueChanged(app, event)
app.fcsfEditField.Value;
end
% Value changed function: CRLBEditField, NotesTextArea
function CRLBEditFieldValueChanged(app, event)
app.CRLBEditField.Value;
end
% Value changed function: FWHMEditField
function FWHMEditFieldValueChanged(app, event)
app.FWHMEditField.Value;
end
% Value changed function: SNREditField
function SNREditFieldValueChanged(app, event)
app.SNREditField.Value;
end
% Button pushed function: LoadDataButton
function LoadDataButtonPushed(app, event)
app.EditSpectralquality.Visible='off';
app.ILabel.Visible='off';
app.SLabel.Visible='off';
app.ALabel.Visible='off';
app.PLabel.Visible='off';
app.RLabel.Visible='off';
app.LLabel.Visible='off';
app.axialrl.Visible='off';
app.axialap.Visible='off';
app.coronalsi.Visible='off';
app.Panel_2.Visible='off';
app.TabGroup.Visible='off';
app.which_map.Visible='off';
app.ROIatlasDropDown.Visible='off';
app.ROIAtlasLabel.Visible='off';
app.RegionNetworkExclusionEditField.Visible='off';
app.RegionNetworkExclusionEditFieldLabel.Visible='off';
app.VisualizationoptionButtonGroup.Visible='on';
app.WhichMetaboliteButtonGroup.Visible='off';
app.DataButtonGroup.Visible='off';
app.axialap.Visible='off';
app.axialrl.Visible='off';
app.coronalsi.Visible='off';
app.RegionNameDropDown.Visible='off';
app.RegionNameDropDownLabel.Visible='off';
obj=findobj(app.Panel,'type','Axes');
delete(obj);
wait=uiprogressdlg(app.UIFigure,'Message','Plotting.. Please wait','Title','Plotting');
selectedButton = app.VisualizationoptionButtonGroup.SelectedObject;
obj=findobj(app.Panel,'type','Axes');
delete(obj);
varext=app.Pinfo.ext;
if varext=='0' %% Nifti Plot
switch selectedButton.Text %% selected file is a nifti
case 'Raw data visualization'
app.DataButtonGroup.Visible='on';
app.Panel.AutoResizeChildren='off';
app.Panel_2.Visible='on';
app.Slider.Visible='off';
app.SliceNumberLabel.Visible='off';
obj=findobj(app.Panel,'type','Axes'); %panel clear
delete(obj); %panel clear
nifti_file = [app.SPath,app.SFile];
nii = nii_tool('load', nifti_file);
size(nii.img)
if ans(1,1)>1 % multivoxel nifti image
fid = squeeze(nii.img);
sw = 1/nii.hdr.pixdim(5);
% Decode the JSON header extension string
header_extension = jsondecode(nii.ext.edata_decoded);
% Extract F0 and number of samples
f0 = header_extension.SpectrometerFrequency;
npts = nii.hdr.dim(5);
% Create frequency axis
f = [(-sw/2)+(sw/(2*npts)):sw/(npts):(sw/2)-(sw/(2*npts))];
% Convert to ppm
ppm = -f/f0;
ppm = ppm + 4.68;
wait.Value=0.2;
nrow=nii.hdr.dim(1,2);
ncol=nii.hdr.dim(1,3);
npoints=nii.hdr.dim(1,5); %
n=1;
pos=get(app.Panel,'Position');
xinc=1/nrow ;
yinc=1/ncol;
for k=1:nrow
ystart=(k-1)*yinc;
for j=1:ncol
xstart=(j-1)*xinc;
ax= subplot('Position',[-5 -5 0 0],'Parent',app.Panel);
switch app.DataButtonGroup.SelectedObject.Text
case 'Real'
spec = fftshift(fft(squeeze(fid(k,j,:))));
dataplot=real(spec);%squeeze(real(flip(raw_data(app.Slider.Value,k,j,:))));
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(real(spec));%min(min(min(min(real((raw_data(:,:,:,532:800)))))));
ymax=max(real(spec));%max(max(max(max(real((raw_data(:,:,:,532:800)))))));
% ylim(ax,[ymin ymax]);
case 'Imag'
spec = fftshift(fft(squeeze(fid(k,j,:))));
dataplot=imag(spec);
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(imag(spec));%min(min(min(min(imag((raw_data(:,:,:,532:800)))))));
ymax=max(imag(spec));%max(max(max(max(imag((raw_data(:,:,:,532:800)))))));
% ylim(ax,[ymin ymax]);
otherwise
spec = fftshift(fft(squeeze(fid(k,j,:))));
Bsqrt=sqrt(((real(spec)).^2)+((imag(spec)).^2));
absdata=(Bsqrt);
dataplot=absdata;
%squeeze(real(flip(raw_data(app.Slider.Value,k,j,:))));
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(real(spec));%min(min(min(min(real((raw_data(:,:,:,532:800)))))));
ymax=max(real(spec));%max(max(max(max(real((raw_data(:,:,:,532:800)))))));
% ylim(ax,[ymin ymax]);
end
xticks(ax,[ ]);
yticks(ax,[ ]);
set(ax,'Position',[xstart,1-yinc-ystart,xinc*0.95,yinc*0.7]);
n=n+1;
wait.Value=0.9*(n/(ncol*nrow));
end
end
app.Slider.Visible='off';
app.SliceNumberLabel.Visible='off';
obj=findobj(app.Panel,'Type','Axes');
set(obj,'ButtonDownFcn',@axck);
else % the data is single voxel nifti
app.SliceNumberLabel.Visible='off';
app.Slider.Visible='off';
fid = squeeze(nii.img);
sw = 1/nii.hdr.pixdim(5)
% Decode the JSON header extension string
header_extension = jsondecode(nii.ext.edata_decoded)
% Extract F0 and number of samples
f0 = header_extension.SpectrometerFrequency;
npts = nii.hdr.dim(5);
% Create frequency axis
f = [(-sw/2)+(sw/(2*npts)):sw/(npts):(sw/2)-(sw/(2*npts))];
% Convert to ppm
ppm = -f/f0;
ppm = ppm + 4.68;
n=1;
pos=get(app.Panel,'Position');
xinc=1/1;
yinc=1/1;
ystart=(1-1)*yinc;
xstart=(1-1)*xinc;
ax= subplot('Position',[-5 -5 0 0],'Parent',app.Panel);
switch app.DataButtonGroup.SelectedObject.Text
case 'Real'
spec = fftshift(fft(squeeze(fid(:,1))));
dataplot=real(spec);
plot(ax,dataplot);
xlim(ax,[1 length(fid)]);
ymin=min(real(spec));
ymax=max(real(spec));
% set(gca, 'xdir', 'reverse', 'xlim', [0 5]);
% xlabel('Chemical shift (ppm)');
case 'Imag'
spec = fftshift(fft(squeeze(fid(:,1))));
dataplot=imag(spec);
plot(ax,dataplot);
xlim(ax,[1 length(fid)]);
ymin=min(imag(spec));
ymax=max(imag(spec));
otherwise
spec = fftshift(fft(squeeze(fid(:,1))));
Bsqrt=sqrt(((real(spec)).^2)+((imag(spec)).^2));
absdata=(Bsqrt);
dataplot=absdata;
plot(ax,dataplot);
xlim(ax,[1 4097]);
ymin=min(real(spec));
ymax=max(real(spec));
end
xticks(ax,[ ]);
yticks(ax,[ ]);
set(ax,'Position',[xstart,1-yinc-ystart,xinc*0.95,yinc*0.7]);
n=n+1;
wait.Value=0.9;
end
otherwise
f = msgbox('There is no coord/table files of the Nifti');
selectedButton = 'Coord file visualization';
% app.LoadDataButtonPushed(app);
end
else %% the selected file is an spar file
switch selectedButton.Text %% selected file is an spar file
case 'Raw data visualization'
app.SliceNumberLabel.Visible='on';
app.Slider.Visible='on';
app.DataButtonGroup.Visible='on';
[raw_data]=RawDataVisual(app.Pinfo.sparfilepath);
[nslice,nrow,ncol,t]= size(raw_data);
app.Panel.AutoResizeChildren='off';
app.Panel_2.Visible='on';
n=1;
pos=get(app.Panel,'Position');
xinc=1/nrow ;
yinc=1/ncol;
for k=1:nrow
ystart=(k-1)*yinc;
for j=1:ncol
xstart=(j-1)*xinc;
ax= subplot('Position',[-5 -5 0 0],'Parent',app.Panel);
switch app.DataButtonGroup.SelectedObject.Text
case 'Real'
dataplot=squeeze(real(flip(raw_data(app.Slider.Value,k,j,:))));
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(min(min(min(real((raw_data(:,:,:,532:800)))))));
ymax=max(max(max(max(real((raw_data(:,:,:,532:800)))))));
ylim(ax,[ymin ymax]);
case 'Imag'
dataplot=squeeze(imag(flip(raw_data(app.Slider.Value,k,j,:))));
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(min(min(min(imag((raw_data(:,:,:,532:800)))))));
ymax=max(max(max(max(imag((raw_data(:,:,:,532:800)))))));
ylim(ax,[ymin ymax]);
otherwise % Abs
rval=squeeze(real(flip(raw_data(app.Slider.Value,k,j,:))));
ival=squeeze(imag(flip(raw_data(app.Slider.Value,k,j,:))));
Bsqrt=sqrt((rval.^2)+(ival.^2));
absdata=(Bsqrt);
dataplot=absdata;
plot(ax,dataplot);
xlim(ax,[532 800]);
ymin=min(min(min(min(imag((raw_data(:,:,:,532:800)))))));
ymax=max(max(max(max(imag((raw_data(:,:,:,532:800)))))));
ylim(ax,[ymin ymax]);
end
xticks(ax,[ ]);
yticks(ax,[ ]);
%box(ax,'off');
set(ax,'Position',[xstart,1-yinc-ystart,xinc*0.95,yinc*0.7]);
n=n+1;
wait.Value=0.9*(n/(ncol*nrow));
end
end
obj=findobj(app.Panel,'Type','Axes');
set(obj,'ButtonDownFcn',@axck);
otherwise %% Coord file visualization
app.SliceNumberLabel.Visible='on';
app.Slider.Visible='on';
app.DataButtonGroup.Visible='off';
[app.allvoxels]=GUI_MV_coordreader(app.Pinfo);
[nslice,nrow,ncol]= size(app.allvoxels);
app.Panel.AutoResizeChildren='off';
app.Panel_2.Visible='off';
n=1;
pos=get(app.Panel,'Position');
xinc=1/nrow ;
yinc=1/ncol;
for k=1:nrow
ystart=(k-1)*yinc;
for j=1:ncol
xstart=(j-1)*xinc;
ax= subplot('Position',[-5 -5 0 0],'Parent',app.Panel);
plot(ax,app.allvoxels(app.Slider.Value,k,j).spectra);
xticks(ax,[ ]);
yticks(ax,[ ]);
box(ax,'on');
set(ax,'Position',[xstart,1-yinc-ystart,xinc*0.95,yinc*0.7]);
n=n+1;
wait.Value=0.9*(n/(ncol*nrow));
set(ax,'Tag', num2str([k,j]))
end
end
obj=findobj(app.Panel,'Type','Axes');
set(obj,'ButtonDownFcn',@ImageClickCallback);
end %% spar file
end
obj=findobj(app.Panel,'Type','Axes');
set(obj,'Color',app.Panel.BackgroundColor);
set(obj,'XColor',app.Panel.BackgroundColor);
set(obj,'YColor',app.Panel.BackgroundColor);
function ImageClickCallback(AxesH, EventData)
row=strsplit(AxesH.Tag,' ');
column=row{2};
row=row{1};
f=figure;
ax=subplot(1,1,1,'Parent',f);
ax=get(f,'Children');
[app.tabledata,app.metabs,app.corrMatrix,app.sp,app.bg,app.fit,app.coord_filename]=load_lcmodel(app.Pinfo.coordpath,app.Pinfo.sparname,...
app.Slider.Value,row,column);
plotSpectra(app,1,app.sp{1}.ppm,3,ax,[0 0 0],16);
... what to do with x and y?
end
function axck(varargin)
f=figure;
copyobj(varargin{1},f);
ax=get(f,'Children');
set(ax,'Position',[0 0 1 1]);
% varargin{1};
% varargin{2}
end
delete(wait);
% toc;
app.MinEditField.Visible='off';
app.MinEditFieldLabel.Visible='off';
app.MaxEditField.Visible='off';
app.MaxEditFieldLabel.Visible='off';
app.AdjustrangeButton.Visible='off';
app.AdjustrangeButton_2.Visible='off';
app.AdjustrangeButton_3.Visible='off';
app.MinEditField_2.Visible='off';
app.MaxEditField_2.Visible='off';
app.MinEditField_2Label.Visible='off';
app.MaxEditField_2Label.Visible='off';
app.MinEditField_3.Visible='off';
app.MaxEditField_3.Visible='off';
app.MinEditField_3Label.Visible='off';
app.MaxEditField_3Label.Visible='off';
app.currentmodule=1;
app.mloaddata=1;
if app.mloaddata>0
set(app.CoregistrationButton,'Enable','on');
end
%app.SliceNumberLabel.Visible='on';
% app.Slider.Visible='on';
app.Panel.Visible='on';
% app.Panel_2.Visible='on';
end
% Selection changed function: VisualizationoptionButtonGroup
function VisualizationoptionButtonGroupSelectionChanged(app, event)
selectedButton = app.VisualizationoptionButtonGroup.SelectedObject;
obj=findobj(app.Panel,'type','Axes');
delete(obj);
switch selectedButton.Text
case 'Raw data visualization'
app.Panel_2.Visible='on';
app.DataButtonGroup.Visible='on';
otherwise
app.DataButtonGroup.Visible='off';
app.Panel_2.Visible='off';
end
app.LoadDataButtonPushed(app);
end
% Button pushed function: ExitButton
function ExitButtonPushed(app, event)
delete(app)
end
% Button pushed function: CoregistrationButton
function CoregistrationButtonPushed(app, event)
app.EditSpectralquality.Visible='off';
app.ILabel.Visible='off';
app.SLabel.Visible='off';
app.ALabel.Visible='off';
app.PLabel.Visible='off';
app.RLabel.Visible='off';
app.LLabel.Visible='off';
app.axialrl.Visible='off';
app.axialap.Visible='off';
app.coronalsi.Visible='off';
app.MinEditField.Visible='off';
app.MinEditFieldLabel.Visible='off';
app.MaxEditField.Visible='off';
app.MaxEditFieldLabel.Visible='off';
app.AdjustrangeButton.Visible='off';
app.AdjustrangeButton_2.Visible='off';
app.AdjustrangeButton_3.Visible='off';
app.MinEditField_2.Visible='off';
app.MaxEditField_2.Visible='off';
app.MinEditField_2Label.Visible='off';
app.MaxEditField_2Label.Visible='off';
app.MinEditField_3.Visible='off';
app.MaxEditField_3.Visible='off';
app.MinEditField_3Label.Visible='off';
app.MaxEditField_3Label.Visible='off';
app.TabGroup.Visible='off';
app.DataButtonGroup.Visible='off';
app.Panel_2.Visible='off';
app.which_map.Visible='off';
app.ROIatlasDropDown.Visible='off';
app.axialap.Visible='off';
app.axialrl.Visible='off';
app.coronalsi.Visible='off';
app.ROIAtlasLabel.Visible='off';
app.VisualizationoptionButtonGroup.Visible='off';
app.RegionNetworkExclusionEditField.Visible='off';
app.RegionNetworkExclusionEditFieldLabel.Visible='off';
app.WhichMetaboliteButtonGroup.Visible='off';
app.Slider.Visible='off';
app.SliceNumberLabel.Visible='off';
app.WhichMetaboliteButtonGroup.Visible='off';
app.RegionNameDropDown.Visible='off';
app.RegionNameDropDownLabel.Visible='off';
obj=findobj(app.Panel,'type','Axes');
delete(obj);
wait=uiprogressdlg(app.UIFigure,"Message",'Processing.. It will take some time be patient. ','Title','Coregistration');
app.VisualizationoptionButtonGroup.Visible='off';
switch app.MetaboliteMapListppmButtonGroup.SelectedObject.Text
case 'User defined map'
app.Metname={'Cr+PCr' 'Glu+Gln' 'GPC+PCh' 'Ins' 'Lac' 'Lip13a' 'Lip13b' 'Lip13a+Lip13b' 'NAA+NAAG' app.userdefmapname.Value};
shiftedppm=[3.03 2.25 3.2 3.52 1.3 1.3 1.3 1.3 2.02 app.userdefmapppm.Value];
set(app.UserdefinedmetaboliteButton,'Enable','on');
otherwise %'Pre-defined maps (Above)'
app.Metname={'Cr+PCr' 'Glu+Gln' 'GPC+PCh' 'Ins' 'Lac' 'Lip13a' 'Lip13b' 'Lip13a+Lip13b' 'NAA+NAAG'};
shiftedppm=[3.03 2.25 3.2 3.52 1.3 1.3 1.3 1.3 2.02 ];
set(app.UserdefinedmetaboliteButton,'Enable','off');
end
for n=1:numel(app.Metname)
app.Metabolites(n).no=n;
app.Metabolites(n).name=app.Metname{1,n};
app.Metabolites(n).ppm=shiftedppm(1,n);
end
spectrapath=app.Pinfo.spectrapath;
app.coreg_path=[spectrapath,filesep,'nifti',filesep,'coreg_binary_mask']; % Output files of coregistration binary masks.
if ~exist(app.coreg_path,'dir')
mkdir(app.coreg_path);
end
if app.coreg_status<1
switch app.MRSIacquiredafterButtonGroup.SelectedObject.Text
case 'T1w-MRI'
app.Pinfo.MRI= [app.Pinfo.mainpath,'exam_1',filesep,'images',filesep,'T1',filesep,'nifti',filesep,app.Pinfo.name,'_Bet.nii.gz'];
otherwise
app.Pinfo.MRI= [app.Pinfo.mainpath,'exam_1',filesep,'images',filesep,'T2',filesep,'nifti',filesep,app.Pinfo.name,'_Bet.nii.gz'];
end
%newly added for corre.
MRIFOVMask_file=[app.coreg_path,filesep,app.Pinfo.sparname,'_FOV_mask.nii'];
[app.Pinfo] = Mask_FOV_run_Pinfo(app.Pinfo,MRIFOVMask_file,app.RFOV_dir);
%%
for k=1:numel(app.Metabolites)
wait.Value=(k/numel(app.Metabolites))-0.1;
%MRIFOVMask_file=[app.coreg_path,filesep,app.Pinfo.sparname,'_',app.Metabolites(k).name,'_FOV_mask.nii'];
MRIpressMask_file=[app.coreg_path,filesep,app.Pinfo.sparname,'_',app.Metabolites(k).name,'_PressBox_mask.nii'];
switch app.ChemicalshiftcorrectionButtonGroup.SelectedObject.Text
case 'On'
Chem_Shift_Dir_mat=find_chem_shift_directions(app.RFOV_dir, app.chem_shift_dir_AP, app.chem_shift_dir_LR, app.chem_shift_dir_FH);
[GR_ex, GR_echo,GR_echo2]=gradient_strength_calc(app.Pinfo.apVOI,app.Pinfo.lrVOI,app.Pinfo.ccVOI,Chem_Shift_Dir_mat,app.RFexBWEditField.Value,app.RFechoBWEditField.Value,app.RFecho2BWEditField.Value);
[app.chem_shift_ex(k).no,app.chem_shift_echo(k).no,app.chem_shift_echo2(k).no]=Chem_Shift_calculation(app.Metabolites(k).ppm,GR_ex,GR_echo,GR_echo2,app.ReferenceMetabolite.SelectedObject.Text,app.userrefmetppm);
[app.Pinfo] = Mask_Press_run_Pinfo(app.Pinfo,k,MRIpressMask_file,app.chem_shift_ex(k).no,app.chem_shift_echo(k).no,app.chem_shift_echo2(k).no,app.RFOV_dir);
otherwise
app.chem_shift_ex(k).no=0;
app.chem_shift_echo(k).no=0;
app.chem_shift_echo2(k).no=0;
%[app.Pinfo] = Mask_FOV_run_Pinfo(app.Pinfo,k,MRIFOVMask_file,app.chem_shift_ex(k).no,app.chem_shift_echo(k).no,app.chem_shift_echo2(k).no,app.RFOV_dir);