dicom-rs
dicom-rs copied to clipboard
Reading a file with incomplete meta table
I have a Dicom file which does not has "sop_instance_uid" or at least Dicom-rs does not recognize it! I know that there are two ways to read a dicom file but both of them give me "ParseMetaDataSet" error and then I can not go further. Is there any way to somehow add this element to meta table? If so, please provide more information(sample, link to source,...)
Thank you for reporting. Could you provide an anonymized form of the DICOM file or an abridged dump of the file using another DICOM tool? It would help to understand what really happens in this case. The ParseMetaDataSet error variant should also contain an informative root source error underneath.
If the file is missing a file meta group entirely, then it needs to be read using separate data set reading functions, such as InMemDicomObject::read_dataset_with_ts. A best-effort mechanism to infer parts of the file meta table may eventually exist (#50).
If only one of the mandatory fields are missing, such as Media Storage SOP Instance UID, it is true that DICOM-rs shows no recourse at the moment (FWIW that field is mandatory according to the standard). In this case, maybe the object loading options could be extended to set up baseline file meta information, so that it would fill in the necessary gaps in advance.
Here is the output of open_file() function:
let mut obj = open_file("some_path").unwrap();
thread 'main' panicked at 'called Result::unwrap() on an Err value: ParseMetaDataSet { source: MissingElement { alias: "MediaStorageSOPInstanceUID", backtrace: Backtrace(()) } }
But as you can see from another Dicom tool, the dicom file actually has the "MediaStorageSOPInstanceUID" element!
1.zip
Odd. dicom-dump uses open_file underneath but it could produce a dump of the given file just fine. Can you double check that this is the problematic file, and that you are using the latest version of the library (0.5.0)?
OK, the issue can be reproduced with the second example.
The file is clearly missing mandatory fields as per PS3.10 Chapter 7, but it can be made more resilient with the following two changes:
FileMetaTableexpects mandatory fields to always be present, so it will have to be changed so that they also sit behindOptions. Better coordinate this with #70 too.- File opening options can be extended to support strict/relaxed checking (whether to error on missing attributes); and to fill in missing file meta attributes with default values or overrides.
Until something like the above is implemented, DICOM-rs requires all Type 1 file meta information attributes to be present in a file, even if just placeholders.
thank you