How can I display a 3D image of a DICOM stack without it being squished?

12 views (last 30 days)
Hello, I have tried using the volshow function from this page about displaying a 3D view of a dicom stack, the only problem is that the image is squished. (Like the first example from the dicomreadVolume page)
One solution was to incorporate the line "V = dicomreadVolume(sourcetable,"s3",MakeIsotropic=true);" but I very quickly noticed that matlab's example dicom images have a dicom tag called "SpacingBetweenSlices" , something other dicom stacks, like ones from Slicer, do not have. I have tried adding the tag to the metadata of my own dicom images in order to make the line above work. Problem is the dicomwrite function does not actually save that tag to any of the images in the file explorer. (Two attempts of how I tried this shown below, both run without spitting out errors)
1st Try:
for i = 1:sourcetable.Frames
metadata = dicominfo(fullfile(name, fileList(i).name), 'UseDictionaryVR', true);
metadata.spacingBetweenSlices = 3.3000; % This value is pulled from the metadata of matlabs dicom example
dicomwrite(dicomread(fullfile(name, fileList(i).name)), ...
fullfile(name, fileList(i).name), metadata);
end
2nd Try:
for i = 1:numel(fileList)
% Read DICOM metadata for the current file
metadata = dicominfo(fullfile(inputFolderPath, fileList(i).name));
% Add the new DICOM tag, this is pulled from matlabs example dicom metadata
metadata.(dicomlookup('0018','0088')) = struct('VR', 'DS', 'Value', 3.3);
% New file name for the modified DICOM image
[~, fileName, fileExt] = fileparts(fileList(i).name);
newFileName = strcat(fileName, '_modified', fileExt);
outputFilePath = fullfile(newDir, newFileName);
% Write the modified DICOM image with updated metadata to the new file
dicomwrite(dicomread(fullfile(inputFolderPath, fileList(i).name)), outputFilePath, metadata);
end
I have tried other 3d viewing functions, however, I really like the volshow function as I am able to rotate the image around without any lag. Does anyone has any tips or suggestions on how they display their dicom image stack without it being squished?
  2 Comments
Rik
Rik on 12 Jul 2023
In my own 3D viewer I used the image function to deal with anisotropic voxels.
You can calculate the slice increment by subtracting the z value of two subsequent slices. If you want I can look up the correct dicom tag for that property. (but it is probably quicker to Google it yourself)
Walter Roberson
Walter Roberson on 15 Sep 2023
Most DICOM modalities do not record the position of each slide independently. In most of them, the position of individual slices is implied.
See https://stackoverflow.com/questions/14930222/how-to-calculate-space-between-dicom-slices-for-mpr for some of the details about complications in calculating slice thickness.

Sign in to comment.

Accepted Answer

Tim Jackman
Tim Jackman on 15 Sep 2023
Edited: Walter Roberson on 15 Sep 2023
The volshow documentation now has an example that shows how to use the Transformation property to set the correct spatial referencing and avoid the squished volume effect:
Also, the medicalVolume object from the Medical Imaging Toolbox will handle this for you:

More 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!