Enet4 / dicom-rs

Rust implementation of the DICOM standard
https://dicom-rs.github.io
Apache License 2.0
422 stars 82 forks source link

Reading a file with incomplete meta table #255

Open sh4hri4roo opened 2 years ago

sh4hri4roo commented 2 years ago

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,...)

Enet4 commented 2 years ago

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.

sh4hri4roo commented 2 years ago

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

Enet4 commented 2 years ago

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)?

sh4hri4roo commented 2 years ago

Yes, I'm using the latest version.

IM00001.zip

Enet4 commented 2 years ago

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:

  1. FileMetaTable expects mandatory fields to always be present, so it will have to be changed so that they also sit behind Options. Better coordinate this with #70 too.
  2. 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.

sh4hri4roo commented 2 years ago

thank you

shubhsingh5901 commented 4 months ago

Hi,

@Enet4 I will create a pr for this, as discussed on forum.