Skip to content

Commit 9529f59

Browse files
authored
Merge pull request #383 from mgxd/doc/update-docs
DOC: First documentation pass
2 parents 80392f9 + 95a9e20 commit 9529f59

File tree

7 files changed

+653
-620
lines changed

7 files changed

+653
-620
lines changed

docs/community.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
## NiPreps Community
1+
# NiPreps Community
22

33
Check out the [official NiPreps community page](https://www.nipreps.org/community/), where topics such as contributing, code of conduct, and licensing are outlined.
44

5-
65
## NiBabies Coding Style
76

87
### Pre-commit

docs/conf.py

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,55 @@
66

77
import os
88
import sys
9-
from datetime import datetime
10-
from sphinx import __version__ as sphinxversion
9+
from datetime import datetime, timezone
10+
1111
from packaging.version import Version, parse
12+
from sphinx import __version__ as sphinxversion
13+
14+
import nibabies
1215

1316
# -- Path setup --------------------------------------------------------------
1417
here = os.path.dirname(__file__)
1518
# If extensions (or modules to document with autodoc) are in another directory,
1619
# add these directories to sys.path here. If the directory is relative to the
1720
# documentation root, use os.path.abspath to make it absolute, like shown here.
18-
sys.path.append(os.path.join(here, "sphinxext"))
19-
sys.path.insert(0, os.path.join(here, "..", "wrapper"))
21+
sys.path.append(os.path.join(here, 'sphinxext'))
22+
sys.path.insert(0, os.path.join(here, '..', 'wrapper'))
2023

21-
from github_link import make_linkcode_resolve # this is only available after sphinxext to PATH
24+
# this is only available after sphinxext to PATH
25+
from github_link import make_linkcode_resolve # noqa: E402
2226

2327
# -- General configuration ---------------------------------------------------
2428

2529
# If your documentation needs a minimal Sphinx version, state it here.
26-
needs_sphinx = "1.5.3"
30+
needs_sphinx = '1.5.3'
2731

2832
# Add any Sphinx extension module names here, as strings. They can be
2933
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3034
# ones.
3135
extensions = [
32-
"sphinx.ext.autodoc",
33-
"sphinx.ext.doctest",
34-
"sphinx.ext.intersphinx",
35-
"sphinx.ext.coverage",
36-
"sphinx.ext.mathjax",
37-
"sphinx.ext.linkcode",
38-
"sphinx.ext.napoleon",
39-
"sphinxarg.ext", # argparse extension
40-
"nipype.sphinxext.plot_workflow",
41-
"myst_nb", # stop segregating rst/md
36+
'sphinx.ext.autodoc',
37+
'sphinx.ext.doctest',
38+
'sphinx.ext.intersphinx',
39+
'sphinx.ext.coverage',
40+
'sphinx.ext.mathjax',
41+
'sphinx.ext.linkcode',
42+
'sphinx.ext.napoleon',
43+
'sphinxcontrib.bibtex',
44+
'sphinxarg.ext', # argparse extension
45+
'nipype.sphinxext.plot_workflow',
46+
'myst_parser', # allow markdown
47+
# 'sphinx-togglebutton', # collapse admonitions
4248
]
4349

44-
autodoc_mock_imports = [
45-
"numpy",
46-
"nibabel",
47-
"nilearn"
48-
]
49-
if parse(sphinxversion) >= parse("1.7.0"):
50-
autodoc_mock_imports += [
51-
"pandas",
52-
"nilearn",
53-
"seaborn",
50+
bibtex_bibfiles = ['../nibabies/data/boilerplate.bib']
51+
52+
autodoc_mock_imports = ['numpy', 'nibabel', 'nilearn']
53+
if parse(sphinxversion) >= parse('1.7.0'):
54+
autodoc_mock_imports = [
55+
'pandas',
56+
'nilearn',
57+
'seaborn',
5458
]
5559

5660
# Add any paths that contain templates here, relative to this directory.
@@ -62,14 +66,33 @@
6266
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
6367

6468

65-
source_suffix = [".rst", ".md"]
69+
source_suffix = ['.rst', '.md']
6670

6771
# -- Options for HTML output -------------------------------------------------
6872

6973
# The theme to use for HTML and HTML Help pages. See the documentation for
7074
# a list of builtin themes.
7175
#
72-
html_theme = 'sphinx_rtd_theme'
76+
html_theme = 'shibuya'
77+
78+
# Options specific to theme
79+
html_theme_options = {
80+
'color_mode': 'light',
81+
'dark_code': True,
82+
'github_url': 'https://github.com/nipreps/nibabies',
83+
'nav_links': [
84+
{
85+
'title': 'NiPreps Homepage',
86+
'url': 'https://nipreps.org',
87+
'external': True,
88+
},
89+
{
90+
'title': 'Docker Hub',
91+
'url': 'https://hub.docker.com/r/nipreps/nibabies',
92+
'external': True,
93+
},
94+
],
95+
}
7396

7497
# Add any paths that contain custom static files (such as style sheets) here,
7598
# relative to this directory. They are copied after the builtin static files,
@@ -83,40 +106,30 @@
83106
# https://github.com/sphinx-contrib/napoleon/pull/10 is merged.
84107
napoleon_use_param = False
85108
napoleon_custom_sections = [
86-
("Inputs", "Parameters"),
87-
("Outputs", "Parameters"),
109+
('Inputs', 'Parameters'),
110+
('Outputs', 'Parameters'),
88111
]
89112

90113
# -- MyST parameters ---------------------------------------------------------
91114

92115
myst_heading_anchors = 3
93116
myst_enable_extensions = [
94-
"colon_fence",
95-
"substitution",
117+
'colon_fence',
118+
'substitution',
96119
]
97120

98-
linkcode_resolve = make_linkcode_resolve("nibabies",
99-
"https://github.com/nipreps/"
100-
"nibabies/blob/{revision}/"
101-
"{package}/{path}#L{lineno}")
121+
linkcode_resolve = make_linkcode_resolve(
122+
'nibabies',
123+
'https://github.com/nipreps/' 'nibabies/blob/{revision}/' '{package}/{path}#L{lineno}',
124+
)
102125

103-
project = "NiBabies"
104-
author = "The NiPreps developers"
105-
copyright = "2021-%s, %s" % (datetime.now().year, author)
126+
project = 'NiBabies'
127+
author = 'The NiPreps developers'
106128

107-
import nibabies
129+
copyright = f'2021-{datetime.now(tz=timezone.utc)}, {author}'
108130

109131
nibabies_ver = Version(nibabies.__version__)
110-
release = "version" if nibabies_ver.is_prerelease else nibabies_ver.public
111-
112-
myst_substitutions = {
113-
"release": release,
114-
"version": str(nibabies_ver),
115-
"dockerbuild": "docker pull nipreps/nibabies:{{ release }}",
116-
"singbuild": (
117-
"singularity build nibabies-{{ release }}.sif docker://nipreps/nibabies:{{ release }}"
118-
),
119-
}
132+
release = 'version' if nibabies_ver.is_prerelease else nibabies_ver.public
120133

121134
# to avoid Python highlighting in literal text
122-
highlight_language = "none"
135+
highlight_language = 'none'

docs/faqs.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,74 @@
22

33
## Leveraging precomputed results
44

5-
Whether manual intervention is required, or you want to reduce processing time, *NiBabies* allow the use of certain pre-computed files during processing, which can skip part of the workflow.
6-
Support is limited to the following files:
7-
- Anatomical mask in T1w or T2w space
8-
- Antomical segmentation (aseg) in T1w or T2w space
5+
Whether manual intervention is required, or you want to break up processing, *NiBabies* can reuse previously-computed files (either from NiBabies directly or a third party application) to be injected into the workflow directly.
6+
7+
:::{versionchanged} 24.0.0
8+
9+
In addition to the brain mask and anatomical segmentation, support was added for additional precomputed derivatives. To see which derivatives are supported, view [](outputs.md#anatomical-derivatives).
10+
:::
911

1012
To use pre-computed results, one or more [BIDS Derivatives](https://bids-specification.readthedocs.io/en/stable/05-derivatives/01-introduction.html#bids-derivatives) directories must be passed in to *NiBabies* using the `--derivatives` flag.
1113
Derivative directories must include a [`dataset_description.json` and the required fields](https://bids-specification.readthedocs.io/en/stable/03-modality-agnostic-files.html#derived-dataset-and-pipeline-description).
1214
Additionally, files must include the `space-T1w` or `space-T2w` key-value pair in the filenames, and a matching sidecar JSON file with the `SpatialReference` field defined.
1315

1416
A sample layout of a derivatives directory can be found below:
1517

16-
```
18+
```bash
1719
my_precomputed/
1820
├── dataset_description.json
1921
└── sub-01
2022
└── anat
23+
├── sub-01_desc-preproc_T2w.nii.gz
2124
├── sub-01_space-T2w_desc-aseg_dseg.json
2225
├── sub-01_space-T2w_desc-aseg_dseg.nii.gz
2326
├── sub-01_space-T2w_desc-brain_mask.json
2427
└── sub-01_space-T2w_desc-brain_mask.nii.gz
2528
```
2629

27-
and the contents of the JSON files:
28-
```
29-
{"SpatialReference": "sub-01/anat/sub-01_T2w.nii.gz"}
30-
```
30+
In this example, `sub-01_desc-preproc_T2w.nii.gz` will be used as the T2w reference. The other files (the brain mask and segmentation), will be in the same space.
31+
32+
:::{warning}
33+
If no anatomical reference is provided, the outputs must be in the same space as the raw anatomical data.
34+
:::
3135

32-
The `SpatialReference` file will be used to ensure the raw data and the derivatives are aligned and in the same space.
36+
:::{note}
37+
If an aseg is provided, it will be used for surface generation.
38+
:::
3339

3440
## Multi-atlas segmentation with joint label fusion
3541

3642
By default, *NiBabies* will run [FSL FAST](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FAST) for tissue segmentation, and Infant FreeSurfer for segmentation labels.
37-
However, you can instead use ANTs Joint Label Fusion to generate both, granted you provide multiple atlases with anatomicals / segmentations via the `--segmentation-atlases-dir` flag.
43+
44+
Alternatively, ANTs {abbr}`JLF (Joint Label Fusion)` can be used by providing a directory with one or more template images composed of anatomicals and segmentations. To pass in this directory, use the `--segmentation-atlases-dir` flag.
3845
When using this approach, there are a few assumptions being made:
46+
3947
1. The anatomicals are brain masked.
40-
1. The labeled segmentations follow the [FreeSurfer lookup table](https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT).
48+
1. The segmentation labels adhere to the [FreeSurfer LUT](https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT).
4149

4250
Here is an example layout of what the `--segmentation-atlases-dir` flag expects:
4351

44-
```
45-
$ tree JLF-templates
46-
JLF-templates/
47-
├── Template01
48-
│   ├── Segmentation.nii.gz
49-
│   ├── T1w_brain.nii.gz
50-
│   └── T2w_brain.nii.gz
51-
└── Template02
52-
├── Segmentation.nii.gz
53-
├── T1w_brain.nii.gz
54-
└── T2w_brain.nii.gz
52+
```bash
53+
$ tree JLF-atlases
54+
55+
JLF-atlases/
56+
├── dataset_description.json
57+
├── participants.tsv
58+
├── sub-01
59+
│ ├── sub-01_desc-aseg_dseg.nii.gz
60+
│ ├── [sub-01_T1w.json] * optional
61+
│ ├── sub-01_T1w.nii.gz
62+
│ ├── [sub-01_T2w.json] * optional
63+
│ └── sub-01_T2w.nii.gz
64+
├── sub-02
65+
...
5566
```
5667

5768
## More context on releases
69+
5870
Like other *NiPreps*, *NiBabies* follows Calendar Versioning ([CalVer](https://calver.org/)), in format of `YY.MINOR.MICRO`.
5971
In short, here is a quick heuristic on how new releases should be looked at:
72+
6073
1. If the `YY` or `MINOR` has changed, it is a feature release, with substantial changes to the workflow.
6174
1. If the `YY.MINOR` match the version you used, but the `MICRO` has changed, it is a bug-fix release.
6275
Check the [release notes](https://github.com/nipreps/nibabies/releases) - if the fixes do not pertain to your data, there is no need to upgrade.

docs/index.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
```{include} ../README.md
2-
:relative-docs: docs/
3-
:relative-images:
42
```
53

6-
## Contents
4+
# Table of Contents
75

86
```{toctree}
9-
:maxdepth: 2
7+
:maxdepth: 3
108
11-
installation
12-
usage
13-
faqs
14-
outputs
15-
community
9+
installation.md
10+
usage.md
11+
faqs.md
12+
outputs.md
13+
community.md
1614
```

docs/installation.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
11
# Installation
22

3-
The latest release of *NiBabies* is {{ release }}.
4-
5-
To view all available releases, refer to the [NiBabies PyPI page](https://pypi.org/project/nibabies/#history).
3+
There are two ways to install *NiBabies*:
4+
- using container technologies; or
5+
- within a manually prepared environment, also known as *bare-metal*.
66

77
## Container Installation
88

9-
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/).
9+
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 [Apptainer](https://apptainer.org/).
1010

1111
### Working with Docker
1212

1313
Images are hosted on our [Docker Hub](https://hub.docker.com/r/nipreps/nibabies).
1414
To pull an image, the specific version tag must be specified in order to pull the images.
15+
For example, to pull the first release in the 24.0.0 series, you can do:
1516

16-
:::{admonition} Example Docker build
17-
:class: seealso
18-
19-
$ {{ dockerbuild }}
20-
:::
17+
```shell
18+
docker pull nipreps/nibabies:24.0.0
19+
```
2120

2221
There are also a few keyword tags, `latest` and `unstable`, that serve as special pointers.
2322
`latest` points to the latest release (excluding any betas or release candidates).
2423
`unstable` points to the most recent developmental change, and should only be used to test new features or fixes.
2524

26-
### Working with Singularity
25+
:::{tip}
26+
`latest` will pull the most recent release, but beware that it will not be updated until calling the docker pull command again. For this reason, it is recommended to pull using the explicit version tag.
27+
:::
2728

28-
The easiest way to create a Singularity image is to build from the [Docker](#working-with-docker) images hosted online.
29+
### Working with Apptainer (formerly Singularity)
2930

30-
:::{admonition} Example Singularity build
31-
:class: seealso
31+
Visit the [apptainer containers page](https://datasets.datalad.org/?dir=/repronim/containers/images/bids), courtesy of DataLad and ReproNim, to download already created images.
3232

33-
$ {{ singbuild }}
33+
:::{tip}
34+
Images are listed as `bids-nibabies--<version>.sing`, where `<version>` is the release tag.
3435
:::
3536

37+
Otherwise, you can create an Apptainer image from the [Docker](#working-with-docker) images hosted online.
38+
39+
```bash
40+
apptainer build nibabies-24.0.0.sif docker://nipreps/nibabies:24.0.0
41+
```
42+
3643
## Installing the nibabies-wrapper
3744

3845
The `nibabies-wrapper` is a lightweight Python tool to facilitate running `nibabies` within a container service.
3946
To install or upgrade to the current release:
40-
```
41-
$ pip install --update nibabies-wrapper
47+
48+
```bash
49+
pip install --update nibabies-wrapper
4250
```
4351

4452
For further details, see [](usage.md#using-the-nibabies-wrapper).

0 commit comments

Comments
 (0)