DicomImage.Dataset is Obsolete. Dataset should not be publicly accessible from DicomImage.

192 views
Skip to first unread message

Yiannis Demetrakopoulos

unread,
Jan 19, 2019, 1:45:44 AM1/19/19
to Fellow Oak DICOM
Hi,
I updated to the new 4.0.0 version and I get many "DicomImage.Dataset is Obsolete. Dataset should not be publicly accessible from DicomImage." warnings in my code.
Please let me know which is the recommended way to access the dataset from a dicomImage.

Thank you.

Reinhard Gruber

unread,
Jan 21, 2019, 2:50:37 AM1/21/19
to Fellow Oak DICOM
the property DicomImage.Dataset was marked obsolete in commit https://github.com/fo-dicom/fo-dicom/pull/582 due to some multi-threading issues.
I would recommend:

if you are only intereseted in the image, you can call 

    var img = new DicomImage(filename);

If you also want to access the dataset, I call

   var dataset = new DicomDataset(filename);
   var img = new DicomImage(dataset);

If you never faced some multi-threading issues, then it would be fine to compile with the errors. I think that was the reason, why the property was only marked as obsolete, to make to make the developer not to use the property if possible. If it was really dangerous, then Anders surely would have made the property private.

Yiannis Demetrakopoulos

unread,
Jan 21, 2019, 6:02:17 AM1/21/19
to Fellow Oak DICOM
Thank you very much for your answer.
I tried to use the new DicomDataset(filename) but it seems that there is no DicomImage(filename) overload available.
I would really appreciate to be able to use something like this.

Kind Regards
Demetrakopoulos Ioannis

Yiannis Demetrakopoulos

unread,
Jan 21, 2019, 6:10:04 AM1/21/19
to Fellow Oak DICOM
I tired  
DicomFile file = DicomFile.Open(fileName);
DicomDataset dataset = file.Dataset;

It works.But I am wondering if there is anything better in terms of execution time.

Thanks
Reply all
Reply to author
Forward
0 new messages