Skip to content

Commit

Permalink
Restore Delphi Compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jul 15, 2017
1 parent d34c14b commit 99656cb
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 96 deletions.
6 changes: 6 additions & 0 deletions mainunit.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 2 additions & 5 deletions mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ TGLForm1 = class(TForm)
InterpolateAxialMenu: TMenuItem;
InterpolateCoronalMenu: TMenuItem;
InterpolateSagittalMenu: TMenuItem;

ShaderPanel: TPanel;
QualityTrack: TTrackBar;
S10Check: TCheckBox;
Expand Down Expand Up @@ -156,7 +155,6 @@ TGLForm1 = class(TForm)
MRU2: TMenuItem;
MRU1: TMenuItem;
StringGrid1: TStringGrid;

ToolPanel: TPanel;
ClipBox: TGroupBox;
Label4: TLabel;
Expand Down Expand Up @@ -3517,6 +3515,7 @@ procedure TGLForm1.UpdateFont(initialSetup: boolean);
else begin
gText.ChangeFontName(p, GLBox);
gClrBar.ChangeFontName(p, GLBox);
GLBox.Invalidate;
end;
end;

Expand Down Expand Up @@ -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));
Expand All @@ -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
Expand Down
72 changes: 72 additions & 0 deletions nifti_foreign.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 99656cb

Please sign in to comment.