Skip to content

Commit 2e6abda

Browse files
authored
Merge branch 'master' into spec
2 parents 6c073ac + 810dfb3 commit 2e6abda

File tree

150 files changed

+235170
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+235170
-4
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[codespell]
2-
skip = .git,*.pdf,*.svg,venvs,./examples/from_parsers
2+
skip = .git,*.pdf,*.svg,venvs,./examples/from_parsers,*.trig
33
#
44
# ignore-words-list =

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ settings.json
55
**/*.gz
66
.datalad
77
**/*.tsv
8-
*.json
98
**/*.pyc
109
*.DS_Store
1110
*.ipynb_checkpoints

.gitmodules

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[submodule "examples/fmriprep/ds001734"]
2+
path = examples/fmriprep/ds001734
3+
url = [email protected]:OpenNeuroDatasets/ds001734.git
4+
datalad-id = ca05bc10-29a0-11e9-9a7b-0242ac13000d
5+
[submodule "examples/heudiconv/sourcedata/hirni-demo"]
6+
path = examples/heudiconv/sourcedata/hirni-demo
7+
url = https://github.com/psychoinformatics-de/hirni-demo.git

examples/dcm2niix_1/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# BIDS Prov example #1 for `dcm2niix`
2+
3+
This example aims at showing provenance traces from a DICOM to Nifti conversion, performed by `dcm2niix` on a Linux-based (Fedora) operating system.
4+
5+
## Overview
6+
7+
We use the single file `prov/dcm2niix.prov.jsonld` to store all provenance traces relative to the conversion steps.
8+
9+
After conversion, and adding provenance traces, the resulting directory tree looks like this:
10+
11+
```
12+
prov/
13+
└── dcm2niix.prov.jsonld
14+
sourcedata/
15+
sub-02/
16+
└── anat
17+
├── sub-02_T1w.json
18+
└── sub-02_T1w.nii
19+
```
20+
21+
Note that the `sourcedata/` directory contains the source dataset described in the [section hereafter](#source-dataset).
22+
23+
## Provenance visualization
24+
25+
We are able to visualize these provenance files using the following commands (current directory is `examples/dcm2niix_1/`):
26+
27+
```shell
28+
pip install bids-prov==0.1.0
29+
bids_prov_visualizer --input_file prov/dcm2niix.prov.jsonld --output_file prov/dcm2niix.prov.png
30+
```
31+
32+
![](/examples/dcm2niix_1/prov/dcm2niix.prov.png)
33+
34+
## Source dataset
35+
36+
We get raw data from https://github.com/psychoinformatics-de/hirni-demo.git, a demo datalad dataset containing dicoms.
37+
38+
```shell
39+
# Get example dicom(s) in a sourcedata/ directory
40+
mkdir sourcedata
41+
cd sourcedata
42+
datalad install --recursive https://github.com/psychoinformatics-de/hirni-demo.git
43+
cd acq1
44+
datalad get ./*
45+
cd ..
46+
ls -1
47+
acq1
48+
acq2
49+
code
50+
dataset_description.json
51+
README
52+
studyspec.json
53+
cd ..
54+
```
55+
56+
Note that we will only convert the anatomical data available in this dataset (`acq1/` directory).
57+
58+
## Perform the conversions
59+
60+
Install `dcm2niix`.
61+
62+
```shell
63+
sudo yum install dcm2niix
64+
```
65+
66+
With this setup we are ready to convert dicoms to nifti files using `dcm2niix`.
67+
68+
```shell
69+
dcm2niix -o . -f sub-%i/anat/sub-%i_T1w sourcedata/acq1/dicoms/example-dicom-structural-master/dicoms/
70+
```
71+
72+
## Limitations
73+
74+
### `Used` key for activities
75+
76+
Although the BIDS-Prov spec mentions:
77+
78+
> Used : OPTIONAL. UUID. Identifier of an entity used by this activity (the corresponding Entity must be defined with its own Entity record).
79+
80+
We represented used entities in a list to link all the dicom files of a directory to the corresponding conversion activity.
81+
82+
### `Environments` not defined in the context
83+
84+
We cannot use an `Environments` list because the current context (commit ce0eb77) does not define the `Environments` term. Therefore, we defined the `urn:fedora-b7hmkmqd` environments as an `Entity`.
85+
86+
### High number of dicom files
87+
88+
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`:
89+
90+
```
91+
bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms
92+
```
93+
94+
although it is not allowed by the current version of the BIDS Prov specification to have directories as `Entities`.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"@context": "https://purl.org/nidash/bidsprov/context.json",
3+
"BIDSProvVersion": "0.0.1",
4+
"Records": {
5+
"Software": [
6+
{
7+
"Id": "urn:dcm2niix-xce5m9z3",
8+
"Label": "dcm2niix",
9+
"Version": "v1.0.20220720"
10+
}
11+
],
12+
"Activities": [
13+
{
14+
"Id": "urn:conversion-00f3a18f",
15+
"Label": "Conversion",
16+
"Command": "dcm2niix -o . -f sub-%i/anat/sub-%i_T1w sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms/",
17+
"AssociatedWith": "urn:dcm2niix-xce5m9z3",
18+
"Used": [
19+
"urn:fedora-b7hmkmqd",
20+
"bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms"
21+
]
22+
}
23+
],
24+
"Entities": [
25+
{
26+
"Id": "bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms",
27+
"Label": "dicoms"
28+
},
29+
{
30+
"Id": "bids::sub-02/anat/sub-02_ses-20130717141500_T1w.nii",
31+
"Label": "sub-02_T1w.nii",
32+
"GeneratedBy": "urn:conversion-00f3a18f"
33+
},
34+
{
35+
"Id": "bids::sub-02/anat/sub-02_ses-20130717141500_T1w.json",
36+
"Label": "sub-02_T1w.json",
37+
"GeneratedBy": "urn:conversion-00f3a18f"
38+
},
39+
{
40+
"Id": "urn:fedora-b7hmkmqd",
41+
"Label": "Fedora release 36 (Thirty Six)",
42+
"OperatingSystem": " GNU/Linux 6.2.15-100.fc36.x86_64"
43+
}
44+
]
45+
}
46+
}
56.4 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit f5aa766d900037d97c82329e7dfc94ee80086b92
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"Modality": "MR",
3+
"ManufacturersModelName": "nifti2dicom",
4+
"SoftwareVersions": "0.4.11",
5+
"SeriesDescription": "anat-T1w",
6+
"ProtocolName": "anat-T1w",
7+
"ImageType": ["DERIVED", "SECONDARY"],
8+
"RawImage": false,
9+
"SeriesNumber": 401,
10+
"AcquisitionTime": "13:25:18.000000",
11+
"AcquisitionNumber": 1,
12+
"SliceThickness": 0.666667,
13+
"SpacingBetweenSlices": 0.666667,
14+
"ImageOrientationPatientDICOM": [
15+
0.999032,
16+
-0.0217884,
17+
0.0382096,
18+
0.0265195,
19+
0.991414,
20+
-0.128044 ],
21+
"ConversionSoftware": "dcm2niix",
22+
"ConversionSoftwareVersion": "v1.0.20220720"
23+
}

examples/dcm2niix_1/sub-02/anat/sub-02_T1w.nii

Whitespace-only changes.

examples/dcm2niix_2/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# BIDS Prov example #2 for `dcm2niix`
2+
3+
This example aims at showing provenance traces from a DICOM to Nifti conversion, performed by `dcm2niix` on a Linux-based (Fedora) operating system.
4+
5+
## Overview
6+
7+
We use JSON-LD sidecars and modality agnostic files inside the `prov/` directory to store all provenance traces.
8+
9+
After conversion, and adding provenance traces, the resulting directory tree looks like this:
10+
11+
```
12+
prov/
13+
├── environments.prov.jsonld
14+
└── software.prov.jsonld
15+
sourcedata/
16+
sub-02/
17+
└── anat/
18+
├── prov/
19+
│ └── sub-02_T1w.prov.jsonld
20+
├── sub-02_T1w.json
21+
└── sub-02_T1w.nii
22+
23+
```
24+
25+
Note that the `sourcedata/` directory contains the source dataset described in the [section hereafter](#source-dataset).
26+
27+
* `prov/sub-02_T1w.prov.jsonld` is a "sidecar" defining provenance for the corresponding `.nii` file.
28+
* `environments.prov.jsonld` mutualises the declaration of software environments objects for lower level prov files
29+
* `software.prov.jsonld` mutualises the declaration of software pieces objects for lower level prov files
30+
31+
## Provenance merge
32+
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
39+
```
40+
41+
## Provenance visualization
42+
43+
We are then able to visualize these provenance files using the following commands (current directory is `examples/dcm2niix_2/`):
44+
45+
```shell
46+
pip install bids-prov==0.1.0
47+
bids_prov_visualizer --input_file prov/merged/dcm2niix.prov.jsonld --output_file prov/merged/dcm2niix.prov.png
48+
```
49+
50+
![](/examples/dcm2niix_2/prov/merged/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
57+
58+
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:
59+
* `bids::prov/#dcm2niix-xce5m9z3`
60+
* `bids::prov/#fedora-b7hmkmqd`
61+
62+
## Limitations
63+
64+
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.
65+
66+
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`:
67+
* `bids::sourcedata/hirni-demo/acq1/dicoms/example-dicom-structural-master/dicoms`
68+
* `bids::sourcedata/hirni-demo/acq2/dicoms/example-dicom-functional-master/dicoms`
69+
70+
although it is not allowed by the current version of the BIDS Prov specification to have directories as `Entities`.

0 commit comments

Comments
 (0)