Skip to content

Commit 2afe136

Browse files
bpinsardyarikoptic
authored andcommitted
change tostr -> tobytes for deprecation, add basic test
1 parent 517ffdc commit 2afe136

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

heudiconv/heuristics/convertall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def custom_seqinfo(wrapper: dw.Wrapper, series_files: list[str], **kw: Any) -> t
2626
# in https://github.com/nipy/heudiconv/pull/333
2727
from nibabel.nicom.dicomwrappers import WrapperError
2828
try:
29-
affine = wrapper.affine.tostring()
29+
affine = wrapper.affine.tobytes()
3030
except WrapperError:
3131
lgr.exception("Errored out while obtaining/converting affine")
3232
affine = None

heudiconv/tests/test_dicoms.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@ def test_group_dicoms_into_seqinfos() -> None:
9999
]
100100

101101

102+
def test_custom_seqinfo() -> None:
103+
"""Tests for custom seqinfo extraction"""
104+
105+
from heudiconv.heuristics.convertall import custom_seqinfo
106+
107+
dcmfiles = glob(op.join(TESTS_DATA_PATH, "phantom.dcm"))
108+
109+
seqinfos = group_dicoms_into_seqinfos(
110+
dcmfiles,
111+
"studyUID",
112+
flatten=True,
113+
custom_seqinfo=custom_seqinfo)
114+
115+
seqinfo = list(seqinfos.keys())[0]
116+
117+
assert hasattr(seqinfo, 'custom')
118+
assert isinstance(seqinfo.custom, tuple)
119+
assert len(seqinfo.custom) == 2
120+
assert seqinfo.custom[1] == dcmfiles[0]
121+
102122
def test_get_datetime_from_dcm_from_acq_date_time() -> None:
103123
typical_dcm = dcm.dcmread(
104124
op.join(TESTS_DATA_PATH, "phantom.dcm"), stop_before_pixels=True

0 commit comments

Comments
 (0)