Skip to content

Commit

Permalink
Merge pull request #793 from UNFmontreal/fix/sensitive_marking
Browse files Browse the repository at this point in the history
Fix assignment of sensitive git-annex metadata data via glob patterns (regression introduced by #739)
  • Loading branch information
yarikoptic authored Oct 25, 2024
2 parents 7200a0b + 8da2b43 commit 93781c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions heudiconv/external/dlad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions heudiconv/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_conversion(
heuristic,
anon_cmd,
template="sourcedata/sub-{subject}/*/*/*.tgz",
xargs=["--datalad"],
)
runner(args) # run conversion

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 93781c7

Please sign in to comment.