6
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7
StdCtrls, RXSpin,nifti_hdr,graphicsMathLibrary, ExtCtrls;
10
TReorientForm = class(TForm)
14
ReorientTimer: TTimer;
15
PitchEdit: TRxSpinEdit;
16
RollEdit: TRxSpinEdit;
27
procedure ReorientTimerTimer(Sender: TObject);
28
procedure EditChange(Sender: TObject);
30
{ Private declarations }
32
procedure ApplyTransform ( var lHdr: TMRIcroHdr);
34
{ Public declarations }
38
ReorientForm: TReorientForm;
42
uses nifti_img_view,nifti_img, nifti_hdr_view;
46
procedure TReorientForm.ApplyTransform ( var lHdr: TMRIcroHdr);
51
if (XEdit.value = 0) and (YEdit.value = 0) and (ZEdit.value = 0)
52
and (PitchEdit.value = 0) and (YawEdit.value = 0) and (RollEdit.value = 0) then exit;
53
lRot := Matrix3D (1,0,0,XEdit.value,
58
lHdr.NIFTIhdr.srow_x[0],lHdr.NIFTIhdr.srow_x[1],lHdr.NIFTIhdr.srow_x[2],lHdr.NIFTIhdr.srow_x[3], // 3D "graphics" matrix
59
lHdr.NIFTIhdr.srow_y[0],lHdr.NIFTIhdr.srow_y[1],lHdr.NIFTIhdr.srow_y[2],lHdr.NIFTIhdr.srow_y[3], // 3D "graphics" matrix
60
lHdr.NIFTIhdr.srow_z[0],lHdr.NIFTIhdr.srow_z[1],lHdr.NIFTIhdr.srow_z[2],lHdr.NIFTIhdr.srow_z[3], // 3D "graphics" matrix
62
if PitchEdit.value <> 0 then RotatePitch(PitchEdit.value{-11.4592},lRot);
63
if RollEdit.value <> 0 then RotateRoll(RollEdit.value,lRot);
64
if YawEdit.value <> 0 then RotateYaw(YawEdit.value,lRot);
66
lM := MultiplyMatrices(lRot,lM);
68
(* WriteNiftiMatrix (lHdr.NiftiHdr,
69
lM.matrix[1,1],lM.matrix[1,2],lM.matrix[1,3],lM.matrix[1,4],
70
lM.matrix[2,1],lM.matrix[2,2],lM.matrix[1,3],lM.matrix[2,4],
71
lM.matrix[3,1],lM.matrix[3,2],lM.matrix[1,3],lM.matrix[3,4]);
74
//Caption := inttostr(random(888))+floattostr(lM.matrix[1,4]);
75
XLabel.caption:= floattostr(lM.matrix[1,1])+'x'+floattostr(lM.matrix[1,2])+'x'+floattostr(lM.matrix[1,3])+'x'+floattostr(lM.matrix[1,4]);
76
YLabel.caption:= floattostr(lM.matrix[2,1])+'x'+floattostr(lM.matrix[2,2])+'x'+floattostr(lM.matrix[2,3])+'x'+floattostr(lM.matrix[2,4]);
77
ZLabel.caption:= floattostr(lM.matrix[3,1])+'x'+floattostr(lM.matrix[3,2])+'x'+floattostr(lM.matrix[3,3])+'x'+floattostr(lM.matrix[3,4]);
79
(*procedure DrawLine(lIMage: TImage; lXmm,lYmm,lZmm,lXmm2,lYmm2,lZmm2: integer);
83
lImage.Canvas.Pen.Color:=gBGImg.XBarClr;
84
lImage.Canvas.Pen.Width := gBGImg.XBarThick;
85
MMToImgCoord( lX,lY,lZ, lXmm,lYmm,lZmm);
86
lImage.Canvas.MoveTo(lX,lY);
87
MMToImgCoord( lX,lY,lZ, lXmm2,lYmm2,lZmm2);
88
lImage.Canvas.LineTo(lX,lY);
91
procedure TReorientForm.ReorientTimerTimer(Sender: TObject);
93
ReorientTimer.enabled := false;
94
//ImgForm.CloseOverlayImgClick(nil);
96
(*DrawLine(ImgForm.PGImage2,0,-104,0,0,72,0);//horizontal line on Sag
97
DrawLine(ImgForm.PGImage2,0,0,78,0,0,-48);//horizontal line on Sag
98
DrawLine(ImgForm.PGImage3,0,0,77,0,0,-48);//horizontal line on Sag
99
DrawLine(ImgForm.PGImage3,-64,0,0,64,0,0);//horizontal line on Sag
101
ApplyTransform(gMRIcroOverlay[kBGOverlayNum]);
102
//MMToImgCoord(var lX,lY,lZ: integer; var lXmm,lYmm,lZmm: single);
105
(*procedure TReorientForm.ReorientTimerTimer(Sender: TObject);
109
ReorientTimer.enabled := false;
110
ImgForm.CloseOverlayImgClick(nil);
111
ReorientTimer.enabled := false;
112
lFilename := 'C:\pas\Delphi\niftiview\grey.voi';
113
ImgForm.LoadOverlay (lFilename);
116
procedure TReorientForm.EditChange(Sender: TObject);
118
ReorientTimer.enabled := true;