Read Dicom REG file to deformation Field

19 views (last 30 days)
Hello,
currently I am working in the field of image registration and a program outputs DICOM REG files. see here: http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.20.3.html
For calculating the Target Registration Error I want to read a Deformation field out of this REG file (like in imregdemons, where I get a 4 D field and each voxel is individually transformed)
However I have some difficulties with it and wanted to ask if someone of you has had experience with it.
Here is my code so far:
info = dicominfo(dicomfile);
grid_data = info.DeformableRegistrationSequence.Item_2.DeformableRegistrationGridSequence.Item_1.VectorGridData;
dimensions = info.DeformableRegistrationSequence.Item_2.DeformableRegistrationGridSequence.Item_1.GridDimensions;
preTransformMatrix = info.DeformableRegistrationSequence.Item_2.PreDeformationMatrixRegistrationSequence.Item_1.FrameOfReferenceTransformationMatrix;
preTransformMatrix = reshape(preTransformMatrix, [4 4]).';
postTransformMatrix = info.DeformableRegistrationSequence.Item_2.PostDeformationMatrixRegistrationSequence.Item_1.FrameOfReferenceTransformationMatrix;
preTransformMatrix = reshape(postTransformMatrix, [4 4]).';
x = grid_data(1 : 3 : end);
y = grid_data(2 : 3 : end);
z = grid_data(3 : 3 : end);
defField_x = permute( reshape(x, dimensions(1), dimensions(2), dimensions(3)), [2 1 3] );
defField_y = permute( reshape(y, dimensions(1), dimensions(2), dimensions(3)), [2 1 3] );
defField_z = permute( reshape(z, dimensions(1), dimensions(2), dimensions(3)), [2 1 3] );
defField_x_resampled = imresize3d(defField_x,[],target_dimensions,'linear');
defField_y_resampled = imresize3d(defField_y,[],target_dimensions,'linear');
defField_z_resampled = imresize3d(defField_z,[],target_dimensions,'linear');
defField(:,:,:,1) = defField_x_resampled;
defField(:,:,:,2) = defField_y_resampled;
defField(:,:,:,3) = defField_z_resampled;
What I have accomplished so far is the interpolation of the vector grid data to the size of the original registered image, but now I am confused how I should include the pre and post deformation transformation matrix.
To summarize: In the end I want to have a 4D deformationfield which explains the full displacement for every voxel, thus it probably needs to be combined out of the transformation matrices and the data from the vector grid data.
Any help would be very much appreciated because I could not find much information about this on the internet.
I tried open those files with slicer and save them as nifit but that did not work...
This is the data from this report:
Thank you very much
Regards
Michael

Answers (0)

Categories

Find more on DICOM Format in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!