How to use dicomwrite after modification

1 vue (au cours des 30 derniers jours)
Ahmad Abbas
Ahmad Abbas le 10 Août 2020
Commenté : Walter Roberson le 10 Août 2020
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))

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Août 2020
Modifié(e) : Walter Roberson le 10 Août 2020
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 ?
  2 commentaires
Ahmad Abbas
Ahmad Abbas le 10 Août 2020
my idea is to convert the pixel value to HU
i need the convertion for all the dicom but used 200 just to show the result

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur DICOM Format dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by