Skip to content

Commit

Permalink
Transpose list of lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Oct 15, 2023
1 parent 53f01cc commit d5f1376
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions xcp_d/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,8 @@ def _make_dictionary(metadata=None, **kwargs):
def _out_file_to_source(in_file, dataset_name, dataset_path):
bids_uri = [f"bids:{dataset_name}:{str(Path(in_file).relative_to(dataset_path))}"]
return bids_uri


def _transpose_lol(lol):
"""Transpose list of lists."""
return list(map(list, zip(*lol)))
8 changes: 6 additions & 2 deletions xcp_d/workflows/concatenation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
FilterOutFailedRuns,
)
from xcp_d.utils.doc import fill_doc
from xcp_d.utils.utils import _make_dictionary, _select_first
from xcp_d.utils.utils import _make_dictionary, _select_first, _transpose_lol
from xcp_d.workflows.plotting import init_qc_report_wf


Expand Down Expand Up @@ -311,7 +311,11 @@ def init_concatenate_data_wf(
name="make_timeseries_dict",
iterfield=["Sources"],
)
workflow.connect([(timeseries_src, make_timeseries_dict, [("bids_uris", "Sources")])])
# fmt:off
workflow.connect([
(timeseries_src, make_timeseries_dict, [(("bids_uris", _transpose_lol), "Sources")]),
])
# fmt:on

ds_timeseries = pe.MapNode(
DerivativesDataSink(
Expand Down

0 comments on commit d5f1376

Please sign in to comment.