diff --git a/xcp_d/tests/test_interfaces_bids.py b/xcp_d/tests/test_interfaces_bids.py index 36c760038..7d9e35ab4 100644 --- a/xcp_d/tests/test_interfaces_bids.py +++ b/xcp_d/tests/test_interfaces_bids.py @@ -1,4 +1,6 @@ """Tests for framewise displacement calculation.""" +from nipype.interfaces.base import isdefined + from xcp_d.interfaces import bids @@ -34,4 +36,4 @@ def test_infer_bids_uris(): dataset_path=dataset_path, ) out = infer_bids_uris.run() - assert out.outputs.bids_uris == [] + assert not isdefined(out.outputs.bids_uris) diff --git a/xcp_d/tests/test_utils_utils.py b/xcp_d/tests/test_utils_utils.py index f9002ad5f..5b649d603 100644 --- a/xcp_d/tests/test_utils_utils.py +++ b/xcp_d/tests/test_utils_utils.py @@ -416,11 +416,11 @@ def test_listify(): ] outputs = [ [1], - [1], + (1,), ["a"], ["a"], ["a", ["b", "c"]], - ["a", "b"], + ("a", "b"), ] for i, input_ in enumerate(inputs): expected_output = outputs[i] diff --git a/xcp_d/utils/bids.py b/xcp_d/utils/bids.py index 646161a2c..5eb0e5f6c 100644 --- a/xcp_d/utils/bids.py +++ b/xcp_d/utils/bids.py @@ -986,7 +986,7 @@ def _make_uri(in_file, dataset_name, dataset_path): ValueError If ``in_file`` is not relative to ``dataset_path``. """ - bids_uri = [f"bids:{dataset_name}:{str(Path(in_file).relative_to(dataset_path))}"] + bids_uri = f"bids:{dataset_name}:{str(Path(in_file).relative_to(dataset_path))}" return bids_uri @@ -1001,7 +1001,7 @@ def _make_xcpd_uri(out_file, output_dir): if isinstance(out_file, list): return [_make_uri(of, "xcp_d", dataset_path) for of in out_file] else: - return _make_uri(out_file, "xcp_d", dataset_path) + return [_make_uri(out_file, "xcp_d", dataset_path)] def _make_preproc_uri(out_file, fmri_dir): @@ -1011,7 +1011,7 @@ def _make_preproc_uri(out_file, fmri_dir): if isinstance(out_file, list): return [_make_uri(of, "preprocessed", fmri_dir) for of in out_file] else: - return _make_uri(out_file, "preprocessed", fmri_dir) + return [_make_uri(out_file, "preprocessed", fmri_dir)] def _make_custom_uri(out_file): @@ -1023,4 +1023,4 @@ def _make_custom_uri(out_file): if isinstance(out_file, list): return [_make_uri(of, "custom_confounds", os.path.dirname(of)) for of in out_file] else: - return _make_uri(out_file, "custom_confounds", os.path.dirname(out_file)) + return [_make_uri(out_file, "custom_confounds", os.path.dirname(out_file))] diff --git a/xcp_d/utils/utils.py b/xcp_d/utils/utils.py index a2c1a7777..f40ffdaf5 100644 --- a/xcp_d/utils/utils.py +++ b/xcp_d/utils/utils.py @@ -547,6 +547,8 @@ def _make_dictionary(metadata=None, **kwargs): """ from copy import deepcopy + from xcp_d.utils.utils import _listify + if metadata: out_metadata = deepcopy(metadata) for key, value in kwargs.items(): @@ -554,7 +556,7 @@ def _make_dictionary(metadata=None, **kwargs): out_metadata[key] = value elif isinstance(value, list): # Append the values if they're a list - out_metadata[key] += value + out_metadata[key] = _listify(out_metadata[key]) + value else: # Overwrite the old value out_metadata[key] = value