File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,19 @@ or::
119
119
...
120
120
return seqinfos # ordered dict containing seqinfo objects: list of DICOMs
121
121
122
+ ---------------------------------------------------------------
123
+ ``custom_seqinfo(series_files, wrapper) ``
124
+ ---------------------------------------------------------------
125
+ If present this function will be called on eacg group of dicoms with
126
+ a sample nibabel dicom wrapper to extract additional information
127
+ to be used in ``infotodict ``.
128
+
129
+ Importantly the return value of that function needs to be hashable.
130
+ For instance the following non-hashable types can be converted to an alternative
131
+ hashable type:
132
+ - list > tuple
133
+ - dict > frozendict
134
+ - arrays > bytes (tobytes(), or pickle.dumps), str or tuple of tuples.
122
135
123
136
-------------------------------
124
137
``POPULATE_INTENDED_FOR_OPTS ``
Original file line number Diff line number Diff line change @@ -90,6 +90,15 @@ def create_seqinfo(
90
90
global total_files
91
91
total_files += len (series_files )
92
92
93
+ custom_seqinfo_data = custom_seqinfo (wrapper = mw , series_files = series_files ) \
94
+ if custom_seqinfo else None
95
+ try :
96
+ hash (custom_seqinfo_data )
97
+ 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." )
101
+
93
102
return SeqInfo (
94
103
total_files_till_now = total_files ,
95
104
example_dcm_file = op .basename (series_files [0 ]),
@@ -119,9 +128,7 @@ def create_seqinfo(
119
128
date = dcminfo .get ("AcquisitionDate" ),
120
129
series_uid = dcminfo .get ("SeriesInstanceUID" ),
121
130
time = dcminfo .get ("AcquisitionTime" ),
122
- custom =
123
- custom_seqinfo (wrapper = mw , series_files = series_files )
124
- if custom_seqinfo else None ,
131
+ custom = custom_seqinfo_data ,
125
132
)
126
133
127
134
You can’t perform that action at this time.
0 commit comments