Skip to content

Commit cfdd3d7

Browse files
bpinsardyarikoptic
authored andcommitted
run pre-commit magic!
1 parent 419ed48 commit cfdd3d7

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ You can run your conversion automatically (which will produce a ``.heudiconv`` d
7171
.. image:: figs/workflow.png
7272

7373

74-
``heudiconv`` comes with `existing heuristics <https://github.com/nipy/heudiconv/tree/master/heudiconv/heuristics>`_ which can be used as is, or as examples.
74+
``heudiconv`` comes with `existing heuristics <https://github.com/nipy/heudiconv/tree/master/heudiconv/heuristics>`_ which can be used as is, or as examples.
7575
For instance, the Heuristic `convertall <https://github.com/nipy/heudiconv/blob/master/heudiconv/heuristics/convertall.py>`_ extracts standard metadata from all matching DICOMs.
7676
``heudiconv`` creates mapping files, ``<something>.edit.text`` which lets researchers simply establish their own conversion mapping.
7777

heudiconv/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def prep_conversion(
223223
custom_grouping=getattr(heuristic, "grouping", None),
224224
# callable which will be provided dcminfo and returned
225225
# structure extend seqinfo
226-
custom_seqinfo=getattr(heuristic, 'custom_seqinfo', None),
226+
custom_seqinfo=getattr(heuristic, "custom_seqinfo", None),
227227
)
228228
elif seqinfo is None:
229229
raise ValueError("Neither 'dicoms' nor 'seqinfo' is given")

heudiconv/dicoms.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@
99
from pathlib import Path
1010
import sys
1111
import tarfile
12-
from typing import TYPE_CHECKING, Any, Dict, Hashable, List, NamedTuple, Optional, Union, Protocol, overload
12+
from typing import (
13+
TYPE_CHECKING,
14+
Any,
15+
Dict,
16+
Hashable,
17+
List,
18+
NamedTuple,
19+
Optional,
20+
Protocol,
21+
Union,
22+
overload,
23+
)
1324
from unittest.mock import patch
1425
import warnings
1526

@@ -90,14 +101,19 @@ def create_seqinfo(
90101
global total_files
91102
total_files += len(series_files)
92103

93-
custom_seqinfo_data = custom_seqinfo(wrapper=mw, series_files=series_files) \
94-
if custom_seqinfo else None
104+
custom_seqinfo_data = (
105+
custom_seqinfo(wrapper=mw, series_files=series_files)
106+
if custom_seqinfo
107+
else None
108+
)
95109
try:
96110
hash(custom_seqinfo_data)
97111
except TypeError:
98-
raise RuntimeError("Data returned by the heuristics custom_seqinfo is not hashable. "
99-
"See https://heudiconv.readthedocs.io/en/latest/heuristics.html#custom_seqinfo for more "
100-
"details.")
112+
raise RuntimeError(
113+
"Data returned by the heuristics custom_seqinfo is not hashable. "
114+
"See https://heudiconv.readthedocs.io/en/latest/heuristics.html#custom_seqinfo for more "
115+
"details."
116+
)
101117

102118
return SeqInfo(
103119
total_files_till_now=total_files,

heudiconv/heuristics/convertall.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from heudiconv.dicoms import dw
77
from heudiconv.utils import SeqInfo
88

9-
lgr = logging.getLogger('heudiconv')
9+
lgr = logging.getLogger("heudiconv")
1010

1111

1212
def create_key(
@@ -25,6 +25,7 @@ def custom_seqinfo(wrapper: dw.Wrapper, series_files: list[str]) -> tuple[str, s
2525
# the sample series file as was requested
2626
# in https://github.com/nipy/heudiconv/pull/333
2727
from nibabel.nicom.dicomwrappers import WrapperError
28+
2829
try:
2930
affine = wrapper.affine.tobytes()
3031
except WrapperError:

heudiconv/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def get_study_sessions(
224224
file_filter=getattr(heuristic, "filter_files", None),
225225
dcmfilter=getattr(heuristic, "filter_dicom", None),
226226
custom_grouping=getattr(heuristic, "grouping", None),
227-
custom_seqinfo=getattr(heuristic, 'custom_seqinfo', None),
227+
custom_seqinfo=getattr(heuristic, "custom_seqinfo", None),
228228
)
229229

230230
if sids:

heudiconv/tests/test_dicoms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ def test_custom_seqinfo() -> None:
107107
dcmfiles = glob(op.join(TESTS_DATA_PATH, "phantom.dcm"))
108108

109109
seqinfos = group_dicoms_into_seqinfos(
110-
dcmfiles,
111-
"studyUID",
112-
flatten=True,
113-
custom_seqinfo=custom_seqinfo)
110+
dcmfiles, "studyUID", flatten=True, custom_seqinfo=custom_seqinfo
111+
)
114112

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

117-
assert hasattr(seqinfo, 'custom')
115+
assert hasattr(seqinfo, "custom")
118116
assert isinstance(seqinfo.custom, tuple)
119117
assert len(seqinfo.custom) == 2
120118
assert seqinfo.custom[1] == dcmfiles[0]

0 commit comments

Comments
 (0)