From 8da2b432959300725dc9a47848badf71f99c290e Mon Sep 17 00:00:00 2001 From: bpinsard Date: Mon, 21 Oct 2024 10:30:42 -0400 Subject: [PATCH] fix glob patterns for #739 induced regression --- heudiconv/external/dlad.py | 6 +++--- heudiconv/tests/test_regression.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/heudiconv/external/dlad.py b/heudiconv/external/dlad.py index dd9daeae..cb2decfc 100644 --- a/heudiconv/external/dlad.py +++ b/heudiconv/external/dlad.py @@ -156,12 +156,12 @@ def add_to_datalad( # Provide metadata for sensitive information sensitive_patterns = [ - "sourcedata", + "sourcedata/**", "*_scans.tsv", # top level "*/*_scans.tsv", # within subj "*/*/*_scans.tsv", # within sess/subj - "*/anat", # within subj - "*/*/anat", # within ses/subj + "*/anat/*", # within subj + "*/*/anat/*", # within ses/subj ] for sp in sensitive_patterns: mark_sensitive(ds, sp, annexed_files) diff --git a/heudiconv/tests/test_regression.py b/heudiconv/tests/test_regression.py index 6e57be4d..30fe57b5 100644 --- a/heudiconv/tests/test_regression.py +++ b/heudiconv/tests/test_regression.py @@ -55,6 +55,7 @@ def test_conversion( heuristic, anon_cmd, template="sourcedata/sub-{subject}/*/*/*.tgz", + xargs=["--datalad"], ) runner(args) # run conversion @@ -96,6 +97,18 @@ def test_conversion( for key in keys: assert orig[key] == conv[key] + # validate sensitive marking + from datalad.api import Dataset + + ds = Dataset(outdir) + all_meta = dict(ds.repo.get_metadata(".")) + target_rec = {"distribution-restrictions": ["sensitive"]} + for pth, meta in all_meta.items(): + if "anat" in pth or "scans.tsv" in pth: + assert meta == target_rec + else: + assert meta == {} + @pytest.mark.skipif(not have_datalad, reason="no datalad") def test_multiecho(