template_checker

check a header against best template

Module Attributes

ErrorCompare

Dictionary for mismatches in input (have key) and template (expect key)

CheckResult

Functions

find_errors(template, current_hdr)

given a template and hdr, find any mismatches (non-conforming errors) :param template: expected values :param current_hdr: values we currently have :returns: dictionary of tag key names and the have/expect values

Classes

CheckResult

ErrorCompare

Dictionary for mismatches in input (have key) and template (expect key)

TemplateChecker([db])

cache db connection and list of tags read a dicom file and report if it conforms to the expected template

class template_checker.CheckResult[source]
  • conforms: false when a acq2sqlite.DBQuery.CONSTS
    template-parameter between input and template mismatch
  • errors: nested dict of {mismatched_param: {'have':...,'expect':...}} (parameter keyed dictionary with ErrorCompare values)
  • input: dict of all parameters of an input dicom header
  • template: all the parameters of a template (matching Study, SeriesName)

Here’s an example of CheckResult datastructure in html/javascript on the static debug-enabled page

../_images/CheckResults_mrqart.png
class template_checker.ErrorCompare[source]

Dictionary for mismatches in input (have key) and template (expect key)

class template_checker.TemplateChecker(db=None)[source]

cache db connection and list of tags read a dicom file and report if it conforms to the expected template

check_file(dcm_path)[source]

File disbatch for TemplateChecker.check_header()

Parameters:

dcm_path – path to dicom file with header/parameters to read.

Returns:

output of check_header

Return type:

CheckResult

check_header(hdr)[source]

Check acquisition parameters against it’s template.

Parameters:

hdr – DB row or file dictionary desc. acq. to check against template

Returns:

Conforming status, errors, and comparison information

Return type:

CheckResult

template_checker.find_errors(template, current_hdr)[source]

given a template and hdr, find any mismatches (non-conforming errors) :param template: expected values :param current_hdr: values we currently have :returns: dictionary of tag key names and the have/expect values

Parameters:
  • template (dict[str, str])

  • current_hdr (dict[str, str])

Return type:

dict[str, ErrorCompare]