Skip to content

Commit 1136b62

Browse files
committed
Third example for dcm2niix
1 parent 54a14b9 commit 1136b62

File tree

4 files changed

+84
-50
lines changed

4 files changed

+84
-50
lines changed

examples/dcm2niix_2/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ We are then able to visualize these provenance files using the following command
4242

4343
```shell
4444
pip install bids-prov==0.1.0
45-
bids_prov_visualizer --input_file prov/merged/dcm2niix.prov.jsonld --output_file prov/merged/dcm2niix.prov.png
45+
bids_prov_visualizer --input_file prov/merged/dcm2niix.prov.jsonld --output_file prov/merged/dcm2niix.prov.png
4646
```
4747

4848
![](/examples/dcm2niix_2/prov/merged/dcm2niix.prov.png)
@@ -51,13 +51,13 @@ pip install bids-prov==0.1.0
5151

5252
Dataset is the same as the one for [example dcm2niix_1](/BEP028_BIDSprov/examples/dcm2niix_1/README.md#source-dataset).
5353

54-
### Notes
54+
## Notes
5555

5656
In this example, we rely on the fact that nodes defined in the `prov/*.prov.jsonld` files have `bids::prov/` as base IRIs. Here are the involved nodes:
5757
* `bids::prov/#dcm2niix-xce5m9z3`
5858
* `bids::prov/#fedora-b7hmkmqd`
5959

60-
### Limitations
60+
## Limitations
6161

6262
The `bids::prov/#fedora-b7hmkmqd` node defined in `prov/environments.prov.jsonld` is defined as an `Entity` as the current context (commit [ce0eb77](https://github.com/bids-standard/BEP028_BIDSprov/commit/ce0eb774abd9527e594bd69212a87d5047864678)) does not define the `Environments` term.
6363

examples/dcm2niix_3/README.md

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
11
# BIDS Prov example for `dcm2niix`
22

3-
This example aims at showing the capture of provenance for a [`dcm2niix`](https://github.com/rordenlab/dcm2niix) usecase: converting DICOM data to Nifti files within a BIDS dataset.
3+
This example aims at showing provenance traces from a DICOM to Nifti conversion, performed by `dcm2niix` on a Linux-based (Fedora) operating system.
44

5-
Source data for this example can be found here: https://github.com/psychoinformatics-de/hirni-demo. This is a datalad dataset containing anatomical and functional MRI acquisitions. The contents of this dataset can be downloaded using:
5+
## Overview
66

7-
```shell
8-
mkdir sourcedata
9-
cd sourcedata
10-
datalad install --recursive https://github.com/psychoinformatics-de/hirni-demo.git
11-
```
7+
This time, we describe the provenance records using BIDS Prov, but inside several *JSON* files.
8+
9+
After conversion, and adding provenance traces, the resulting directory tree looks like this:
1210

13-
> [!NOTE] Note that the dataset must be added inside the `sourcedata/` directory.
11+
```
12+
prov/
13+
├── prov-dcm2niix_act.prov.json
14+
├── prov-dcm2niix_base.prov.json
15+
├── prov-dcm2niix_env.prov.json
16+
└── prov-dcm2niix_soft.prov.json
17+
sourcedata/
18+
sub-02/
19+
└── anat
20+
├── sub-02_T1w.json
21+
└── sub-02_T1w.nii
22+
```
1423

15-
## Purpose
24+
Note that the `sourcedata/` directory contains the source dataset described in the [section hereafter](#source-dataset).
1625

17-
The aim of the example is to describe the provenance records using BIDS Prov, but inside several *JSON* files.
1826
We use:
1927

20-
* the `GeneratedBy` field of JSON sidecars, already existing in the BIDS specification
28+
* the `GeneratedBy` field of JSON sidecar, already existing in the BIDS specification
2129
* modality agnostic files inside the `prov/` directory
2230

23-
as follows:
31+
## Provenance merge
2432

33+
The python script `code/merge_prov.py` aims at merging all provenance records into one JSON-LD graph.
34+
35+
```shell
36+
pip install bids-prov==0.1.0
37+
mkdir prov/merged/
38+
python code/merge_prov.py
2539
```
26-
.
27-
├── prov
28-
│ ├── prov-dcm2niix_act.prov.json
29-
│ ├── prov-dcm2niix_base.prov.json
30-
│ ├── prov-dcm2niix_env.prov.json
31-
│ └── prov-dcm2niix_soft.prov.json
32-
└── sub-02
33-
├── ses-20130717141500
34-
│ └── anat
35-
│ └── sub-02_ses-20130717141500_T1w.json
36-
└── ses-20140425155335
37-
└── func
38-
└── sub-02_ses-20140425155335_task-oneback_run-1_bold.json
40+
41+
## Provenance visualization
42+
43+
We are then able to visualize these provenance files using the following commands (current directory is `examples/dcm2niix_3/`):
44+
45+
```shell
46+
pip install bids-prov==0.1.0
47+
bids_prov_visualizer --input_file prov/merged/prov-dcm2niix.prov.jsonld --output_file prov/merged/prov-dcm2niix.prov.png
3948
```
4049

41-
## New features for BIDS / BIDS Prov
50+
![](/examples/dcm2niix_3/prov/merged/prov-dcm2niix.prov.png)
51+
52+
## Source dataset
53+
54+
Dataset is the same as the one for [example dcm2niix_1](/BEP028_BIDSprov/examples/dcm2niix_1/README.md#source-dataset).
55+
56+
## Notes
4257

4358
We introduce the following BIDS entity that is currently not existing:
4459
* `prov`
@@ -54,26 +69,6 @@ We introduce the following BIDS suffixes that are currently not existing:
5469

5570
We use the `GeneratedBy` field of JSON sidecars to link to `Activities` that created the file the sidecars refers to.
5671

57-
## Merging JSON in a JSON-LD file and plotting graph
58-
59-
The python script `code/merge_prov.py` aims at merging all these provenance records into one JSON-LD graph.
60-
61-
```shell
62-
mkdir prov/merged/
63-
python code/merge_prov.py
64-
```
65-
66-
From that, we generate the JSON-LD graph `prov/merge/prov-dcm2niix.prov.jsonld`. Then we were able to plot the graph as a png file. We used this command:
67-
68-
```shell
69-
pip install bids-prov==0.1.0
70-
bids_prov_visualizer --input_file prov/merged/prov-dcm2niix.prov.jsonld --output_file prov/merged/prov-dcm2niix.prov.png
71-
```
72-
73-
![](/examples/dcm2niix/prov/merged/prov-dcm2niix.prov.png)
74-
75-
### Notes
76-
7772
In this example, we rely on the fact that nodes defined in the `prov/*.prov.jsonld` files have `bids::prov/` as base IRIs.
7873

7974
The `code/merge_prov.py` code is responsible for:
@@ -86,7 +81,6 @@ The `code/merge_prov.py` code is responsible for:
8681

8782
2. Listing all the DICOM files used by the dcm2niix conversion steps would lower readability of the JSON-LD provenance files. Therefore we only listed the following directories as `Entities`:
8883
* `bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms`
89-
* `bids::sourcedata/hirni-demo/acq2/dicoms/example-dicom-functional-master/dicoms`
9084

9185
although it is not allowed by the current version of the BIDS Prov specification to have directories as `Entities`.
9286

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"Records": {
3+
"Software": [
4+
{
5+
"Label": "dcm2niix",
6+
"Version": "v1.0.20220720",
7+
"Id": "bids::prov/#dcm2niix-khhkm7u1"
8+
}
9+
],
10+
"Activities": [
11+
{
12+
"Label": "Conversion",
13+
"Command": "dcm2niix -o . -f sub-%i/anat/sub-%i_T1w sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms",
14+
"AssociatedWith": "bids::prov/#dcm2niix-khhkm7u1",
15+
"Used": [
16+
"bids::prov/#fedora-uldfv058",
17+
{
18+
"Id": "bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms",
19+
"Type": "Entity",
20+
"Label": "dicoms"
21+
}
22+
],
23+
"Id": "bids::prov/#conversion-00f3a18f"
24+
}
25+
],
26+
"Entities": [
27+
{
28+
"Label": "Fedora release 36 (Thirty Six)",
29+
"OperatingSystem": "GNU/Linux 6.2.15-100.fc36.x86_64",
30+
"Id": "bids::prov/#fedora-uldfv058"
31+
},
32+
{
33+
"Id": "bids::sub-02/anat/sub-02_T1w.nii",
34+
"GeneratedBy": "bids::prov/#conversion-00f3a18f"
35+
}
36+
]
37+
},
38+
"@context": "https://purl.org/nidash/bidsprov/context.json",
39+
"BIDSProvVersion": "0.0.1"
40+
}
35.9 KB
Loading

0 commit comments

Comments
 (0)