How to use dicomwrite after modification

4 次查看(过去 30 天)
how i can use dicomwrite and copy the metadata for the code below
clear
myFolder = 'C:\Users\Admin\Desktop\MATLAB\Crop cochlea';
filePattern = fullfile(myFolder, '*dcm');
theFiles = dir(filePattern);
crop=zeros(209,218,394);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n',fullFileName);
crop(:,:,k)=x;
end
tmp11 = min(max (0.7966*crop -568.5, -1000),4096);
hu = uint16(tmp11);
imagesc(hu(:,:,200))

采纳的回答

Walter Roberson
Walter Roberson 2020-8-10
编辑:Walter Roberson 2020-8-10
You are constructing file names for all the dcm files in the directory. You iterate over each one, displaying a file name appropriate for each. You the assign the undefined variable x to a variable indexed by the file number.
You are not presently reading any file. You are not presently collecting any dicom metadata. If you were collecting it, then which one would you want to collect, since you seem to be wanting to write a single output file? The single output file looks likely to want to be the adjusted value hu, which is a stack of images, but metadata for one file would not be appropriate for a stack of images in dicom. Perhaps you want to write just file #200 ? Why bother to read the other files then?
tmp11 = min(max (0.7966*crop -568.5, -1000),4096);
0.7966*crop -568.5 values that come out smaller than -1000 would be replaced with -1000 . Resulting values that are more than 4096 would be replaced with 4096. The resulting range of values would be -1000 to 4096.
hu = uint16(tmp11);
Minimum value of uint16 is 0, so all the values in the range -1000 to 0 would be replaced by 0 when doing the uint16 conversion. If that was the intention, then why not use max with 0 instead of -1000 ? Or code is not making sense.
crop=zeros(209,218,394);
You do that no matter how many files there are in the directory.
crop(:,:,k)=x;
are you sure that the undefined variable or function x will return a result that is exactly 209 x 218 ?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by