Skip to content

Commit

Permalink
change tostr -> tobytes for deprecation, add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
bpinsard committed Jan 16, 2024
1 parent 806baa7 commit c715225
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion heudiconv/heuristics/convertall.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def custom_seqinfo(wrapper: dw.Wrapper, series_files: list[str], **kw: Any) -> t
# in https://github.com/nipy/heudiconv/pull/333
from nibabel.nicom.dicomwrappers import WrapperError
try:
affine = wrapper.affine.tostring()
affine = wrapper.affine.tobytes()
except WrapperError:
lgr.exception("Errored out while obtaining/converting affine")
affine = None
Expand Down
20 changes: 20 additions & 0 deletions heudiconv/tests/test_dicoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ def test_group_dicoms_into_seqinfos() -> None:
]


def test_custom_seqinfo() -> None:
"""Tests for custom seqinfo extraction"""

from heudiconv.heuristics.convertall import custom_seqinfo

dcmfiles = glob(op.join(TESTS_DATA_PATH, "phantom.dcm"))

seqinfos = group_dicoms_into_seqinfos(
dcmfiles,
"studyUID",
flatten=True,
custom_seqinfo=custom_seqinfo)

seqinfo = list(seqinfos.keys())[0]

assert hasattr(seqinfo, 'custom')
assert isinstance(seqinfo.custom, tuple)
assert len(seqinfo.custom) == 2
assert seqinfo.custom[1] == dcmfiles[0]

def test_get_datetime_from_dcm_from_acq_date_time() -> None:
typical_dcm = dcm.dcmread(
op.join(TESTS_DATA_PATH, "phantom.dcm"), stop_before_pixels=True
Expand Down

0 comments on commit c715225

Please sign in to comment.