I am new to DICOM, and as a first study task I converted a TIFF image to DICOM. I followed, more or less, DCMTK examples. The image file I created is read by IrfanView, for example, as a dcm file, but not by DICOMscope. I ger a 'load failed' error. The log file says 'Invalid data structures'. I geuss DICOMscope is more strict, but I cannot find what exatly do I miss. (The file is grayscale and not compressed).
The relevant code snippet is like this:
// Preparing DCM image data
status = dataset->putAndInsertUint16(DCM_Rows, h) ;
if (status.bad())
wcout << "error inserting DCM rows - " << status.text() << endl ;
status = dataset->putAndInsertUint16(DCM_Columns, w) ;
if (status.bad())
wcout << "error inserting DCM columns - " << status.text() << endl ;
dataset->putAndInsertUint16(DCM_SamplesPerPixel, myTiffReader.get_sample_num()) ;
status = dataset->putAndInsertString(DCM_PhotometricInterpretation,
PhotometricInterpretationNames[EPI_Monochrome1-1].Name) ;
if (status != EC_Normal)
wcout << "Error inserting DICOM photometric interpretation tag." << endl ;
dataset->putAndInsertUint16(DCM_BitsAllocated, 16) ;
dataset->putAndInsertUint16(DCM_BitsStored, 12) ;
status = dataset->putAndInsertUint16(DCM_HighBit, 15) ;
if (status.bad())
wcout << "error inserting DCM Highbit - " << status.text() << endl ;
dataset->putAndInsertUint16(DCM_PixelRepresentation, 0) ;
dataset->putAndInsertUint16(DCM_PlanarConfiguration, 0) ;
status = dataset->putAndInsertUint16Array(DCM_PixelData, DCM_Buff, w*h) ;
if (status == EC_Normal)
{
status = fileFormat.saveFile(argv[3], EXS_LittleEndianExplicit) ;
if (status.good())
wcout << "DICOM output file " << argv[3] << " was saved successfully" << endl ;
else
wcout << "Error writing DICOM output file " << argv[3] << endl ;
}
else
wcout << "Failed writing pixel data to DICOM data set" << endl ;
Can anyone give me a hint as where and how to look for the mistake?
DICOM file I created is not read by DICOMscope
Moderator: Moderator Team
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
In ran dcm2pnm with the options: -v -d +ot
The output doesn't look too helpful to me:
reading DICOM file: D:\DICOM\dcmdemo\dcmdemo\out.dcm
preparing pixel data.
disabling VOI window computation
writing frame 1 to d:\DICOM\dcmdemo\dcmdemo\out2.tif
TIFF: Error writing TIFF header.
cleaning up memory.
Any insight or suggestion?
The output doesn't look too helpful to me:
reading DICOM file: D:\DICOM\dcmdemo\dcmdemo\out.dcm
preparing pixel data.
disabling VOI window computation
writing frame 1 to d:\DICOM\dcmdemo\dcmdemo\out2.tif
TIFF: Error writing TIFF header.
cleaning up memory.
Any insight or suggestion?
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
-
- ICSMED DICOM Services
- Posts: 2217
- Joined: Fri, 2004-10-29, 21:38
- Location: Oldenburg, Germany
I've checked the file with our DCMCHECK validation tool and found a numerous errors:
You should first fix these violations of the DICOM standard before trying to open the file with DICOMscope. Please note that DICOMscope uses a couple of more header attributes than the underlying DCMTK for processing the image (e.g. Series and Study Instance UID).
Code: Select all
**************************************************************************
** check inconsistencies between the given data and the iod-definition **
** (Part 3 of the DICOM-Standard) **
**************************************************************************
Error E-04: Attribute is missing.
Affected attribute: StudyDate(0008,0020) (modules GeneralStudyModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: StudyTime(0008,0030) (modules GeneralStudyModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: AccessionNumber(0008,0050) (modules GeneralStudyModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: Modality(0008,0060) (modules GeneralSeriesModule, SCEquipmentModule) (Type 1)
Error E-04: Attribute is missing.
Affected attribute: ConversionType(0008,0064) (modules SCEquipmentModule) (Type 1)
Error E-04: Attribute is missing.
Affected attribute: ReferringPhysiciansName(0008,0090) (modules GeneralStudyModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: PatientID(0010,0020) (modules PatientModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: PatientsBirthDate(0010,0030) (modules PatientModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: PatientsSex(0010,0040) (modules PatientModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: StudyInstanceUID(0020,000d) (modules GeneralStudyModule) (Type 1)
Error E-04: Attribute is missing.
Affected attribute: SeriesInstanceUID(0020,000e) (modules GeneralSeriesModule) (Type 1)
Error E-04: Attribute is missing.
Affected attribute: StudyID(0020,0010) (modules GeneralStudyModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: SeriesNumber(0020,0011) (modules GeneralSeriesModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: InstanceNumber(0020,0013) (modules GeneralImageModule, SOPCommonModule) (Type 2)
Error E-04: Attribute is missing.
Affected attribute: PatientOrientation(0020,0020) (modules GeneralImageModule) (Type 2C)
Condition "(not(/ImageOrientationPatient exists)) and (not(/ImagePositionPatient exists))" is true.
Error E-05: Attribute is unexpected.
Affected attribute: PlanarConfiguration(0028,0006) (Type 1C) (vm=1; len=2; modules: ImagePixelModule)
Condition "val(./SamplesPerPixel[0]) > 1" is false.
Who is online
Users browsing this forum: No registered users and 1 guest