Skip to content

Commit e53b4e0

Browse files
authored
Merge pull request #128 from mgxd/doc/rtd
DOC: Beef up readthedocs
2 parents 23c3bef + c9110f0 commit e53b4e0

File tree

7 files changed

+159
-92
lines changed

7 files changed

+159
-92
lines changed

README.md

Lines changed: 8 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,21 @@
11
# *NiBabies*: A robust preprocessing workflow tailored for neonate and infant MRI
22

3-
![nibabies](https://github.com/nipreps/nibabies/actions/workflows/pytest.yml/badge.svg)
4-
![coverage](https://codecov.io/gh/nipreps/nibabies/branch/master/graph/badge.svg)
3+
[![github](https://github.com/nipreps/nibabies/actions/workflows/pytest.yml/badge.svg)](https://github.com/nipreps/nibabies/actions)
4+
[![circle](https://circleci.com/gh/nipreps/nibabies/tree/master.svg?style=shield)](https://circleci.com/gh/nipreps/nibabies/tree/master)
5+
[![dockerhub](https://img.shields.io/badge/docker-nipreps/nibabies-brightgreen.svg?logo=docker&style=flat)](https://hub.docker.com/r/nipreps/nibabies/tags/)
6+
[![coverage](https://codecov.io/gh/nipreps/nibabies/branch/master/graph/badge.svg)](https://app.codecov.io/gh/nipreps/nibabies/branch/master)
7+
[![documentation](https://readthedocs.org/projects/nibabies/badge/?version=latest)](https://nibabies.readthedocs.io/en/latest/)
58
[![DOI](https://zenodo.org/badge/264223087.svg)](https://zenodo.org/badge/latestdoi/264223087)
69

710
Anatomical | Functional
811
---------- | ----------
912
![nibabies-anat](./docs/_static/nibabies_anat.png) | ![nibabies-func](./docs/_static/nibabies_func.png)
1013

11-
*NiBabies* is an extension of [fMRIPrep](https://fmriprep.org/en/stable/) designed and tested for infants 0-2 years old. *NiBabies* offers structural and functional MRI preprocessing.
14+
*NiBabies* is an open-source software pipeline designed to process anatomical and functional magnetic resonance imaging data.
15+
A member of the [NeuroImaging PREProcessing toolS (NiPreps)](https://www.nipreps.org/) family, *NiBabies* is designed and optimized for human infants between 0-2 years old.
1216

1317
---
1418

1519
## Getting Started
1620

17-
Before using *NiBabies*, you will need to have your MRI data formatted in [BIDS](https://bids.neuroimaging.io/).
18-
This helps the software locate the available data, and optimize the workflow accordingly.
19-
20-
### Installing NiBabies
21-
22-
Given its extensive dependencies, the easiest way to get up and running with *NiBabies* is by using the available [Docker](https://hub.docker.com/r/nipreps/nibabies/tags?page=1&ordering=last_updated) containers.
23-
24-
Images are all tagged with the release number, which must be specified in order to pull the images. For example, if you wanted to pull version `21.0.0rc1`, you would use the following command.
25-
```
26-
# Docker
27-
docker pull nipreps/nibabies:21.0.0rc1
28-
```
29-
30-
However, if you would prefer to install this tool natively, you can refer the [Dockerfile](./Dockerfile) as a guide for all the dependencies.
31-
32-
---
33-
34-
## Usage
35-
36-
*NiBabies* follow the [BIDS App Specifications](http://bids-apps.neuroimaging.io/about/), meaning you only need to provide three positional arguments:
37-
38-
- **bids_dir** - the root folder of a BIDS valid dataset.
39-
- **output_dir** - folder to store outputs and reports.
40-
- **level** - processing stage to be run, currently can only be `participant`.
41-
42-
However, as infant brains can vastly differ depending on age, providing the following arguments is highly recommended:
43-
44-
- **--age-months** - participant age in months
45-
> **_NOTE:_** This is required when using Infant FreeSurfer
46-
- **--segmentation-atlases-dir** - directory containing pre-labeled segmentations to use for Joint Label Fusion.
47-
48-
> **_NOTE:_** The segmentation directory should consist of one or more template directories containing:
49-
> - A segmented and labelled NIfTI that includes `Segmentation` in the filename.
50-
> - A brainmasked T1w NIfTI that includes `T1w` in the filename.
51-
52-
To view all options, see the [Command-Line Arguments](https://nibabies.readthedocs.io/usage.html#command-line-arguments) section of the documentation.
53-
54-
---
55-
56-
## Running with ``nibabies-wrapper``
57-
58-
The ``nibabies-wrapper`` is a lightweight Python 2/3 wrapper for running *NiBabies* via Docker and Singularity.
59-
It will generate a Docker/Singularity command line for you, print it out for reporting purposes, and then execute it without further action needed, e.g.:
60-
61-
62-
### Docker
63-
```
64-
$ nibabies-wrapper docker /path/to/data /path/to/output participant --age-months 12
65-
66-
RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=20.10.6 -it -v /path/to/data:/data:ro \
67-
-v /path/to/output:/out nipreps/nibabies:21.0.0rc1 /data /out participant --age-months 12
68-
```
69-
70-
### Singularity
71-
```
72-
$ nibabies-wrapper singularity /path/to/data /path/to/output participant --age-months 12 -i nibabies-21.0.0rc1.sif
73-
74-
RUNNING: singularity run --cleanenv -B /path/to/data:/data:ro \
75-
-B /path/to/output:/out nibabies-21.0.0rc1.sif /data /out participant --age-months 12
76-
```
77-
Note that the `-i` flag is required when using Singularity, and should be the path to the already built Singularity image file.
78-
79-
The ``nibabies-wrapper`` accepts all of the [available options for NiBabies](#usage), automatically translating local files and directories into mount points.
80-
81-
---
82-
83-
## Outputs
84-
85-
TODO - Refer to [fMRIPrep's outputs](https://fmriprep.org/en/20.2.1/outputs.html) for now.
21+
For comprehensive information on *NiBabies*, including installation and usage, visit [our documentation](https://nibabies.readthedocs.io/en/latest).

docs/conf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# "nipype.sphinxext.plot_workflow",
3636
# "sphinxcontrib.napoleon",
3737
"sphinxarg.ext", # argparse extension
38-
"myst_nb",
38+
"myst_nb", # stop segregating rst/md
3939
]
4040

4141
autodoc_mock_imports = [
@@ -80,4 +80,10 @@
8080

8181
# -- MyST parameters ---------------------------------------------------------
8282

83-
myst_heading_anchors = 2
83+
myst_heading_anchors = 3
84+
myst_enable_extensions = [
85+
"colon_fence",
86+
]
87+
88+
# to avoid Python highlighting in literal text
89+
highlight_language = "none"

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
```{toctree}
99
:maxdepth: 2
1010
11+
installation
1112
usage
13+
outputs
1214
```

docs/installation.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Installation
2+
3+
## Container Installation
4+
5+
Given its extensive dependencies, the easiest way to get up and running with *NiBabies* is by using a container service, such as [Docker](https://www.docker.com/get-started) or [Singularity](https://sylabs.io/singularity/).
6+
7+
### Working with Docker
8+
9+
Images are hosted on our [Docker Hub](https://hub.docker.com/r/nipreps/nibabies).
10+
To pull an image, the specific version tag must be specified in order to pull the images.
11+
For example, if you want to pull version `21.0.0`, you would use the following command.
12+
```
13+
$ docker pull nipreps/nibabies:21.0.0
14+
```
15+
16+
There are also a few keyword tags, `latest` and `unstable`, that serve as special pointers.
17+
`latest` points to the latest release (excluding any betas or release candidates).
18+
`unstable` points to the most recent developmental change, and should only be used to test new features or fixes.
19+
20+
### Working with Singularity
21+
22+
The easiest way to create a Singularity image is to build from the [Docker](#working-with-docker) images hosted online.
23+
For example, if you want to build version `21.0.0`, you would use the following command.
24+
```
25+
$ singularity build nibabies-21.0.0.sif docker://nipreps/nibabies:21.0.0
26+
```
27+
28+
## Installing the nibabies-wrapper
29+
30+
The `nibabies-wrapper` is a lightweight Python tool to facilitate running `nibabies` within a container service.
31+
To install or upgrade to the current release:
32+
```
33+
$ pip install --update nibabies-wrapper
34+
```
35+
36+
For further details, see [](usage.md#using-the-nibabies-wrapper).
37+
38+
## Bare-metal Installation
39+
40+
If you would prefer to install this tool natively, you can refer the [Dockerfile](https://github.com/nipreps/nibabies/blob/master/Dockerfile) as a guide for all the dependencies.

docs/outputs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Outputs
2+
3+
Refer to [*fMRIPrep* outputs](https://fmriprep.org/en/latest/outputs.html)

docs/usage.md

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,118 @@ The *NiBabies* workflow takes as principal input the path of the dataset
66
that is to be processed.
77
The input dataset is required to be in valid
88
{abbr}`BIDS (The Brain Imaging Data Structure)` format,
9-
and it must include at least one T1-weighted and
9+
and it must include at least one T1-weighted and
1010
one T2-weighted structural image and
1111
(unless disabled with a flag) a BOLD series.
1212
We highly recommend that you validate your dataset with the free, online
1313
[BIDS Validator](http://bids-standard.github.io/bids-validator/).
1414

15-
The exact command to run *NiBabies* depends on the [Installation] method.
15+
The exact command to run *NiBabies* depends on the [Installation](./installation.md) method.
1616
The common parts of the command follow the
1717
[BIDS-Apps](https://github.com/BIDS-Apps) definition.
1818
Example:
1919

2020
```Shell
21-
fmriprep data/bids_root/ out/ participant -w work/
21+
$ nibabies data/bids_root/ out/ participant -w work/ --participant-id 01 --age-months 12
2222
```
2323

2424
Further information about BIDS and BIDS-Apps can be found at the
2525
[NiPreps portal](https://www.nipreps.org/apps/framework/).
2626

27+
## The FreeSurfer license
28+
29+
*NiBabies* uses FreeSurfer tools, which require a license to run.
30+
31+
To obtain a FreeSurfer license, simply register for free at https://surfer.nmr.mgh.harvard.edu/registration.html.
32+
33+
FreeSurfer will search for a license key file first using the `$FS_LICENSE` environment variable and then in the default path to the license key file (`$FREESURFER_HOME`/license.txt). If `$FS_LICENSE` is set, the [`nibabies-wrapper`](#using-the-nibabies-wrapper) will automatically handle setting the license within the container.
34+
Otherwise, you will need to use the `--fs-license-file` flag to ensure the license is available.
35+
2736
## Command-Line Arguments
2837
```{argparse}
2938
:ref: nibabies.cli.parser._build_parser
3039
:prog: nibabies
31-
:nodefault:
3240
:nodefaultconst:
3341
```
3442

35-
The command-line interface of the docker wrapper
43+
## More information on command-line arguments
44+
45+
At minimum, the following *positional* arguments are required.
46+
47+
- **`bids_dir`** - the root folder of a BIDS valid dataset.
48+
- **`output_dir`** - folder to store outputs and reports.
49+
- **`level`** - processing stage to be run, currently can only be `participant`.
50+
51+
However, as infant brains can vastly differ depending on age, providing the following arguments is highly recommended:
52+
53+
- **`--age-months`** - participant age in months
54+
55+
:::{admonition} Warning
56+
:class: warning
57+
58+
This is required if FreeSurfer is not disabled (`--fs-no-reconall`)
59+
:::
60+
61+
- **`--participant-id`** - participant ID
62+
63+
:::{admonition} Tip
64+
:class: tip
65+
66+
This is recommended when using `--age-months` if age varies across participants.
67+
:::
68+
69+
- **`--segmentation-atlases-dir`** - directory containing pre-labeled segmentations to use for Joint Label Fusion.
70+
71+
:::{admonition} Tip
72+
:class: tip
73+
74+
The segmentation directory layout should consist of one or more template directories containing:
75+
* A segmented and labeled NIfTI that includes `Segmentation` in the filename.
76+
* A brainmasked T1w NIfTI that includes `T1w` in the filename.
77+
78+
:::
79+
80+
## Using the nibabies wrapper
81+
82+
The wrapper will generate a Docker or Singularity command line for you, print it out for reporting purposes, and then execute it without further action needed.
83+
For installation instructions, please see [](installation.md#installing-the-nibabies-wrapper)
84+
85+
### Sample Docker usage
86+
87+
```
88+
$ nibabies-wrapper docker /path/to/data /path/to/output participant --age-months 12 --fs-license-file /usr/freesurfer/license.txt
89+
90+
RUNNING: docker run --rm -e DOCKER_VERSION_8395080871=20.10.6 -it -v /path/to/data:/data:ro \
91+
-v /path/to/output:/out -v /usr/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
92+
nipreps/nibabies:21.0.0 /data /out participant --age-months 12
93+
...
94+
```
95+
96+
:::{admonition} Docker usage warning
97+
:class: warning
98+
99+
When using Docker, the wrapper will default to using the same version of `nibabies` as the wrapper.
100+
This can be overridden by using the `-i` flag to specify a particular Docker image.
101+
:::
102+
103+
### Sample Singularity usage
104+
105+
```
106+
$ nibabies-wrapper singularity /path/to/data /path/to/output participant --age-months 12 -i nibabies-21.0.0rc1.sif --fs-license-file /usr/freesurfer/license.txt
107+
108+
RUNNING: singularity run --cleanenv -B /path/to/data:/data:ro \
109+
-B /path/to/output:/out -B /usr/freesurfer/license.txt:/opt/freesurfer/license.txt:ro \
110+
nibabies-21.0.0.sif /data /out participant --age-months 12
111+
...
112+
```
113+
114+
:::{admonition} Singularity usage warning
115+
:class: warning
116+
117+
Note that the `-i` flag is required when using Singularity, and should be the path to the already built Singularity image file.
118+
:::
119+
120+
The command-line interface of the nibabies wrapper
36121
------------------------------------------------
37122

38123
```{argparse}
@@ -41,6 +126,3 @@ The command-line interface of the docker wrapper
41126
:nodefault:
42127
:nodefaultconst:
43128
```
44-
45-
46-

wrapper/nibabies_wrapper.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#!/usr/bin/env python
22
"""
3-
The NiBabies wrapper for Docker/Singularity
4-
5-
6-
This is a Python wrapper to run NiBabies through a container service.
3+
This is a Python wrapper to facilitate running NiBabies through Docker or Singularity services.
74
Docker or Singularity must be installed and running.
8-
This can be checked by running either ::
5+
To test installation, you can use one of the following:
96
10-
docker info
11-
singularity version
7+
```bash
8+
docker info
9+
singularity version
10+
```
1211
1312
Please report any feedback to our GitHub repository
1413
(https://github.com/nipreps/nibabies) and do not
@@ -430,8 +429,7 @@ def _is_file(path, parser):
430429
"--fs-subjects-dir",
431430
metavar="PATH",
432431
type=os.path.abspath,
433-
help="Path to existing FreeSurfer subjects directory to reuse. "
434-
"(default: OUTPUT_DIR/freesurfer)",
432+
help="Path to existing Infant FreeSurfer subjects directory to reuse. ",
435433
)
436434
g_wrap.add_argument(
437435
"--config-file",
@@ -444,7 +442,7 @@ def _is_file(path, parser):
444442
"--anat-derivatives",
445443
metavar="PATH",
446444
type=os.path.abspath,
447-
help="Path to existing sMRIPrep/nibabies-anatomical derivatives to fasttrack "
445+
help="Path to existing NiBabies anatomical derivatives to fasttrack "
448446
"the anatomical workflow.",
449447
)
450448
g_wrap.add_argument(

0 commit comments

Comments
 (0)