Skip to content

Commit

Permalink
Scripting COLORBARSIZE() #20
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Apr 11, 2018
1 parent 2bd0de4 commit e311507
Show file tree
Hide file tree
Showing 14 changed files with 510 additions and 255 deletions.
5 changes: 3 additions & 2 deletions MRIcroGL.app/Contents/Resources/script/a1.gls
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const
pth = '/Users/rorden/Downloads/thresh/';
begin
//RESETDEFAULTS;
//LOADIMAGE(pth+'mni152_2009bet.nii');
MOSAIC('L+ 0 ,30');
//LOADIMAGE(pth+'mni152_2009bet.nii');
colorbarsize(0.1);
//MOSAIC('L+ 0 ,30');



Expand Down
15 changes: 14 additions & 1 deletion commandsu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ procedure CLIPAZIMUTHELEVATION (DEPTH,AZI,ELEV: single);
procedure CLIPFORMVISIBLE (VISIBLE: boolean);
procedure COLORBARCOORD (L,T,R,B: single);
procedure COLORBARPOSITION (P: integer);
procedure COLORBARSIZE (F: single);
procedure COLORBARFORMVISIBLE (VISIBLE: boolean);
procedure COLORBARTEXT (VISIBLE: boolean);
procedure COLORBARVISIBLE (VISIBLE: boolean);
Expand Down Expand Up @@ -115,7 +116,7 @@ procedure QUIT;//new
(Ptr:@OVERLAYLOADCLUSTER;Decl:'OVERLAYLOADCLUSTER';Vars:'(lFilename: string; lThreshold, lClusterMM3: single; lSaveToDisk: boolean): integer'),

(Ptr:@OVERLAYLOADVOL;Decl:'OVERLAYLOADVOL';Vars:'(lFilename: string; lVol: integer): integer'));
knProc = 84;
knProc = 85;
kProcRA : array [1..knProc] of TScriptRec =
(
(Ptr:@AZIMUTH;Decl:'AZIMUTH';Vars:'(DEG: integer)'),
Expand All @@ -130,6 +131,7 @@ procedure QUIT;//new
(Ptr:@CLIPFORMVISIBLE;Decl:'CLIPFORMVISIBLE';Vars:'(VISIBLE: boolean)'),
(Ptr:@COLORBARCOORD;Decl:'COLORBARCOORD';Vars:'(L,T,R,B: single)'),
(Ptr:@COLORBARPOSITION;Decl:'COLORBARPOSITION';Vars:'(P: integer)'),
(Ptr:@COLORBARSIZE;Decl:'COLORBARSIZE';Vars:'(F: single)'),
(Ptr:@ADDNODE;Decl:'ADDNODE';Vars:'(INTENSITY, R,G,B,A: byte)'),
(Ptr:@COLORBARFORMVISIBLE;Decl:'COLORBARFORMVISIBLE';Vars:'(VISIBLE: boolean)'),
(Ptr:@COLORBARTEXT;Decl:'COLORBARTEXT';Vars:'(VISIBLE: boolean)'),
Expand Down Expand Up @@ -530,6 +532,17 @@ procedure COLORBARPOSITION(P: integer);
ReRender(false);
end;

procedure COLORBARSIZE (F: single);
begin
if (F < 0.0099) or (F > 0.50001) then begin
ScriptForm.Memo2.Lines.Add('COLORBARSIZE should be a value between 0.01 and 0.5');
exit;
end;
gPrefs.ColorbarSize:= F;
gClrbar.SizeFraction := F;
ReRender(false);
end;

procedure COLORBARCOORD (L,T,R,B: single);
begin
ScriptForm.Memo2.Lines.Add('COLORBARCOORD replaced with COLORBARPOSITION');
Expand Down
46 changes: 24 additions & 22 deletions dcm_load.pas
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ function dcmList(dcm2niixExe, dicomDir: string): TStringList;
hProcess.Free;
end;


function HomeDir: string; //set path to home if not provided
{$IFDEF UNIX}
begin
result := expandfilename('~/');
end;
{$ELSE}
var
SpecialPath: PWideChar;
begin
Result := '';
SpecialPath := WideStrAlloc(MAX_PATH);
try
FillChar(SpecialPath^, MAX_PATH, 0);
if SHGetSpecialFolderPathW(0, SpecialPath, CSIDL_PERSONAL, False) then
Result := SpecialPath+pathdelim;
finally
StrDispose(SpecialPath);
end;
end;
{$ENDIF}

function dcmSeriesSelectForm(dcm2niixExe, dicomDir: string): string;
const
kMaxItems = 16;
Expand All @@ -117,7 +139,8 @@ function dcmSeriesSelectForm(dcm2niixExe, dicomDir: string): string;
end;
PrefForm:=TForm.Create(nil);
PrefForm.SetBounds(100, 100, 520, 212);
PrefForm.Caption:='DICOM Loading '+dcm2niixExe;
//PrefForm.Caption:='DICOM Loading '+dcm2niixExe;
PrefForm.Caption:='Save converted images to '+HomeDir;
PrefForm.Position := poScreenCenter;
PrefForm.BorderStyle := bsDialog;
{$IFNDEF FPC}PrefForm.AutoSize := true;{$ENDIF}
Expand Down Expand Up @@ -157,27 +180,6 @@ function dcmSeriesSelectForm(dcm2niixExe, dicomDir: string): string;
dcmStrings.Free;
end; // PrefMenuClick()

function HomeDir: string; //set path to home if not provided
{$IFDEF UNIX}
begin
result := expandfilename('~/');
end;
{$ELSE}
var
SpecialPath: PWideChar;
begin
Result := '';
SpecialPath := WideStrAlloc(MAX_PATH);
try
FillChar(SpecialPath^, MAX_PATH, 0);
if SHGetSpecialFolderPathW(0, SpecialPath, CSIDL_PERSONAL, False) then
Result := SpecialPath+pathdelim;
finally
StrDispose(SpecialPath);
end;
end;
{$ENDIF}

function findNiiFile(baseName: string): string;
//if baseName '~/d/img.nii' does not exist but '~/d/img_e1.nii' does
var
Expand Down
91 changes: 46 additions & 45 deletions mainunit.lfm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object GLForm1: TGLForm1
Left = 248
Left = 108
Height = 787
Top = 23
Width = 1032
Expand All @@ -25,20 +25,21 @@ object GLForm1: TGLForm1
Top = 0
Width = 216
Align = alLeft
BevelOuter = bvNone
ClientHeight = 787
ClientWidth = 216
ParentFont = False
TabOrder = 0
OnClick = ToolPanelClick
object ClipBox: TGroupBox
Left = 1
Left = 0
Height = 92
Top = 125
Width = 214
Top = 124
Width = 216
Align = alTop
Caption = 'Clipping'
ClientHeight = 70
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 0
object Label4: TLabel
Expand Down Expand Up @@ -104,22 +105,22 @@ object GLForm1: TGLForm1
end
end
object ShaderBox: TGroupBox
Left = 1
Height = 80
Top = 706
Width = 214
Left = 0
Height = 82
Top = 705
Width = 216
Align = alClient
Caption = 'Shader'
ClientHeight = 58
ClientWidth = 206
ClientHeight = 60
ClientWidth = 208
ParentFont = False
TabOrder = 1
OnResize = ShaderBoxResize
object ShaderMemo: TMemo
Left = 0
Height = 0
Top = 58
Width = 206
Top = 60
Width = 208
Align = alClient
Lines.Strings = (
'Memo1'
Expand Down Expand Up @@ -304,11 +305,11 @@ object GLForm1: TGLForm1
Left = 0
Height = 120
Top = 0
Width = 206
Width = 208
Align = alTop
BevelOuter = bvNone
ClientHeight = 120
ClientWidth = 206
ClientWidth = 208
TabOrder = 1
object ShaderDrop: TComboBox
Left = 2
Expand Down Expand Up @@ -742,14 +743,14 @@ object GLForm1: TGLForm1
end
object IntensityBox: TGroupBox
Tag = 270
Left = 1
Left = 0
Height = 50
Top = 1
Width = 214
Top = 0
Width = 216
Align = alTop
Caption = 'Intensity Minimum..Maximum'
ClientHeight = 28
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 2
object MinEdit: TEdit
Expand Down Expand Up @@ -777,14 +778,14 @@ object GLForm1: TGLForm1
end
end
object CutoutBox: TGroupBox
Left = 1
Left = 0
Height = 92
Top = 476
Width = 214
Top = 475
Width = 216
Align = alTop
Caption = 'Cutout'
ClientHeight = 70
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 3
object Xx: TLabel
Expand Down Expand Up @@ -908,22 +909,22 @@ object GLForm1: TGLForm1
TabOrder = 4
end
object MosaicBox: TGroupBox
Left = 1
Left = 0
Height = 259
Top = 217
Width = 214
Top = 216
Width = 216
Align = alTop
Caption = 'Mosaic'
ClientHeight = 237
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 5
Visible = False
object MosaicText: TMemo
Left = 0
Height = 121
Top = 116
Width = 206
Width = 208
Align = alClient
Lines.Strings = (
'MosaicText'
Expand All @@ -935,11 +936,11 @@ object GLForm1: TGLForm1
Left = 0
Height = 116
Top = 0
Width = 206
Width = 208
Align = alTop
BevelOuter = bvNone
ClientHeight = 116
ClientWidth = 206
ClientWidth = 208
TabOrder = 1
object ColOverlap: TTrackBar
Left = 126
Expand Down Expand Up @@ -1073,22 +1074,22 @@ object GLForm1: TGLForm1
end
end
object OverlayBox: TGroupBox
Left = 1
Left = 0
Height = 74
Top = 51
Width = 214
Top = 50
Width = 216
Align = alTop
Caption = 'Overlays'
ClientHeight = 52
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 6
Visible = False
object StringGrid1: TStringGrid
Left = 0
Height = 52
Top = 0
Width = 206
Width = 208
Align = alClient
AutoEdit = False
BorderStyle = bsNone
Expand Down Expand Up @@ -1142,14 +1143,14 @@ object GLForm1: TGLForm1
TabOrder = 7
end
object LineBox: TGroupBox
Left = 1
Left = 0
Height = 50
Top = 656
Width = 214
Top = 655
Width = 216
Align = alTop
Caption = 'Lines'
ClientHeight = 28
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 9
object LineWidthLabel: TLabel
Expand Down Expand Up @@ -1181,14 +1182,14 @@ object GLForm1: TGLForm1
end
end
object Slice2DBox: TGroupBox
Left = 1
Left = 0
Height = 88
Top = 568
Width = 214
Top = 567
Width = 216
Align = alTop
Caption = '2D Slices'
ClientHeight = 66
ClientWidth = 206
ClientWidth = 208
ParentFont = False
TabOrder = 8
object LeftBtn: TSpeedButton
Expand Down Expand Up @@ -1869,9 +1870,9 @@ object GLForm1: TGLForm1
end
end
object OpenDialog1: TOpenDialog
FileName = '/Users/rorden/Documents/pas/raycast'
FileName = '/Users/rorden/Documents/pas'
Filter = 'NIfTI|*.nii;*.hdr;*.nii.gz|PIC|*.PIC'
InitialDir = '/Users/rorden/Documents/pas/'
InitialDir = '/Users/rorden/Documents/'
left = 320
top = 16
end
Expand Down
Loading

0 comments on commit e311507

Please sign in to comment.