forked from rordenlab/MRIcroGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainunit.pas
executable file
·10439 lines (9911 loc) · 346 KB
/
mainunit.pas
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
unit mainunit;
//{$mode delphi}
{$mode delphi}{$H+}
{$IFDEF LCLCocoa}
//MetalAPI supported on modern MacOS: disable for Linux, Windows and old MacOS
//{$DEFINE METALAPI} //set in ProjectOptions/CompilerOptions/CustomOptions: -dMETALAPI
//{$modeswitch objectivec1}
{$modeswitch objectivec1}
{$DEFINE NewCocoa}
//{$DEFINE DARKMODE}
{$ENDIF}
{$IFNDEF METALAPI}
{$WARN 5023 off : Unit "$1" not used in $2}
{$include ./Metal-Demos/common/glopts.inc}
{$ENDIF}
{$IFDEF LCLCarbon}
error: you must compile for the Cocoa widgetset (ProjectOptions/Additions&Overrides)
{$ENDIF}
{$DEFINE MATCAP}
{$DEFINE COMPILEYOKE} //use yoking
{$DEFINE CLRBAR} //provide color bar
{$DEFINE GRAPH} //timeseries viewer
{$DEFINE AFNI} //afni statistical maps \
{$WARN 5024 OFF} //disable warnings about unused parameters
{$WARN 5043 off : Symbol "$1" is deprecated}
{$DEFINE MATT1}
{$IFDEF MYPY}{$IFNDEF PY4LAZ}
{$include ./PythonBridge/pyopts.inc} //for PYTHON_DYNAMIC
{$ifdef darwin}
{$ifdef CPUAARCH64}
{$linklib ./PythonBridge/aarch64-darwin/libpython3.7m.a}
{$else}
{$linklib ./PythonBridge/x86_64-darwin/libpython3.7m.a}
{$endif}
{$endif}
{$ifdef linux}
{$ifndef PYTHON_DYNAMIC}
{$linklib c}
{$linklib m}
{$linklib pthread}
{$linklib util}
{$linklib dl}
{$linklib ./PythonBridge/x86_64-linux/libpython3.7m.a}
{$ENDIF}
{$endif}
{$ENDIF}{$ENDIF}
interface
{$include opts.inc} //for DEFINE MOSAICS
uses
{$IFDEF MATT1}umat, {$ENDIF}
{$IFDEF METALAPI}
MetalPipeline, Metal,MetalControl, mtlvolume2,
{$IFDEF GRAPH}mtlgraph,{$ENDIF}
{$IFDEF CLRBAR}mtlclrbar, {$ENDIF}
{$ENDIF}
{$IFDEF COMPILEYOKE} yokesharemem, {$ENDIF}
{$IFDEF Linux} LazFileUtils, {$ENDIF}
{$IFDEF AFNI} nifti_foreign, afni_fdr, {$ENDIF}
{$IFDEF MYPY}
{$IFDEF PY4LAZ}
PythonEngine, //use PythonForLazarus
{$ELSE}
Python3Core, PythonBridge, //use PythonPascalBridge
{$ENDIF}
{$ENDIF} //if MYPY
{$IFDEF Darwin} MacOSAll, CocoaAll,{$ENDIF}
{$IFDEF LCLCocoa}SysCtl, {$IFDEF DARKMODE}nsappkitext, {$ENDIF}{$IFDEF NewCocoa} UserNotification,{$ENDIF} {$ENDIF}
{$IFDEF UNIX}Process,{$ELSE} Windows,{$ENDIF}
{$WARN 5024 OFF}LazVersion,{$WARN 5024 ON}
ctypes, resize, ustat, tiff2nifti, //LCLMessageGlue,
lcltype, GraphType, Graphics, dcm_load, crop, intensityfilter,
LCLIntf, slices2D, StdCtrls, SimdUtils, Classes, SysUtils, Forms, Controls,clipbrd,
Dialogs, Menus, ExtCtrls, CheckLst, ComCtrls, Spin, Types, fileutil, ulandmarks, nifti_types,
nifti_hdr_view, fsl_calls, math, nifti, niftis, prefs, dcm2nii, strutils, drawVolume, autoroi, VectorMath, LMessages;
const
{$include vers.inc}
//{$IFDEF FASTGZ}
//kVers = '1.2.20210831';
//{$ELSE}
//kVers = '1.2.20210831-';
//{$ENDIF}
type
{ TGLForm1 }
TGLForm1 = class(TForm)
CenterPanel: TPanel;
ClipThickLabel: TLabel;
ClipThickTrack: TTrackBar;
ClusterView: TListView;
GraphMenu: TMenuItem;
GraphScalingMenu: TMenuItem;
GraphSaveMenu: TMenuItem;
GraphOpenMenu: TMenuItem;
GraphMarkerMenu: TMenuItem;
GraphRawMenu: TMenuItem;
GraphDemeanMenu: TMenuItem;
GraphNormalizeMenu: TMenuItem;
GraphNormalize01Menu: TMenuItem;
GraphPercentMenu: TMenuItem;
GraphAddMenu: TMenuItem;
GraphShowHideMenu: TMenuItem;
GraphClearMenu: TMenuItem;
GraphSaveBitmapMenu: TMenuItem;
DisplayCorrelationR: TMenuItem;
DisplayCorrelationZ: TMenuItem;
AfniPrevMenu: TMenuItem;
AfniPopup: TPopupMenu;
LayerAfniBtn: TButton;
AfniNextMenu: TMenuItem;
LayerAfniDrop: TComboBox;
MatCapDrop: TComboBox;
CropMenu1: TMenuItem;
EditPasteMenu: TMenuItem;
AddOverlayClusterMenu: TMenuItem;
GraphDrawingMenu: TMenuItem;
DrawFilledMenu: TMenuItem;
LayerIsLabelMenu: TMenuItem;
AfniDetailsMenu: TMenuItem;
AfniDirMenu: TMenuItem;
LayerClusterMenu: TMenuItem;
ClusterCopyMenu: TMenuItem;
ClusterSaveMenu: TMenuItem;
GraphSaveTxtMenu: TMenuItem;
GraphSaveBmpMenu: TMenuItem;
LayerFindPeakMenu: TMenuItem;
AfniPMenu: TMenuItem;
AfniQMenu: TMenuItem;
GraphOpenAddMenu: TMenuItem;
LayerClusterOptsMenu: TMenuItem;
ImportTIFFFolderMenu: TMenuItem;
LayerClusterMeansMenu: TMenuItem;
DrawIntensityFilterMenu: TMenuItem;
DrawDilateMenu: TMenuItem;
LayerExport8BitMenu: TMenuItem;
DicomDirMenu: TMenuItem;
EdgeMenu2: TMenuItem;
IntensityHistogamMenu: TMenuItem;
GraphSqrtMenu: TMenuItem;
IntensityHistogamOptionsMenu: TMenuItem;
GraphLognMenu: TMenuItem;
GraphLog10Menu: TMenuItem;
MPR4Menu: TMenuItem;
ScriptHaltMenu: TMenuItem;
NimlMenu: TMenuItem;
OpenAFNIMenu: TMenuItem;
ClusterPopUp: TPopupMenu;
GraphPanel: TPanel;
ClusterPanel: TPanel;
GraphPopUp: TPopupMenu;
RemoveSmallClusterMenu: TMenuItem;
ResizeMenu1: TMenuItem;
ReorientMenu1: TMenuItem;
InvalidateTImer: TTimer;
RulerCheck: TCheckBox;
BetterRenderTimer: TTimer;
ClusterGraphSplitter: TSplitter;
ToolsMenu: TMenuItem;
OpenAltasMenu: TMenuItem;
TBSplitter: TSplitter;
LayerWidgetChangeTimer: TTimer;
TopPanel: TPanel;
BottomPanel: TPanel;
AnatDrop: TComboBox;
CreateOverlapImageMenu: TMenuItem;
CreateSubtractionPlotMenu: TMenuItem;
LayerZeroIntensityInvisibleMenu: TMenuItem;
LayerInvertColorMapMenu: TMenuItem;
Smooth2DCheck: TCheckBox;
ZoomBtn: TButton;
LayerOptionsBtn: TButton;
ImportMenu: TMenuItem;
ImportDicomMenu: TMenuItem;
HelpAboutMenu: TMenuItem;
ClrbarMenu: TMenuItem;
ClrbarSep: TMenuItem;
BlackClrbarMenu: TMenuItem;
ExtractBrainMenu: TMenuItem;
LayerUpMenu: TMenuItem;
LayerDownMenu: TMenuItem;
LayerSmoothMenu: TMenuItem;
LayerAdditiveMenu: TMenuItem;
LayerResetBrightnessMenu: TMenuItem;
DrawMenu: TMenuItem;
DrawOpenMenu: TMenuItem;
DrawSaveMenu: TMenuItem;
DrawTransparencyMenu: TMenuItem;
DrawHideMenu: TMenuItem;
DrawTrans25Menu: TMenuItem;
DrawTrans50Menu: TMenuItem;
DrawTrans90Menu: TMenuItem;
DrawColorMenu: TMenuItem;
DrawNoneMenu: TMenuItem;
DrawEraseMenu: TMenuItem;
DrawRedMenu: TMenuItem;
DrawAdvancedMenu: TMenuItem;
DrawGreenMenu: TMenuItem;
DrawBlueMenu: TMenuItem;
DrawOverwriteMenu: TMenuItem;
DrawUndoMenu: TMenuItem;
DrawCloseMenu: TMenuItem;
DrawBinarizeMenu: TMenuItem;
DrawSmoothMenu: TMenuItem;
DrawCloneMenu: TMenuItem;
DrawAutomaticMenu: TMenuItem;
DrawInterpolateMenu: TMenuItem;
DrawInterpolate2Menu: TMenuItem;
DrawInterpolateAxMenu: TMenuItem;
DrawInterpolateCorMenu: TMenuItem;
DrawInterpolateSagMenu: TMenuItem;
DrawDescriptivesMenu: TMenuItem;
LayerFromZeroMenu: TMenuItem;
ApplePrefMenu: TMenuItem;
EditMenu: TMenuItem;
EditCopyMenu: TMenuItem;
FileSepMenu: TMenuItem;
FileExitMenu: TMenuItem;
HelpPrefMenu: TMenuItem;
LayerCloseMenu: TMenuItem;
DisplaySep3: TMenuItem;
DisplayNextMenu: TMenuItem;
DisplayPrevMenu: TMenuItem;
LayerShowHeaderMenu: TMenuItem;
LandmarkMenu: TMenuItem;
LandmarkOpenMenu: TMenuItem;
LandmarkSaveMenu: TMenuItem;
LandmarkAddMenu: TMenuItem;
LandmarkUpdateMenu: TMenuItem;
LandmarkDeleteMenu: TMenuItem;
LandmarkSelectNext: TMenuItem;
LayerNextVolumeMenu: TMenuItem;
LayerPrevVolumeMenu: TMenuItem;
LayerCutoutMenu: TMenuItem;
MenuItem1: TMenuItem;
DisplayAnimateMenu: TMenuItem;
LayerShowBidsMenu: TMenuItem;
ExitFullScreenMenu: TMenuItem;
LayerMaskWithBackgroundMenu: TMenuItem;
MaskMenu: TMenuItem;
MaskDeleteMenu: TMenuItem;
MaskPreserveMenu: TMenuItem;
DrawHintsMenu: TMenuItem;
ImportTIFFMenu: TMenuItem;
RemoveHazeOptionsMenu: TMenuItem;
SaveNIfTIMenu: TMenuItem;
StoreFMRIMenu: TMenuItem;
SmoothMenu: TMenuItem;
TextAndCubeMenu: TMenuItem;
OpenFSLMenu: TMenuItem;
OpenStandardMenu: TMenuItem;
NewWindowMenu: TMenuItem;
AnimateTimer: TTimer;
YokeTimer: TTimer;
YokeMenu: TMenuItem;
DisplaySep2: TMenuItem;
ScriptingPyVersion: TMenuItem;
TransBlackClrbarMenu: TMenuItem;
TransWhiteClrbarMenu: TMenuItem;
WhiteClrbarMenu: TMenuItem;
VisibleClrbarMenu: TMenuItem;
ScriptingNewMenu: TMenuItem;
RemoveHazeMenu: TMenuItem;
OpenRecentMenu: TMenuItem;
MosLabelCheck: TCheckBox;
MosaicText: TMemo;
MosCrossCheck: TCheckBox;
MosOrientDrop: TComboBox;
CutNearBtn: TButton;
CutNoneBtn: TButton;
CutoutBox: TGroupBox;
MosOrientLabel: TLabel;
MosColLabel: TLabel;
MosRowOverlapTrack: TTrackBar;
MosRowLabel: TLabel;
MosaicBox: TGroupBox;
MosColEdit: TSpinEdit;
MosRowEdit: TSpinEdit;
MosColOverlapTrack: TTrackBar;
Y2TrackBar: TTrackBar;
Z2TrackBar: TTrackBar;
YLabel: TLabel;
SliceZoom: TTrackBar;
ZLabel: TLabel;
XTrackBar: TTrackBar;
XLabel: TLabel;
XCoordEdit: TEdit;
CoordLabel: TLabel;
SliceABtn: TButton;
SliceLBtn: TButton;
SliceRBtn: TButton;
SliceSBtn: TButton;
SlicePBtn: TButton;
SliceBox: TGroupBox;
LineColorBtn: TButton;
ClipAziTrack: TTrackBar;
ClipElevTrack: TTrackBar;
AddOverlayMenu: TMenuItem;
DisplaySep: TMenuItem;
DisplayLeftMenu: TMenuItem;
DisplayRightMenu: TMenuItem;
DisplayPosteriorMenu: TMenuItem;
DisplayAnteriorMenu: TMenuItem;
DisplayInferiorMenu: TMenuItem;
DisplaySuperiorMenu: TMenuItem;
LineWidthLabel: TLabel;
LineBox: TGroupBox;
HelpMenu: TMenuItem;
OnlineHelpMenu: TMenuItem;
ScriptOpenDialog: TOpenDialog;
ScriptingMenu: TMenuItem;
ScriptingSepMenu: TMenuItem;
ScriptingSaveMenu: TMenuItem;
ScriptingRunMenu: TMenuItem;
ScriptingTemplatesMenu: TMenuItem;
ScriptingOpenMenu: TMenuItem;
SharpenMenu: TMenuItem;
S2Label: TLabel;
S3Label: TLabel;
S4Label: TLabel;
S5Label: TLabel;
S1Track: TTrackBar;
LightAziTrack: TTrackBar;
QLabel: TLabel;
LightLabel: TLabel;
LightElevTrack: TTrackBar;
S1Label: TLabel;
S2Track: TTrackBar;
S3Track: TTrackBar;
S4Track: TTrackBar;
S6Label: TLabel;
S7Label: TLabel;
S8Label: TLabel;
S9Label: TLabel;
S10Label: TLabel;
S5Track: TTrackBar;
S6Track: TTrackBar;
S7Track: TTrackBar;
S8Track: TTrackBar;
S9Track: TTrackBar;
S10Track: TTrackBar;
ShaderDrop: TComboBox;
LayerAlphaLabel: TLabel;
ClipDepthLabel: TLabel;
ClipDepthTrack: TTrackBar;
ClipAziLabel: TLabel;
ClipElevLabel: TLabel;
LayerColorDrop: TComboBox;
LayerDarkEdit: TEdit;
LayerBrightEdit: TEdit;
LayerDarkLabel: TLabel;
LayerBrightLabel: TLabel;
LayerList: TCheckListBox;
ColorDialog1: TColorDialog;
ClipBox: TGroupBox;
LayerPopup: TPopupMenu;
ScriptMemo: TMemo;
ScriptOutputMemo: TMemo;
ScriptBox: TGroupBox;
ScriptPanel: TPanel;
ShaderBox: TGroupBox;
LayerBox: TGroupBox;
MainMenu: TMainMenu;
FileMenu: TMenuItem;
ResetDefaultsMenu: TMenuItem;
DisplayMenu: TMenuItem;
CoronalMenu: TMenuItem;
ColorMenu: TMenuItem;
BackColorMenu: TMenuItem;
ColorEditorMenu: TMenuItem;
LineWidthEdit: TSpinEdit;
SliceIBtn: TButton;
YCoordEdit: TEdit;
ZCoordEdit: TEdit;
ScriptSplitter: TSplitter;
ToolPanel: TScrollBox;
SagittalLMenu: TMenuItem;
MosaicMenu: TMenuItem;
SagittalMenu: TMenuItem;
MPRMenu: TMenuItem;
RenderMenu: TMenuItem;
AxialMenu: TMenuItem;
SaveDialog1: TSaveDialog;
SaveMenu: TMenuItem;
AppleMenu: TMenuItem;
AboutMenu: TMenuItem;
OpenDialog1: TOpenDialog;
LeftSplitter: TSplitter;
RightSplitter: TSplitter;
LayerAlphaTrack: TTrackBar;
QualityTrack: TTrackBar;
UpdateTimer: TTimer;
ViewMenu: TMenuItem;
OpenMenu: TMenuItem;
X2TrackBar: TTrackBar;
YTrackBar: TTrackBar;
ZTrackBar: TTrackBar;
procedure AfniPMenuClick(Sender: TObject);
procedure AfniQMenuClick(Sender: TObject);
procedure CenterPanelClick(Sender: TObject);
procedure DicomDirMenuClick(Sender: TObject);
procedure DrawIntensityFilterMenuClick(Sender: TObject);
procedure GetHistogramPrefs(var bins: integer; var mn, mx: single; var isClampExtremeValues, isIgnoreZeros: boolean);
procedure IntensityHistogamMenuClick(Sender: TObject);
function DoG(layer: integer): boolean;
procedure EdgeMenuClick(Sender: TObject);
procedure FormChangeBounds(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormShortCut(var Msg: TLMKey; var Handled: Boolean);
function HasLabelLayer: boolean;
procedure ClusterSaveClick(Sender: TObject);
procedure ClusterViewColumnClick(Sender: TObject; Column: TListColumn);
procedure ClusterViewCompare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
procedure AddOverlayClusterMenuClick(Sender: TObject);
procedure AfniDetailsMenuClick(Sender: TObject);
procedure AfniDirMenuClick(Sender: TObject);
procedure BetterRenderTimerTimer(Sender: TObject);
procedure ClusterByMenuClick(Sender: TObject);
procedure ClusterViewMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ClusterViewSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure EditPasteMenuClick(Sender: TObject);
function DefaultImage():string;
procedure FormCreate(Sender: TObject);
procedure GraphPanelResize(Sender: TObject);
procedure GraphPanelShow();
procedure ImportTIFFFolderMenuClick(Sender: TObject);
procedure InvalidateTImerTimer(Sender: TObject);
procedure LayerAfniBtnClick(Sender: TObject);
procedure LayerAfniDropClick(Sender: TObject);
procedure LayerClusterMenuClick(Sender: TObject);
procedure LayerContrastChange(Sender: TObject);
procedure GraphDrawingMenuClick(Sender: TObject);
procedure LayerExport8BitMenuClick(Sender: TObject);
procedure LayerFindPeakMenuClick(Sender: TObject);
procedure LayerIsLabelMenuClick(Sender: TObject);
procedure LayerSmoothMenuClick(Sender: TObject);
procedure DrawDilateMenuClick(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure NimlMenuClick(Sender: TObject);
procedure RemoveSmallClusterMenuClick(Sender: TObject);
procedure RulerVisible();
procedure RulerCheckChange(Sender: TObject);
procedure ScriptHaltMenuClick(Sender: TObject);
procedure ScriptingPyVersionClick(Sender: TObject);
procedure ScriptingSepMenuClick(Sender: TObject);
procedure UpdateCropMask(msk: TVec6);
procedure CreateOverlapImageMenuClick(Sender: TObject);
procedure CreateSubtractionPlotMenuClick(Sender: TObject);
procedure ApplyCrop(crop: TVec6i; cropVols: TPoint);
procedure CropMenuClick(Sender: TObject);
procedure DisplayCorrelationRClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: char);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure GraphMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure GraphMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
procedure GraphAddMenuClick(Sender: TObject);
procedure GraphClearMenuClick(Sender: TObject);
procedure GraphMarkerMenuClick(Sender: TObject);
procedure GraphOpenMenuClick(Sender: TObject);
function GraphOpen(fnm: string; isKeepOldGraph: boolean = false; isShowMessageOnError: boolean = false): boolean;
procedure GraphSaveBitmapMenuClick(Sender: TObject);
procedure GraphSaveMenuClick(Sender: TObject);
procedure GraphScaleClick(Sender: TObject);
procedure GraphShowHideMenuClick(Sender: TObject);
procedure LayerInvertColorMapMenuClick(Sender: TObject);
procedure LayerWidgetChangeTimerTimer(Sender: TObject);
procedure LayerZeroIntensityInvisibleMenuClick(Sender: TObject);
procedure MatCapDropChange(Sender: TObject);
procedure ReorientMenuClick(Sender: TObject);
procedure ReportPositionXYZ(isUpdateYoke: boolean = false);
procedure AnatAddBtnClick(Sender: TObject);
procedure AnatDeleteBtnClick(Sender: TObject);
procedure AnatDropChange(Sender: TObject);
procedure AnatSaveBtnClick(Sender: TObject);
procedure AnatUpdate();
function OpenDialogExecute (lFilter,lCaption: string): TStringList;
function OpenDialogExecute1 (lFilter,lCaption: string): String;
procedure AnatOpenBtnClick(Sender: TObject);
procedure AnatUpdateBtnClick(Sender: TObject);
procedure AnimateTimerTimer(Sender: TObject);
procedure CreateStandardMenus (ParentMenu: TMenuItem);
procedure DisplayAnimateMenuClick(Sender: TObject);
function Active4DLayer: integer;
function DisplayNextMenuClick(Sender: TObject): boolean;
procedure DrawHintsMenuClick(Sender: TObject);
procedure EditCopyMenuClick(Sender: TObject);
procedure UpdateColorBar;
procedure ExitFullScreenMenuClick(Sender: TObject);
procedure FileExitMenuClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure ImportTIFFMenuClick(Sender: TObject);
procedure LandmarkSelectNextClick(Sender: TObject);
procedure LayerCloseMenuClick(Sender: TObject);
procedure AfniNextClick(Sender: TObject);
procedure LayerListClickCheck(Sender: TObject);
procedure LayerListShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure LayerMaskWithBackgroundMenuClick(Sender: TObject);
procedure LayerOptionsBtnClick(Sender: TObject);
procedure LayerShowBidsMenuClick(Sender: TObject);
procedure LayerShowHeaderMenuClick(Sender: TObject);
procedure LayerVolumeChange(Sender: TObject);
procedure MaskMenuClick(Sender: TObject);
procedure MouseGesturesMenu(Sender: TObject);
procedure OpenFSLMenuClick(Sender: TObject);
procedure Quit2TextEditor;
procedure DrawAutomaticMenuClick(Sender: TObject);
procedure DrawBinarizeMenuClick(Sender: TObject);
procedure DrawCloneMenuClick(Sender: TObject);
procedure DrawCloseMenuClick(Sender: TObject);
procedure DrawDescriptivesMenuClick(Sender: TObject);
procedure DrawSmoothMenuClick(Sender: TObject);
procedure DrawUndoMenuClick(Sender: TObject);
procedure EnsureOpenVoi();
procedure ClrbarClr(i: integer);
procedure InterpolateDrawMenuClick(Sender: TObject);
procedure LayerFromZeroMenuClick(Sender: TObject);
procedure HelpPrefMenuClick(Sender: TObject);
procedure ResizeMenuClick(Sender: TObject);
procedure SaveMosaicBmp(bmpName: string);
procedure DrawSaveMenuClick(Sender: TObject);
function Save2Bmp(fnm: string): boolean;
procedure DrawOpenMenuClick(Sender: TObject);
procedure DrawTool1Click(Sender: TObject);
procedure DrawTransClick(Sender: TObject);
procedure ExtractBrainMenuClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure LayerAdditiveMenuClick(Sender: TObject);
procedure LayerPopupPopup(Sender: TObject);
procedure LayerMoveUpOrDown(layer: integer; isMoveDown:boolean);
procedure LayerResetBrightnessMenuClick(Sender: TObject);
procedure LayerUpDownClick(Sender: TObject);
procedure NewWindowMenuClick(Sender: TObject);
function NiftiSaveDialogFilename(isVOI: boolean = false; initialFilename: string = ''): string;
procedure SaveNIfTIMenuClick(Sender: TObject);
procedure ClipIntensity(Lo, Hi: single);
procedure ScriptMemoKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ScriptPanelDblClick(Sender: TObject);
procedure SetColorBarPosition;
procedure SliceZoomChange(Sender: TObject);
procedure SmoothCheckChange(Sender: TObject);
procedure SmoothMenuClick(Sender: TObject);
procedure StoreFMRIMenuClick(Sender: TObject);
procedure TextAndCubeMenuClick(Sender: TObject);
procedure ViewGPUgPrepare(Sender: TObject);
procedure ToolPanelDblClick(Sender: TObject);
procedure SaveColorTable;
procedure ClrbarVisibleClick(Sender: TObject);
procedure CoordEditChange(Sender: TObject);
procedure CutNearBtnClick(Sender: TObject);
procedure CutNoneBtnClick(Sender: TObject);
{$IFDEF DARKMODE}
procedure SetFormDarkMode(f: TForm);
procedure SetDarkMode();
{$ENDIF}
procedure SetToolPanelMaxWidth();
function ClusterOpen(fnm: string): boolean;
procedure DisplayViewMenu(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure ImportDicomMenuClick(Sender: TObject);
procedure LayerAlphaTrackMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure LayerChange(layer, colorTag, opacityPercent: integer; displayMin, displayMax: single);
procedure LayerListSelectionChange(Sender: TObject; User: boolean);
procedure LayerWidgetChange(Sender: TObject);
procedure LineColorBtnClick(Sender: TObject);
//procedure LineColorOpacityTrackChange(Sender: TObject);
procedure LineWidthEditChange(Sender: TObject);
procedure MosaicTextChange(Sender: TObject);
procedure OrientBtnClick(Sender: TObject);
procedure RemoveHazeMenuClick(Sender: TObject);
procedure ScriptingNewMenuClick(Sender: TObject);
procedure ClrbarMenuClick(Sender: TObject);
procedure UpdateMosaic(Sender: TObject);
procedure OnlineHelpMenuClick(Sender: TObject);
procedure OpenScript(scriptname: string; isShowScriptPanel: boolean = true);
procedure AddOverlayMenuClick(Sender: TObject);
procedure ScriptingOpenMenuClick(Sender: TObject);
procedure ScriptingRunMenuClick(Sender: TObject);
procedure ScriptingSaveMenuClick(Sender: TObject);
procedure ScriptingTemplatesMenuClick(Sender: TObject);
procedure ScriptFormVisible(vis: boolean);
procedure MakeList(var c: TClusters);
procedure UpdateLayerBox(NewLayers: boolean; NewVolumes: boolean = false);
function AddLayer(Filename: string): boolean;
procedure UpdateContrast (Xa,Ya, Xb, Yb: integer);
function AddBackground(Filename: string; isAddToRecent: boolean = true; isFromFormDrop: boolean = false): boolean;
procedure AboutMenuClick(Sender: TObject);
procedure BackColorMenuClick(Sender: TObject);
procedure ClipLabelClick(Sender: TObject);
procedure ColorEditorMenuClick(Sender: TObject);
procedure LayerContrastKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure UpdateVisibleBoxes(setMenuChecked: boolean = false);
procedure SetDisplayCheck();
procedure UpdateOpenRecent();
procedure OptimalMosaicPixels(out w,h: integer);
procedure AddOpenRecent(Filename: string);
procedure ResetDefaultsClick(Sender: TObject);
procedure DisplayMenuClick(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
//procedure FormResize(Sender: TObject);
procedure PrefTrackChange(Sender: TObject);
procedure GraphPaint(Sender: TObject);
procedure GraphShow();
procedure ShaderDropChange(Sender: TObject);
procedure SharpenMenuClick(Sender: TObject);
//procedure SplitterMoved(Sender: TObject);
procedure SaveMenuClick(Sender: TObject);
procedure SetXHairPosition (lXmm,lYmm,lZmm: single; isUpdateYoke: boolean = false);
procedure UpdateShaderSettings(Sender: TObject);
procedure UpdateTimerTimer(Sender: TObject);
procedure ViewGPUMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure ViewGPUMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure ViewGPUMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure OpenMenuClick(Sender: TObject);
//procedure ShaderMenuClick(Sender: TObject);
//procedure LayerColorDropChange(Sender: TObject);
procedure PickRenderDepth( X, Y: Integer);
procedure ViewGPUMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure ParamStr2Script();
procedure ViewGPUPrepare(Sender: TObject);
procedure ViewGPUPaint(Sender: TObject);
procedure ViewGPUDblClick(Sender: TObject);
procedure ViewGPUKeyPress(Sender: TObject; var Key: char);
procedure ViewGPUKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ViewGPUKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ViewGPUgKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ViewGPUgResize(Sender: TObject);
procedure setShaderSliders;
procedure CutoutChange(Sender: TObject);
procedure OpenRecentMenuClick(Sender: TObject);
procedure OpenStandardMenuClick(Sender: TObject);
procedure CutoutMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure LayerColorFromZero(Layer: integer; IsFromZero: boolean);
function SliceFrac : TVec3;
procedure SetRetina;
{$IFDEF MYPY}
function PyCreate: boolean;
function PyExec(): boolean;
{$IFDEF PY4LAZ}
procedure PyEngineAfterInit(Sender: TObject);
procedure PyIOSendData(Sender: TObject; const Data: AnsiString);
procedure PyIOSendUniData(Sender: TObject; const Data: UnicodeString);
procedure PyModInitialization(Sender: TObject);
{$ELSE}
procedure GotPythonData(str: UnicodeString);
{$ENDIF}
{$ENDIF}
procedure YokeMenuClick(Sender: TObject);
procedure YokeTimerTimer(Sender: TObject);
procedure voiUndo(isRefresh: boolean = false);
procedure SampleAlongLine(startMM, endMM: TVec3);
procedure MorphologyFill(Origin: TVec3; dxOrigin, radiusMM: int64; drawMode: int64);
procedure DrawIntensityFilter(rampAbove, rampBelow, drawMode: integer);
procedure ForceOverlayUpdate();
procedure ZoomBtnClick(Sender: TObject);
private
//
end;
var
GLForm1: TGLForm1;
implementation
{$R *.lfm}
{$IFDEF METALAPI}
const kExt = '.metal';
{$ELSE}
uses
{$IFDEF GRAPH}glgraph,{$ENDIF}
{$IFDEF COREGL}glcorearb,{$ELSE}{$IFNDEF Darwin}gl, {macos has macgl }{$ENDIF} glext,
{$ENDIF}
{$IFDEF LCLCocoa}glcocoanscontext,{$ENDIF}{$IFDEF CLRBAR}glclrbar, {$ENDIF}
{$IFDEF RETINA}retinahelper,{$ENDIF}
OpenGLContext, glvolume2, gl_core_utils {$IFDEF MYPY}{$IFDEF PY4LAZ}{$IFNDEF UNIX}, proc_py {$ENDIF}{$ENDIF}{$ENDIF};
const kExt = '.glsl';
{$ENDIF}
const
kNaNsingle: single = 1/0;
kNaN : double = 1/0;
{$IFDEF UNIX} //end of line
kEOLN = #10;
{$ELSE}
kEOLN = #13#10; //Windows CRLF
{$ENDIF}
kTab = #9;
var
gPrefs: TPrefs;
gPyRunning: boolean = false;
gMouseLimitLo, gMouseLimitHi : TPoint;
gMouse : TPoint = (x: -1; y: -1);
gMouseDrag: boolean = false;
gSliceMM : TVec3 = (x: 0; y: 0; z: 0);
Vol1: TGPUVolume;
isBusy: boolean = false;
isBusyCore: boolean = false;
vols: TNIfTIs;
gLandmark : TLandmark;
{$IFDEF METALAPI}
//isFormShown: boolean = false;
isPrepared: boolean = false;
ViewGPU1: TMetalControl;
{$IFDEF GRAPH}ViewGPUg: TMetalControl;{$ENDIF}
{$ELSE}
ViewGPU1: TOpenGLControl;
{$IFDEF GRAPH}ViewGPUg: TOpenGLControl;{$ENDIF}
{$ENDIF}
{$IFDEF GRAPH}gGraph: TGPUGraph;{$ENDIF}
{$IFDEF CLRBAR}gClrbar: TGPUClrbar;{$ENDIF}
{$IFDEF LCLCocoa}{$IFNDEF METALAPI}
{$DEFINE isCocoaOpenGL}
{$ENDIF}{$ENDIF}
{$IFDEF DBUG}
procedure DebugLn(str: string); //2022
begin
{$IFDEF UNIX}
writeln(str);
{$ENDIF}
end;
{$ENDIF}
procedure GenerateClustersCore(var v: TNIfTI; thresh, mm: single; method: integer; isDarkAndBright: boolean);
var
i: integer = 0;
v2: TNIfTI;
begin
GLForm1.ClusterView.tag := -1;
if (v.IsLabels) or (GLForm1.LayerList.Count < 2) then begin
//either atlas or only image loaded
v.GenerateClusters(thresh, mm, gPrefs.ClusterNeighborMethod, isDarkAndBright);
//GLForm1.ClusterView.visible := true;
exit;
end;
//not an atlas... see if one is loaded
v2 := nil;
while (i < GLForm1.LayerList.Count) and (v2 = nil) do begin
if not vols.Layer(i,v2) then exit;
if not v2.IsLabels then
v2 := nil;
i := i + 1;
end;
v.GenerateClusters(v2, thresh, mm, method, isDarkAndBright); //v2 is either nil or a label map
//GLForm1.ClusterView.visible := (v2 <> nil);
end;
var isDescending: boolean = false;
procedure TGLForm1.ClusterViewColumnClick(Sender: TObject; Column: TListColumn);
//https://www.delphitips.net/2008/04/10/sort-listview-by-clicking-on-columns/
var
i: integer;
begin
ClusterView.SortColumn := Column.Index;
//ClusterView.AutoSortIndicator:= true;
//Descending := not Descending;
isDescending := not isDescending;
//{$ifndef windows} //next lines require trunk or Lazarus >= 2.0.8
//{$IFDEF (LCL_FULLVERSION > 2080600)}
{$IF laz_fullversion >= 2000800}
for i := 0 to (ClusterView.ColumnCount -1) do begin
if (i = Column.Index) then continue;
ClusterView.Column[i].SortIndicator:= siNone;
end;
if isDescending then
ClusterView.Column[Column.Index].SortIndicator:= siDescending
else
ClusterView.Column[Column.Index].SortIndicator:= siAscending;
{$ENDIF}
//ClusterView.SortType := stData; //so
if ClusterView.SortDirection = sdDescending then
ClusterView.SortDirection := sdAscending
else
ClusterView.SortDirection := sdDescending;
end;
procedure TGLForm1.ClusterSaveClick(Sender: TObject);
var
contents,row: ansistring;
column: TListColumn;
item: TListItem;
i, j: integer;
dlg : TSaveDialog;
Txt: TextFile;
niftiVol: TNIfTI;
begin
contents := '';
row := '';
contents := 'MRIcroGL '+kVers+kEOLN;
//if vols.Layer(GLForm1.LayerList.ItemIndex,niftiVol) then
if vols.Layer(ClusterView.tag,niftiVol) then
contents += 'Notes: '+niftiVol.clusterNotes+kEOLN;
// header
for i := 0 to ClusterView.Columns.Count - 1 do
begin
column := TListColumn(ClusterView.Columns[i]);
if not column.Visible then
continue;
row += column.Caption;
if i < ClusterView.Columns.Count - 1 then
row += kTab;
end;
contents += row+kEOLN;
// items
for i := 0 to ClusterView.Items.Count - 1 do
begin
item := TListItem(ClusterView.Items[i]);
row := '';
for j := 0 to item.SubItems.Count do
begin
column := TListColumn(ClusterView.Columns[j]);
if not column.Visible then
continue;
if j = 0 then
row += item.Caption
else
row += item.SubItems[j - 1];
if j < item.SubItems.Count then
row += kTab;
end;
contents += row;
if i < ClusterView.Items.Count - 1 then
contents += kEOLN;
end;
if (Sender as TMenuItem).tag = 0 then begin
Clipboard.AsText:= contents;
exit;
end;
dlg := TSaveDialog.Create(self);
dlg.Title := 'Save table';
dlg.InitialDir := GetUserDir;//GetUserDir;
{$IFDEF Darwin}
if PosEx('.app', dlg.InitialDir) > 0 then
dlg.InitialDir := HomeDir(false);
{$ENDIF}
dlg.Filter := 'Text|*.txt';
dlg.DefaultExt := '.txt';
dlg.FilterIndex := 0;
if not dlg.Execute then begin
dlg.Free;
exit;
end;
AssignFile(Txt, dlg.FileName);
Rewrite(Txt);
WriteLn(Txt, contents);
CloseFile(Txt);
dlg.Free;
end;
{$IFDEF AFNI}
function AFNIjvLabel(statCode: integer): string;
begin
case statCode of
kFUNC_COR_TYPE: result := 'Correl';//// Correlation Coeff # Samples, # Fit Param, # Orts
kFUNC_TT_TYPE: result := 'T';// Student t Degrees-of-Freedom (DOF)
kFUNC_FT_TYPE: result := 'F';// F ratio Numerator DOF, Denominator DOF
kFUNC_ZT_TYPE: result := 'Normal';// Standard Normal -- none --
kFUNC_CT_TYPE: result := 'Chi';// Chi-Squared DOF
kFUNC_BT_TYPE: result := 'Beta';// Incomplete Beta Parameters "a" and "b"
kFUNC_BN_TYPE: result := 'Binomial';// # Trials, Probability per trial
kFUNC_GT_TYPE: result := 'Gamma';// Shape, Scale
kFUNC_PT_TYPE: result := 'Poisson';
else result := 'Other'
end;
end;
{$ENDIF}
function GetFloat(prompt: string; min,def,max: double): double;
var
PrefForm: TForm;
CancelBtn,OkBtn: TButton;
promptLabel: TLabel;
valEdit: TEdit;
begin
PrefForm:=TForm.Create(nil);
//PrefForm.SetBounds(100, 100, 512, 212);
PrefForm.AutoSize := True;
PrefForm.BorderWidth := 8;
PrefForm.Caption:='Value required';
PrefForm.Position := poScreenCenter;
PrefForm.BorderStyle := bsDialog;
//label
promptLabel:=TLabel.create(PrefForm);
promptLabel.Caption:= prompt;
if (min < max) then
promptLabel.Caption:= format('%s (range %0.3g..%0.3g)', [prompt, min, max]);
//promptLabel.Left := 8;
//promptLabel.Top := 12;
promptLabel.AutoSize := true;
promptLabel.AnchorSide[akTop].Side := asrTop;
promptLabel.AnchorSide[akTop].Control := PrefForm;
promptLabel.BorderSpacing.Top := 6;
promptLabel.AnchorSide[akLeft].Side := asrLeft;
promptLabel.AnchorSide[akLeft].Control := PrefForm;
promptLabel.BorderSpacing.Left := 6;
promptLabel.Parent:=PrefForm;
//edit
valEdit:=TEdit.create(PrefForm);
valEdit.Caption := FloatToStrF(def, ffGeneral, 8, 4);
//valEdit.Top := 42;
//valEdit.Width := PrefForm.Width - 16;
valEdit.Constraints.MinWidth:= 300;
valEdit.AutoSize := true;
valEdit.AnchorSide[akTop].Side := asrBottom;
valEdit.AnchorSide[akTop].Control := promptLabel;
valEdit.BorderSpacing.Top := 6;
valEdit.AnchorSide[akLeft].Side := asrLeft;
valEdit.AnchorSide[akLeft].Control := PrefForm;
valEdit.BorderSpacing.Left := 6;
valEdit.Parent:=PrefForm;
//Cancel Btn
CancelBtn:=TButton.create(PrefForm);
CancelBtn.Caption:='Cancel';
CancelBtn.AutoSize := true;
CancelBtn.AnchorSide[akTop].Side := asrBottom;
CancelBtn.AnchorSide[akTop].Control := valEdit;
CancelBtn.BorderSpacing.Top := 6;
CancelBtn.AnchorSide[akLeft].Side := asrLeft;
CancelBtn.AnchorSide[akLeft].Control := PrefForm;
CancelBtn.BorderSpacing.Left := 200;
CancelBtn.Parent:=PrefForm;
CancelBtn.ModalResult:= mrCancel;
//OK button
OkBtn:=TButton.create(PrefForm);
OkBtn.Caption:='OK';
OkBtn.AutoSize := true;
OkBtn.AnchorSide[akTop].Side := asrBottom;
OkBtn.AnchorSide[akTop].Control := valEdit;
OkBtn.BorderSpacing.Top := 6;
OkBtn.AnchorSide[akLeft].Side := asrRight;
OkBtn.AnchorSide[akLeft].Control := CancelBtn;
OkBtn.BorderSpacing.Left := 6;
OkBtn.Parent:=PrefForm;
OkBtn.ModalResult:= mrOK;
//OK button
{$IFDEF DARKMODE}
if gPrefs.DarkMode then GLForm1.SetFormDarkMode(PrefForm);
{$ENDIF}
PrefForm.ShowModal;
result := kNaN;
if (PrefForm.ModalResult = mrOK) then begin
result := StrToFloatDef(valEdit.Caption, def);
if (min < max) and (result < min) then
result := min;
if (min < max) and (result > max) then
result := max;
end;
FreeAndNil(PrefForm);
end; //GetFloat()
procedure TGLForm1.AfniPMenuClick(Sender: TObject);
{$IFDEF AFNI}
var
v: TNIfTI;
jv: integer;
s: string;
df0, df1, p, thresh: double;
begin
vols.Layer(LayerList.ItemIndex,v);
if v = nil then exit;
if length(v.afnis) < v.VolumeDisplayed then exit;
jv := v.afnis[v.VolumeDisplayed].jv;
s := AFNIjvLabel(jv);
if (jv <> kFUNC_TT_TYPE) and (jv <> kFUNC_FT_TYPE) then begin
showmessage('Current version only supports p-values for T and F tests, not "'+s+'"');
exit;
end;
df0 := v.afnis[v.VolumeDisplayed].param[0];
df1 := v.afnis[v.VolumeDisplayed].param[1];
if jv = kFUNC_TT_TYPE then
s := format('%s (%d)', [s, round(df0)])
else
s := format('%s (%d,%d)', [s, round(df0), round(df1)]);
p := GetFloat('Threshold at uncorrected p-value for '+s, 0,0.05,0);
if jv = kFUNC_TT_TYPE then begin
p := p / 2; //2 tails
thresh := inverset(p, df0); //pTdistrInv(round(df0), p);
end else
thresh := inversef(p, round(df0), round(df1));//pFdistrInv(round(df0), round(df1), p);
LayerChange(LayerList.ItemIndex, -1, -1, thresh, thresh);
end;
{$ELSE}
begin
showmessage('Not compiled with AFNI support');