Skip to content

Commit 6fed542

Browse files
committed
Adding provenance record for the JSON sidecar
1 parent 5ae6839 commit 6fed542

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

examples/heudiconv/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ We introduce the following BIDS suffixes that are currently not existing:
144144
* `base`: the file describes common BIDS Prov parameters for the group of provenance traces (version and context for BIDS Prov)
145145

146146
We use the `GeneratedBy` field of JSON sidecars to link to Activities that created the file the sidecars refers to.
147+
We use the `SidecarGeneratedBy` field of JSON sidecars to link to Activities that created or modified the sidecars itself.
147148

148149
In this example, we rely on the fact that nodes defined in the `prov/*.prov.jsonld` files have `bids::prov/` as base IRIs.
149150

examples/heudiconv/code/merge_prov.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
'prov/prov-heudiconv_ent.prov.json'
2121
]
2222
sidecar_files = [
23-
'sub-001/sub-001_scans.json',
2423
'sub-001/anat/sub-001_run-1_T1w.json'
2524
]
2625

@@ -88,6 +87,12 @@
8887
"Id": f"bids::{data_file}",
8988
"GeneratedBy": activity_id
9089
})
90+
if 'SidecarGeneratedBy' in data:
91+
activity_id = data['SidecarGeneratedBy']
92+
base_provenance['Records']['Entities'].append({
93+
"Id": f"bids::{sidecar_filename}",
94+
"GeneratedBy": activity_id
95+
})
9196

9297
# Write jsonld
9398
with open('prov/merged/prov-heudiconv.prov.jsonld', 'w', encoding = 'utf-8') as file:

examples/heudiconv/prov/merged/prov-heudiconv.prov.jsonld

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@
9999
"GeneratedBy": "bids::prov/#preparation-conversion-1xkhm1ft",
100100
"Id": "bids::scans.json"
101101
},
102-
{
103-
"Id": "bids::sub-001/sub-001_scans.tsv",
104-
"GeneratedBy": "bids::prov/#preparation-conversion-1xkhm1ft"
105-
},
106102
{
107103
"Id": "bids::sub-001/anat/sub-001_run-1_T1w.nii.gz",
108104
"GeneratedBy": "bids::prov/#conversion-00f3a18f"
105+
},
106+
{
107+
"Id": "bids::sub-001/anat/sub-001_run-1_T1w.json",
108+
"GeneratedBy": [
109+
"bids::prov/#preparation-conversion-1xkhm1ft",
110+
"bids::prov/#conversion-00f3a18f"
111+
]
109112
}
110113
]
111114
},
5.87 KB
Loading

examples/heudiconv/sub-001/anat/sub-001_run-1_T1w.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@
1818
"SliceThickness": 0.666667,
1919
"SoftwareVersions": "0.4.11",
2020
"SpacingBetweenSlices": 0.666667,
21-
"GeneratedBy": "bids::prov/#conversion-00f3a18f"
21+
"GeneratedBy": "bids::prov/#conversion-00f3a18f",
22+
"SidecarGeneratedBy": [
23+
"bids::prov/#preparation-conversion-1xkhm1ft",
24+
"bids::prov/#conversion-00f3a18f"
25+
]
2226
}

0 commit comments

Comments
 (0)