How to split DICOM to individual slices?

12 ビュー (過去 30 日間)
Wasna Madushanka Ediri Arachchi
Wasna Madushanka Ediri Arachchi 2018 年 1 月 4 日
回答済み: Gautam 2025 年 3 月 7 日
Here I have attached a stacked dicom file comprising 28 slices. How can I save individual dicom files for each slice?

回答 (1 件)

Gautam
Gautam 2025 年 3 月 7 日
To save individual DICOM files for each slice from a stacked DICOM file in MATLAB, you can use the "dicomread" function to read the stacked DICOM file and then iterate through each slice to save it as a separate DICOM file using the "dicomwrite" function.
stackedFileName = 'path_to_stacked_dicom.dcm';
volumeData = dicomread(stackedFileName);
info = dicominfo(stackedFileName);
numSlices = size(volumeData, 3);
for sliceIdx = 1:numSlices
sliceData = volumeData(:, :, sliceIdx);
info.InstanceNumber = sliceIdx;
info.SliceLocation = sliceIdx; % Update slice location if necessary
% Construct a filename for the slice
sliceFileName = sprintf('slice_%02d.dcm', sliceIdx);
% Write the slice to a new DICOM file
dicomwrite(sliceData, sliceFileName, info);
end

カテゴリ

Help Center および File ExchangeDICOM Format についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by