필터 지우기
필터 지우기

How to use dicomwrite after modification

조회 수: 4 (최근 30일)
Ahmad Abbas
Ahmad Abbas 2020년 8월 10일
댓글: Walter Roberson 2020년 8월 10일
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 ?
  댓글 수: 2
Ahmad Abbas
Ahmad Abbas 2020년 8월 10일
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

댓글을 달려면 로그인하십시오.

추가 답변 (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