Skip to content

Commit

Permalink
CONSTS description and image
Browse files Browse the repository at this point in the history
  • Loading branch information
WillForan committed Oct 26, 2024
1 parent 4b3fe42 commit 1805141
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.PHONY: test
.PHONY: test doc docs

# how to get into the python virtual environment
source_venv := . .venv/bin/activate

doc docs: docs/
docs/: .venv/ $(wildcard *.py) sphinx/conf.py $(wildcard sphinx/*.rst)
$(source_venv) && sphinx-build sphinx/ docs/

Expand Down
24 changes: 19 additions & 5 deletions acq2sqlite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
convert db.txt into a sqlite database
Convert ``db.txt`` into a sqlite database.
"""
import sqlite3
import logging
Expand Down Expand Up @@ -49,10 +49,24 @@ def column_names():

class DBQuery:
"""
Convient SQL queries for tracking dicom headers/metadata
Convient SQL queries for tracking dicom headers/metadata.
Poorly implemented, ad-hoc bespoke ORM for ``schema.sql``
This class is a poorly implemented, ad-hoc/bespoke ORM for database defined in ``schema.sql``
"""

#: :py:data:`CONSTS` is a list of expected aquisition-invarient parameters.
#: The values of these attributes should be the same for every aquisition
#: sharing a ``Project × SequenceName`` pair (across all sessions of a Project).
#:
#: We consider the acquistion to have a Quallity Assurance error
#: when the value of any of these parameters in a single acquisition
#: fails to match the template.
#:
#: For example ``TR`` for task EPI acquistion identified by
#: ``SequenceName=RewardedAnti`` in ``Project=WPC-8620``
#: should always be ``1300`` ms.
#:
#: .. image:: ../../sphinx/imgs/nonconforming_example.png
CONSTS = [
"Project",
"SequenceName",
Expand Down Expand Up @@ -121,14 +135,14 @@ def check_acq(self, d):
cur = self.sql.execute(self.find_acq, acq_search_vals)
acq = cur.fetchone()
if acq:
logging.debug(f"have acq {acq[0]} {acq_search_vals}")
logging.info("have acq %s %s",acq[0], acq_search_vals)
return True
return False

def param_rowid(self, d):
"""
Find or insert the combination of parameters for an aquisition.
Using ``CONSTS``, the header parameters that should be invarient
Using :py:data:`CONSTS`, the header parameters that should be invarient
across acquistions of the same name within a study.
>>> db = DBQuery(sqlite3.connect(':memory:'))
Expand Down
2 changes: 1 addition & 1 deletion change_header.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Modify DICOM header information.
Modify DICOM header information to simulate failing QA.
"""
import os
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion dcmmeta2tsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def read_tags(dcm_path: os.PathLike, tags: TagDicts) -> list[str]:
"""
:param dcm_path: dicom file with headers to extract
:param tags: ordered dictionary with 'tag' key as hex pair, see :py:func:`tagpair_to_hex`
:return: list of tag values in same order as ``tags``
:return: list of tag values in same order as ``tags`` \
BUT with CSA headers ``pedp``, ``ipat`` prepended
"""
if not os.path.isfile(dcm_path):
Expand Down
Binary file added sphinx/imgs/nonconforming_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mrrc-hdr-qa documentation

Code to parse dicoms into a template database and alert on non-conforming sequences.

Code
--------

.. toctree::
:caption: Contents:
Expand All @@ -16,6 +18,29 @@ Code to parse dicoms into a template database and alert on non-conforming sequen
:toctree: _autosummary
:recursive:

change_header
dcmmeta2tsv
acq2sqlite
change_header


Overview
--------

See :py:data:`acq2sqlite.DBQuery.CONSTS`

.. image:: ../sphinx/imgs/nonconforming_example.png



.. `https://dicom-parser.readthedocs.io/en/latest/siemens/csa_headers.html#csa-headers`_
Parameters
----------

.. csv-table:: Dicom tag list
:file: ../taglist.txt
:delimiter: \t
:header-rows: 1

.. .. include:: ../readme.md

0 comments on commit 1805141

Please sign in to comment.