From 99656cbdc9a32de4d1714f237484522ff4c563f4 Mon Sep 17 00:00:00 2001 From: Chris Rorden Date: Sat, 15 Jul 2017 12:11:57 -0400 Subject: [PATCH] Restore Delphi Compatibility --- mainunit.dfm | 6 ++ mainunit.pas | 7 +- nifti_foreign.pas | 72 ++++++++++++++++++ simplelaz.lpi | 184 +++++++++++++++++++++++----------------------- 4 files changed, 173 insertions(+), 96 deletions(-) diff --git a/mainunit.dfm b/mainunit.dfm index f855eaf..e52cd1b 100755 --- a/mainunit.dfm +++ b/mainunit.dfm @@ -1411,6 +1411,12 @@ object GLForm1: TGLForm1 ShortCut = 83 OnClick = OrientMenuClick end + object RadiologicalMenu: TMenuItem + AutoCheck = True + Caption = 'Radiological (FlipLR)' + GroupIndex = 212 + OnClick = RadiologicalMenuClick + end end object View1: TMenuItem Caption = 'View' diff --git a/mainunit.pas b/mainunit.pas index b528d22..4447150 100755 --- a/mainunit.pas +++ b/mainunit.pas @@ -51,7 +51,6 @@ TGLForm1 = class(TForm) InterpolateAxialMenu: TMenuItem; InterpolateCoronalMenu: TMenuItem; InterpolateSagittalMenu: TMenuItem; - ShaderPanel: TPanel; QualityTrack: TTrackBar; S10Check: TCheckBox; @@ -156,7 +155,6 @@ TGLForm1 = class(TForm) MRU2: TMenuItem; MRU1: TMenuItem; StringGrid1: TStringGrid; - ToolPanel: TPanel; ClipBox: TGroupBox; Label4: TLabel; @@ -3517,6 +3515,7 @@ procedure TGLForm1.UpdateFont(initialSetup: boolean); else begin gText.ChangeFontName(p, GLBox); gClrBar.ChangeFontName(p, GLBox); + GLBox.Invalidate; end; end; @@ -3562,13 +3561,13 @@ procedure PrefMenuClick; bmpEdit.Parent:=PrefForm; //Font name FontCombo:=TComboBox.create(PrefForm); + FontCombo.Parent:=PrefForm; FontCombo.Left := 8; FontCombo.Top := 78; FontCombo.Width := PrefForm.Width -16; FontCombo.Items.Add('Default Font'); //add fonts FontCombo.ItemIndex:= 0; - if FindFirst(ClutDir+pathdelim+'*.fnt', faAnyFile, searchRec) = 0 then begin repeat s :=ParseFileName(ExtractFileName(searchRec.Name)); @@ -3580,8 +3579,6 @@ procedure PrefMenuClick; until (FindNext(searchRec) <> 0); end; //find fonts FindClose(searchRec); - //FontCombo.Items.Add('Quality: Better'); - //QualityCombo.Items.Add('Quality: Best'); FontCombo.Style := csDropDownList; FontCombo.Parent:=PrefForm; //Tiled Check diff --git a/nifti_foreign.pas b/nifti_foreign.pas index 5d0fc33..7ce407d 100755 --- a/nifti_foreign.pas +++ b/nifti_foreign.pas @@ -552,6 +552,76 @@ function parsePicString(s: string): single; sList.Free; end; +function nii_readVmr (var fname: string; var nhdr: TNIFTIhdr; var gzBytes: int64; var swapEndian: boolean): boolean; +//http://support.brainvoyager.com/automation-aamp-development/23-file-formats/385-developer-guide-26-the-format-of-vmr-files.html +Type + Tvmr_header = packed record //Next: PIC Format Header structure + ver, nx, ny, nz, nvol: word; // 0,4,8,12 + end; // Tbv_header; + Tvmr_tail = packed record // + Xoff,Yoff,Zoff,FramingCube: int16; + PosFlag,CoordSystem: int32; + X1, Y1, Z1,Xn,Yn,Zn, RXv,RYv,RZv, CXv,CYv,CZv: single; + nRmat, nCmat: int32; + Rfov, Cfov, Zthick, Zgap: single; + nTrans: int32; + LRconv, Ref: uint8; + vXres, vYres, vZres: single; + isResVerified, isTal: uint8; + min, mean, max: int32; + end; +var + vhdr : Tvmr_header; + vtail : Tvmr_tail; + lHdrFile: file; + nvox, FSz : integer; +begin + result := false; + {$I-} + AssignFile(lHdrFile, fname); + FileMode := 0; //Set file access to read only + Reset(lHdrFile, 1); + {$I+} + if ioresult <> 0 then begin + NSLog('Error in reading vmr header.'+inttostr(IOResult)); + FileMode := 2; + exit; + end; + FSz := Filesize(lHdrFile); + BlockRead(lHdrFile, vhdr, sizeof(Tvmr_header)); + nVox := vhdr.nx * vhdr.ny * vhdr.nz * vhdr.nvol * 4; //*4 as 32-bpp + if (vhdr.ver < 3) or (vhdr.ver > 255) or ((nVox + sizeof(Tvmr_header)+ sizeof(Tvmr_tail) ) > FSz) then begin //docs do not specify endian - wrong endian? + CloseFile(lHdrFile); + exit; + end; + seek(lHdrFile, nVox + sizeof(Tvmr_header)); + BlockRead(lHdrFile, vtail, sizeof(Tvmr_tail)); + CloseFile(lHdrFile); + swapEndian := false; + nhdr.dim[0]:=3;//3D + nhdr.dim[1]:=vhdr.nx; + nhdr.dim[2]:=vhdr.ny; + nhdr.dim[3]:=vhdr.nz; + nhdr.dim[4]:=1; + nhdr.pixdim[1]:=1.0; + nhdr.pixdim[2]:=1.0; + nhdr.pixdim[3]:=1.0; + //Need examples + //if vtail.isResVerified > 0 then begin + // showmessage(format('%g %g %g',[vtail.X1, vtail.Y1, vtail.Z1])); + //end; + nhdr.datatype := kDT_UNSIGNED_CHAR; + nhdr.vox_offset := sizeof(Tvmr_header); + nhdr.sform_code := 1; + nhdr.srow_x[0]:=nhdr.pixdim[1];nhdr.srow_x[1]:=0.0;nhdr.srow_x[2]:=0.0;nhdr.srow_x[3]:=0.0; + nhdr.srow_y[0]:=0.0;nhdr.srow_y[1]:=nhdr.pixdim[2];nhdr.srow_y[2]:=0.0;nhdr.srow_y[3]:=0.0; + nhdr.srow_z[0]:=0.0;nhdr.srow_z[1]:=0.0;nhdr.srow_z[2]:=-nhdr.pixdim[3];nhdr.srow_z[3]:=0.0; + convertForeignToNifti(nhdr); + //nhdr.scl_inter:= 1; + //nhdr.scl_slope := -1; + result := true; +end; //nii_readVmr() + function nii_readBVox (var fname: string; var nhdr: TNIFTIhdr; var gzBytes: int64; var swapEndian: boolean): boolean; //http://pythology.blogspot.com/2014/08/you-can-do-cool-stuff-with-manual.html Type @@ -2101,6 +2171,8 @@ function readForeignHeader (var lFilename: string; var lHdr: TNIFTIhdr; var gzBy result := nii_readDeltaVision(lFilename, lHdr, gzBytes, swapEndian) else if (lExt = '.V') then result := nii_readEcat(lFilename, lHdr, gzBytes, swapEndian) + else if (lExt = '.VMR') then + result := nii_readVmr(lFilename, lHdr, gzBytes, swapEndian) else if (lExt = '.BVOX') then result := nii_readBVox(lFilename, lHdr, gzBytes, swapEndian) else if (lExt = '.GIPL') then diff --git a/simplelaz.lpi b/simplelaz.lpi index cbd83d9..2acedd6 100644 --- a/simplelaz.lpi +++ b/simplelaz.lpi @@ -226,10 +226,11 @@ if TargetOS='darwin' then - - + + + @@ -307,7 +308,7 @@ if TargetOS='darwin' then - + @@ -317,21 +318,22 @@ if TargetOS='darwin' then - + + - - + + - + - + @@ -416,7 +418,7 @@ if TargetOS='darwin' then - + @@ -448,11 +450,12 @@ if TargetOS='darwin' then - + - - - + + + + @@ -480,11 +483,12 @@ if TargetOS='darwin' then - + - - - + + + + @@ -576,7 +580,7 @@ if TargetOS='darwin' then - + @@ -742,174 +746,172 @@ if TargetOS='darwin' then - + - + - + - - + + - - + - - + + - + - - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +