Skip to content

Commit 04c1b90

Browse files
authored
Merge pull request #1286 from nipreps/fix/1282-multiecho-list-bugs
ENH: Flatten multi-echo lists in circumstances that they fail
2 parents 7fe5335 + 03dfda2 commit 04c1b90

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

mriqc/utils/misc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import json
2626
from collections import OrderedDict
27+
from collections.abc import Iterable
2728
from pathlib import Path
2829

2930
import pandas as pd
@@ -237,6 +238,14 @@ def _flatten_dict(indict):
237238
return out_qc
238239

239240

241+
def _flatten_list(xs):
242+
for x in xs:
243+
if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):
244+
yield from _flatten_list(x)
245+
else:
246+
yield x
247+
248+
240249
def _datalad_get(input_list, nprocs=None):
241250
from mriqc import config
242251

@@ -255,7 +264,7 @@ def _datalad_get(input_list, nprocs=None):
255264
25, 'DataLad dataset identified, attempting to `datalad get` unavailable files.'
256265
)
257266
return get(
258-
input_list,
267+
list(_flatten_list(input_list)),
259268
dataset=str(config.execution.bids_dir),
260269
jobs=nprocs
261270
if not None

mriqc/workflows/functional/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
This workflow is orchestrated by :py:func:`fmri_qc_workflow`.
4444
"""
4545

46+
from collections.abc import Iterable
47+
4648
import nibabel as nb
4749
from nipype.interfaces import utility as niu
4850
from nipype.pipeline import engine as pe
@@ -87,7 +89,11 @@ def fmri_qc_workflow(name='funcMRIQC'):
8789
full_files = []
8890
for bold_path in dataset:
8991
try:
90-
bold_len = nb.load(bold_path).shape[3]
92+
bold_len = nb.load(
93+
bold_path[0]
94+
if isinstance(bold_path, Iterable) and not isinstance(bold_path, (str, bytes))
95+
else bold_path
96+
).shape[3]
9197
except nb.filebasedimages.ImageFileError:
9298
bold_len = config.workflow.min_len_bold
9399
except IndexError: # shape has only 3 elements

0 commit comments

Comments
 (0)