How can I display a 3D image of a DICOM stack without it being squished?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2023-7-12
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
2023-9-15
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.
采纳的回答
Tim Jackman
2023-9-15
编辑:Walter Roberson
2023-9-15
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:
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!