Convert DICOM affinity matrix from image space to patient space in Matlab

It’s easy to get an affinity matrix from the nifti header. However, there are many entries in the DICOM header, but it is not clear to him which entries describe the conversion of the parameter for which there is a new space.

I found a tutorial that is pretty detailed, but I can not find the entries to which they refer. In addition, this tutorial is written for Python, not Matlab. He lists these header entries:

Entries needed:
Image Position (0020,0032)
Image Orientation (0020,0037)
Pixel Spacing (0028,0030)

I cannot find them if I load the dicominfo () header . They may be vendor specific or perhaps located somewhere in the structure. In addition, the pixel spacing they refer to consists of two values, so I think their tutorial will only work for one-second conversions. More header entries for slice thickness and slicegap are required. It is also not easy to calculate the correct transformation for z coordinates.

Does anyone know how to find these records or how to convert image coordinates to patient coordinates with other information from the DICOM header? I am using Matlab.

+3
source share
1 answer

, , . Matlab inf.PerFrameFunctionalGroupsSequence.Item_X., , , /, . . SpacingBetweenSlices ( ), PixelSpacing, ImagePositionPatient ImageOrientationPatient . , , nipy .

, , , . z , dicom, -, 2d-. z- , x y ( ), slicies. , .

%load the header
inf = dicominfo(filename, 'dictionary', yourvendorspecificdictfilehere);

nSl = double(inf.MRSeriesNrOfSlices);
nY = double(inf.Height);
nX = double(inf.Width);
T1 = double(inf.PerFrameFunctionalGroupsSequence.Item_1.PlanePositionSequence.Item_1.ImagePositionPatient);

%load pixel spacing / scaling / resolution
RowColSpacing = double(inf.PerFrameFunctionalGroupsSequence.Item_1.PixelMeasuresSequence.Item_1.PixelSpacing);
%of inf.PerFrameFunctionalGroupsSequence.Item_1.PrivatePerFrameSq.Item_1.Pixel_Spacing;
dx = double(RowColSpacing(1));
dX = [1; 1; 1].*dx;%cols
dy = double(RowColSpacing(2));
dY = [1; 1; 1].*dy;%rows
dz = double(inf.SpacingBetweenSlices);%inf.PerFrameFunctionalGroupsSequence.Item_1.PrivatePerFrameSq.Item_1.SliceThickness; %thickness of spacing?
dZ = [1; 1; 1].*dz;

%directional cosines per basis vector
dircosXY = double(inf.PerFrameFunctionalGroupsSequence.Item_1.PlaneOrientationSequence.Item_1.ImageOrientationPatient);
dircosX = dircosXY(1:3);
dircosY = dircosXY(4:6);
if nSl == 1;
    dircosZ = cross(dircosX,dircosY);%orthogonal to other two direction cosines!
else
    N = nSl;%double(inf.NumberOfFrames);
    TN = double(-eval(['inf.PerFrameFunctionalGroupsSequence.Item_',sprintf('%d', N),'.PlanePositionSequence.Item_1.ImagePositionPatient']));
    dircosZ = ((T1-TN)./nSl)./dZ;
end

%all dircos together
dimensionmixing = [dircosX dircosY dircosZ];

%all spacing together
dimensionscaling = [dX dY dZ];

%mixing and spacing of dimensions together
R = dimensionmixing.*dimensionscaling;%maps from image basis to patientbasis

%offset and R together
A = [[R T1];[0 0 0 1]];

%you probably want to switch X and Y
%(depending on how you load your dicom into a matlab array)
Aold = A;
A(:,1) = Aold(:,2);
A(:,2) = Aold(:,1);

:

enter image description here

, . , Z . . , - , , , , Matlab, DICOM. , Z , , (dicomread )

-Edit- Z

+7

All Articles