mercure-imaging / mercure

mercure DICOM Orchestrator
https://mercure-imaging.org
MIT License
65 stars 31 forks source link

Rule handling in case of missing tags e.g. ContrastBolusAgent #35

Closed joshy closed 2 years ago

joshy commented 2 years ago

Describe the bug Not all tags can be used always. For example if the @ContrastBolusAgent@ tag is missing because it is a series without contrast agent the ui signals an error: Invalid rule: invalid syntax (, line 1).

This behavior happens on the old hermes installation but I suppose on mercure the behavior is the same.

To Reproduce Steps to reproduce the behavior:

  1. Create a rule with @ContrastBolusAgent@
  2. Delete the tag ContrastBolusAgent in the "Test Rule" json section
  3. Click "Test"
  4. See error

Additional context After the rule tag replacement is done (https://github.com/mercure-imaging/mercure/blob/master/common/rule_evaluation.py#41), the rule string still contains @ContrastBolusAgent@ which leads to an error. So after the rule tag replacement step is done, another search and replacement for tags is needed. Tags still found needs to be replaced by either False or 0. This is just a proposal, maybe there is a better way to handle it.

BR Joshy

tblock79 commented 2 years ago

It's true that the processing rule will become invalid if it contains a tag that is not contained in the .tags file. However, this should not be an issue in practice. If a specific DICOM tag is not contained in a DICOM file, the getdcmtags module will still create an (empty-valued) entry in the .tags file. Thus, there should always be an entry in the .tags file for all possible tags (i.e. all tags that have been defined in the file main.cpp of the getdcmtags module).

In the new version, the Rule Tester now features a drag-and-drop mechanism, which can be used for testing if a rule works as expected, by dragging different DICOM files onto the UI. If a tag is missing in DICOM files, it will be replaced with a default value. Thus, also in the UI, the problem should not really occur anymore (except if explicitly deleting entries from the Test Values control, but I'd say that it's reasonable if the Rule Tester shows an error in that case).

joshy commented 2 years ago

Forgot that if the DICOM tag is not found the getdcmtags module will still create a empty-valued entry.