Reference to non-existent field 'PixelSpacing'.
이전 댓글 표시
I have a dicom viewer that cannot load ultrasound images because of that error (see subject line). What to do?
I get the error for that line of the dicom viewer
scale=[info.PixelSpacing(1) info.PixelSpacing(2) info.SliceThickness];
답변 (1개)
Walter Roberson
2018년 5월 7일
0 개 추천
You use dicominfo() to read the metadata. You use dicomread() on the metadata to read the content of the image. You set the PixelSpacing field in the metadata. You dicomwrite() of the content of the image and the metadata into a new file.
Or... you fix the viewer, or get a new viewer.
See https://www.mathworks.com/matlabcentral/answers/215612-how-can-i-convert-pixels-to-mm-for-a-specific-dicom-image#answer_178301 for more information about correctly computing position information for DICOM files.
댓글 수: 11
Stelios Fanourakis
2018년 5월 7일
Stelios Fanourakis
2018년 5월 7일
Walter Roberson
2018년 5월 7일
Look at the link I gave and read the references there to see what kind of information is expected to exist, and look at the information you do have available and figure out what values are needed in order to meaningfully fake it. And then you write them into the metadata the way I described.
Stelios Fanourakis
2018년 5월 7일
Walter Roberson
2018년 5월 7일
편집: Walter Roberson
2018년 5월 7일
Guessed_spacing = repmat(randi([1 50]), 2, 1);
info = dicominfo('YourFile.dcm');
data = dicomread(info);
info.PixelSpacing = Guessed_spacing;
dicomwrite(data, 'YourNewFile.dcm', info);
Walter Roberson
2018년 5월 7일
Look at info.SequenceOfUltrasoundRegions at the content there. In the sample ultrasound image I found, it has Item_1 and Item_2 . For example,
>> info.SequenceOfUltrasoundRegions.Item_1
ans =
struct with fields:
RegionSpatialFormat: 1
RegionDataType: 1
RegionFlags: 2
RegionLocationMinX0: 80
RegionLocationMinY0: 28
RegionLocationMaxX1: 944
RegionLocationMaxY1: 568
ReferencePixelX0: 512
ReferencePixelY0: 28
PhysicalUnitsXDirection: 3
PhysicalUnitsYDirection: 3
ReferencePixelPhysicalValueX: 0
ReferencePixelPhysicalValueY: 0
PhysicalDeltaX: 0.00277428146175764
PhysicalDeltaY: 0.00277428146175764
The PhysicalUnits*Direction coded as 3 indicate cm; see https://dicom.innolitics.com/ciods/us-image/us-region-calibration/00186011/00186026
You want the one that has RegionSpatialFormat 1, which is "2d (tissue or flow), not RegionSpatialFormat 4, which is waveform such as eeg traces or Dopler.
So the pixel spacing was 0.00277428146175764 cm in X and Y. To convert this to PixelSpacing you would need to multiply by 10, because PixelSpacing is in mm http://dicom.nema.org/dicom/2013/output/chtml/part03/sect_10.7.html
I found this information by grabbing a sample DICOM image from https://medistim.com/dicom/ and looking to see what information was available in the file, and then I looked it up online to see what the units were.
Stelios Fanourakis
2018년 5월 7일
Stelios Fanourakis
2018년 5월 7일
편집: Stelios Fanourakis
2018년 5월 7일
Stelios Fanourakis
2018년 5월 7일
편집: Stelios Fanourakis
2018년 5월 7일
Walter Roberson
2018년 5월 7일
When you do dicominfo on the original file does the modality show up as OT ("other") or as US ("ultrasound")?
Stelios Fanourakis
2018년 5월 8일
카테고리
도움말 센터 및 File Exchange에서 Ultrasound Imaging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!