Multimodal DICOM Transform Matrix
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have this function in MATLAB which takes the DICOM info structs of two volumes corresponding to two different MRI modalities of the same patient, and outputs M, the affine transformation matrix which transforms from image coordinates of the volume described by info1 into the image coordinates of the volume described by info2:
function [M,Rot] = GetTransformMatrix(info1, info2)
% This function calculates the 4x4 transform and 3x3 rotation matrix
% between two image coordinate system.
% M=Tipp*R*S*T0;
% Tipp:translation
% R:rotation
% S:pixel spacing
% T0:translate to center(0,0,0) if necessary
% info1: dicominfo of 1st coordinate system
% info2: dicominfo of 2nd coordinate system
% Rot: rotation matrix between coordinate system
[Mdti,Rdti] = TransMatrix(info1);
[Mtf,Rtf] = TransMatrix(info2);
% First we transform into patient coordinates by multiplying by Mdti, and
% then we convert again into image coordinates of the second volume by
% multiplying by inv(Mtf)
M = inv(Mtf) * Mdti;
Rot = inv(Rtf) * Rdti;
end
function [M,R] = TransMatrix(info)
%This function calculates the 4x4 transform matrix from the image
%coordinates to patient coordinates.
ipp=info.ImagePositionPatient;
iop=info.ImageOrientationPatient;
ps=info.PixelSpacing;
Tipp=[1 0 0 ipp(1); ...
0 1 0 ipp(2); ...
0 0 1 ipp(3); ...
0 0 0 1];
r=iop(1:3); c=iop(4:6); s=cross(r',c');
R = [r(1) c(1) s(1) 0; ...
r(2) c(2) s(2) 0; ...
r(3) c(3) s(3) 0; ...
0 0 0 1];
if info.MRAcquisitionType=='3D' % 3D turboflash
S = [ps(2) 0 0 0; 0 ps(1) 0 0; 0 0 info.SliceThickness 0 ; 0 0 0 1];
else % 2D epi dti
S = [ps(2) 0 0 0; ...
0 ps(1) 0 0; ...
0 0 info.SpacingBetweenSlices 0; ...
0 0 0 1];
end
T0 = [ 1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
0 0 0 1];
M = Tipp * R * S * T0;
end
For converting from ADC image coordinates into T2 image coordinates, I'm getting the transformation matrix in the following way:
[M,Rot] = GetTransformMatrix(ADCHeader,T2Header);
M = M';
And then I obtain the MATLAB affine transformation object:
tform = affine3d(M);
To subsequently register the ADCVolume to the T2 volume:
[ADCVolume_reg,~] = imwarp(ADCVolume,tform,'Interp','cubic','FillValues',0,'OutputView',imref3d(size(T2Volume)));
This is yielding the correct result when the DICOM parameter info.SpacingBetweenSlices is the same between ADC and T2, although I get wrong registration when it is different.
Might this be an error with the GetTransformMatrix function, or is it on the arguments I passed to imwarp?
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu DICOM Format finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!