How to use dicomwrite after modification
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ahmad Abbas
el 10 de Ag. de 2020
Comentada: Walter Roberson
el 10 de Ag. de 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))
0 comentarios
Respuesta aceptada
Walter Roberson
el 10 de Ag. de 2020
Editada: Walter Roberson
el 10 de Ag. de 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 ?
Más respuestas (0)
Ver también
Categorías
Más información sobre DICOM Format en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!