Skip to content

Commit

Permalink
♻️ check_header- in prep for check_dbacq
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Nov 7, 2024
1 parent ff8d532 commit b32a9e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mrqart.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def monitor_dirs(watcher, dcm_checker):
# Event(flags=256, cookie=0, name='a', alias='/home/foranw/src/work/mrrc-hdr-qa/./sim')
if re.search("^MR.|.dcm$|.IMA$", event.name):
file = os.path.join(event.alias, event.name)
msg = dcm_checker.check_header(file)
msg = dcm_checker.check_file(file)
logging.debug(msg)
broadcast(WS_CONNECTIONS, json.dumps(msg, default=list))
else:
Expand Down
17 changes: 14 additions & 3 deletions template_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,23 @@ def __init__(self):
self.db = DBQuery()
self.reader = DicomTagReader()

def check_header(self, dcm_path) -> CheckResult:
"""
:returns: (True|Fales, {'have': xxx, 'expect': yyy}, hdr)
def check_file(self, dcm_path) -> CheckResult:
"""
File disbatch for :py:func:`TemplateChecker.check_header`
:param dcm_path: path to dicom file with header/parameters to read.
:returns: output of check_header
"""
hdr = self.reader.read_dicom_tags(dcm_path)
return self.check_header(hdr)

def check_header(self, hdr) -> CheckResult:
"""
Check acquisition parameters against it's template.
:param hdr: DB or file dictionary desc. acq. to check against template
:returns: conforming status, errors, and comparison infomration
"""
template = self.db.get_template(hdr["Project"], hdr["SequenceName"])
template = dict(template)

Expand Down

0 comments on commit b32a9e3

Please sign in to comment.