Skip to content

Commit 39b3988

Browse files
authored
Merge branch 'master' into fmriprep_example
2 parents bdf4533 + d2e49ea commit 39b3988

File tree

71 files changed

+2134
-6
lines changed

Some content is hidden

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

71 files changed

+2134
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ venv*
1212
venv3.11/
1313
.idea/*
1414
.pytest_cache/*
15+
build/*
16+
*.egg-info

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
path = examples/fmriprep/ds001734
33
url = [email protected]:OpenNeuroDatasets/ds001734.git
44
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

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Camille Maumet ([@cmaumet](https://github.com/cmaumet)) and Satrajit Ghosh ([@sa
3434
- Cyril Regan ([@cyril-data](https://github.com/cyril-data))<a href="https://github.com/bids-standard/BEP028_BIDSprov/commits?author=cyril-data" title="Code">💻</a><a href="https://github.com/bids-standard/BEP028_BIDSprov/pulls?q=is%3Apr+reviewed-by%3Acyril-data" title="Reviewed Pull Requests">👀</a><a href="https://github.com/bids-standard/BEP028_BIDSprov/commits?author=cyril-data" title="Documentation">📖</a>
3535
<a href="https://github.com/bids-standard/BEP028_BIDSprov/issues?q=author%3Acyril-data" title="Bug reports">🐛</a>
3636

37+
- Boris Clénet ([@bclenet](https://github.com/bclenet))<a href="https://github.com/bids-standard/BEP028_BIDSprov/commits?author=bclenet" title="Code">💻</a><a href="https://github.com/bids-standard/BEP028_BIDSprov/commits?author=bclenet" title="Documentation">📖</a><a href="https://github.com/bids-standard/BEP028_BIDSprov/issues?q=author%3Abclenet" title="Bug reports">🐛</a>
38+
3739
This project follows the
3840
[all-contributors](https://github.com/all-contributors/all-contributors)
3941
specification. Contributions of any kind welcome!
@@ -80,7 +82,41 @@ Mature building blocks of NIDM:
8082
[New features (to be included)](new_features.md)
8183

8284

83-
## Run parsers on the SPM, FSL and AFNI data
85+
## Using the code
86+
87+
### Visualize your BIDSprov data
88+
89+
To visualize your BIDSprov data, perform the following steps :
90+
1. [clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) the code inside a `BEP028_BIDSprov` directory, and cd into this directory :
91+
92+
```shell
93+
git clone [email protected]:bids-standard/BEP028_BIDSprov.git
94+
cd BEP028_BIDSprov
95+
```
96+
97+
3. install the `bids_prov` python package :
98+
99+
```shell
100+
pip install .
101+
```
102+
103+
4. you should be able to launch the visualizer on your .jsonld files with the command `bids_prov_visualizer`
104+
105+
```shell
106+
bids_prov_visualizer --input_file graph.jsonld --output_file graph.png
107+
108+
bids_prov -h
109+
usage: bids_prov_visualizer [-h] --input_file INPUT_FILE [--output_file OUTPUT_FILE]
110+
111+
options:
112+
-h, --help show this help message and exit
113+
--input_file INPUT_FILE
114+
input BIDSprov data as a .jsonld file
115+
--output_file OUTPUT_FILE
116+
output .png file showing BIDSprov graph
117+
```
118+
119+
### Run parsers on the SPM, FSL and AFNI data
84120

85121
To obtain data in **bids-prov format**, you can use the developed parsers.
86122
* [Tutorial](https://github.com/bids-standard/BEP028_BIDSprov/blob/master/bids_prov/README.md)

bep028spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ Details of the context, will encode terminology that is consistent across BIDS a
799799
```
800800

801801

802-
Contexts are created at the BIDS organization level, and only if necessary extended by a dataset. Thus most dataset creators will be able to reuse existing contexts. For terms, many of these are already in BIDS, with additional ones being curated by the NIDM-terms grant. Additional, terms can and should be re-used from schema.org, bioschemas, and other ontologies and vocabularies whenever possible.
802+
Contexts are created at the BIDS organization level, and only if necessary extended by a dataset. Thus most dataset creators will be able to reuse existing contexts. For terms, many of these are already in BIDS, with additional ones being curated by the NIDM-terms grant. Additional, terms can and should be reused from schema.org, bioschemas, and other ontologies and vocabularies whenever possible.
803803

804804

805805
<!-- Footnotes themselves at the bottom. -->

bids_prov/visualize.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ def main(filename: str, output_file=None, omit_details=True) -> None:
113113
viz_jsonld11(jsonld11, output_file)
114114

115115

116-
if __name__ == "__main__":
117-
116+
def entry_point():
117+
""" A command line tool for the visualize module """
118118
parser = argparse.ArgumentParser()
119-
parser.add_argument("--input_file", type=str, default="res.jsonld", help="data jsonld file ")
120-
parser.add_argument("--output_file", type=str, default="res.png", help="output dir where results are written")
119+
parser.add_argument("--input_file", type=str, help="input BIDSprov data as a .jsonld file ", required=True)
120+
parser.add_argument("--output_file", type=str, default="output_graph.png", help="output .png file showing BIDSprov graph")
121121
opt = parser.parse_args()
122122

123123
main(opt.input_file, output_file=opt.output_file, omit_details=True)
124124
# >> python -m bids_prov.visualize --input_file ./res_temp.jsonld --output_file res.png
125+
126+
if __name__ == "__main__":
127+
entry_point()

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+
}

0 commit comments

Comments
 (0)