Skip to content

Commit 7c5e709

Browse files
committed
- fix the relative paths
1 parent 515d607 commit 7c5e709

22 files changed

+271
-87
lines changed

CerebNet/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CerebNet
2+
Deep learning based tool for segmentation of cerebellar sub-regions.
3+
4+
The training and evaluation scripts of CerebNet are currently not part of the FastSurfer repository and are only available as incompatible stubs from the authors on request via email.
5+
The interface to realistic deformations can be found in :py:`CerebNet.apply_warp`.

CerebNet/apply_warp.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import argparse
12

23
# Copyright 2022 Image Analysis Lab, German Center for Neurodegenerative Diseases (DZNE), Bonn
34
#
@@ -90,8 +91,7 @@ def main(img_path, lbl_path, warp_path, result_path, patch_size):
9091
affine=lbl_file.affine)
9192

9293

93-
if __name__ == '__main__':
94-
import argparse
94+
def make_parser() -> argparse.ArgumentParser:
9595
parser = argparse.ArgumentParser()
9696
parser.add_argument("--img_path",
9797
help="path to T1 image",
@@ -107,11 +107,17 @@ def main(img_path, lbl_path, warp_path, result_path, patch_size):
107107
help="Warp field file",
108108
default='1Warp.nii.gz',
109109
type=str)
110+
return parser
111+
110112

113+
if __name__ == '__main__':
114+
parser = make_parser()
111115
args = parser.parse_args()
112-
warp_path = join(args.result_path, args.warp_filename)
113-
main(args.img_path,
114-
args.lbl_path,
115-
warp_path=warp_path,
116-
result_path=args.result_path,
117-
patch_size=(128, 128, 128))
116+
warp_path = str(join(args.result_path, args.warp_filename))
117+
main(
118+
args.img_path,
119+
args.lbl_path,
120+
warp_path=warp_path,
121+
result_path=args.result_path,
122+
patch_size=(128, 128, 128),
123+
)

FastSurferCNN/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Overview
22

33
This directory contains all information needed to run inference with the readily trained FastSurferVINN or train it from scratch. FastSurferCNN is capable of whole brain segmentation into 95 classes in under 1 minute, mimicking FreeSurfer's anatomical segmentation and cortical parcellation (DKTatlas). The network architecture incorporates local and global competition via competitive dense blocks and competitive skip pathways, as well as multi-slice information aggregation that specifically tailor network performance towards accurate segmentation of both cortical and sub-cortical structures.
4-
![](/doc/images/detailed_network.png)
4+
![](../doc/images/detailed_network.png)
55

66
The network was trained with conformed images (UCHAR, 1-0.7 mm voxels and standard slice orientation). These specifications are checked in the run_prediction.py script and the image is automatically conformed if it does not comply.
77

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ The FastSurfer pipeline consists of two main parts for segmentation and surface
2020
- approximately 5 minutes (GPU), `--seg_only` only runs this part.
2121

2222
Modules (all run by default):
23-
1. `asegdkt:` FastSurferVINN for whole brain segmentation (deactivate with `--no_asegdkt`)
23+
1. `asegdkt:` [FastSurferVINN](FastSurferCNN/README.md) for whole brain segmentation (deactivate with `--no_asegdkt`)
2424
- the core, outputs anatomical segmentation and cortical parcellation and statistics of 95 classes, mimics FreeSurfer’s DKTatlas.
2525
- requires a T1w image ([notes on input images](#requirements-to-input-images)), supports high-res (up to 0.7mm, experimental beyond that).
2626
- performs bias-field correction and calculates volume statistics corrected for partial volume effects (skipped if `--no_biasfield` is passed).
27-
2. `cereb:` CerebNet for cerebellum sub-segmentation (deactivate with `--no_cereb`)
27+
2. `cereb:` [CerebNet](CerebNet/README.md) for cerebellum sub-segmentation (deactivate with `--no_cereb`)
2828
- requires `asegdkt_segfile`, outputs cerebellar sub-segmentation with detailed WM/GM delineation.
2929
- requires a T1w image ([notes on input images](#requirements-to-input-images)), which will be resampled to 1mm isotropic images (no native high-res support).
3030
- calculates volume statistics corrected for partial volume effects (skipped if `--no_biasfield` is passed).
3131

3232
### Surface reconstruction
33-
- approximately 60-90 minutes, `--surf_only` runs only the surface part.
33+
- approximately 60-90 minutes, `--surf_only` runs only [the surface part](recon_surf/README.md).
3434
- supports high-resolution images (up to 0.7mm, experimental beyond that).
3535

3636
<!-- start of image requirements -->
@@ -75,7 +75,7 @@ All installation methods use the `run_fastsurfer.sh` call interface (replace `*f
7575

7676
The `-B` flag is used to tell singularity, which folders FastSurfer can read and write to.
7777

78-
See also __[Example 2](doc/overview/EXAMPLES.md#example-2-fastSurfer-singularity)__ for a full singularity FastSurfer run command and [the Singularity documentation](Singularity/README.md#fastsurfer-singularity-image-usage) for details on more singularity flags.
78+
See also __[Example 2](doc/overview/EXAMPLES.md#example-2-fastsurfer-singularity)__ for a full singularity FastSurfer run command and [the Singularity documentation](Singularity/README.md#fastsurfer-singularity-image-usage) for details on more singularity flags.
7979

8080
(b) For __docker__, the syntax is
8181
```
@@ -144,7 +144,7 @@ Minimum CPU-only: 8 GB system memory (much slower, not recommended) ``--device c
144144
145145
## Expert usage
146146
Individual modules and the surface pipeline can be run independently of the full pipeline script documented in this documentation.
147-
This is documented in READMEs in subfolders, for example: [whole brain segmentation only with FastSurferVINN](FastSurferCNN/README.md), [cerebellum sub-segmentation (in progress)](CerebNet/README.md) and [surface pipeline only (recon-surf)](recon_surf/README.md).
147+
This is documented in READMEs in subfolders, for example: [whole brain segmentation only with FastSurferVINN](FastSurferCNN/README.md), [cerebellum sub-segmentation](CerebNet/README.md) and [surface pipeline only (recon-surf)](recon_surf/README.md).
148148
149149
Specifically, the segmentation modules feature options for optimized parallelization of batch processing.
150150

doc/conf.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from importlib import import_module
1212
import sys
1313
import os
14+
from pathlib import Path
1415

1516
# here i added the relative path because sphinx was not able
1617
# to locate FastSurferCNN module directly for autosummary
@@ -65,7 +66,8 @@
6566
"myst.duplicate_def",
6667
]
6768

68-
myst_heading_anchors = 1
69+
# create anchors for which headings?
70+
myst_heading_anchors = 7
6971

7072
templates_path = ["_templates"]
7173
exclude_patterns = [
@@ -253,23 +255,24 @@ def linkcode_resolve(domain, info):
253255
# myst_ref_domains = ["myst", "std", "py"]
254256

255257

256-
_script_dirs = "fastsurfercnn", "cerebnet", "recon_surf"
258+
_re_script_dirs = "fastsurfercnn|cerebnet|recon_surf"
259+
_up = "^/\\.\\./"
260+
_end = "(\\.md)?(#.*)?$"
257261

258262
# re_reference_target=(regex) => used in missing-reference
259263
fix_links_target = {
260264
# all regexpr are ignorecase, individual replacements are applied until no further
261265
# change occurs, but different (different repl str) replacements are not combined
262266
# "^\\/overview\\/intro\\.md#": "/overview/index.rst#",
263267
"^/?(.*)#(.*)ubuntu-(\\d{2})(\\d{2})": ("/\\1#\\2ubuntu-\\3-\\4",),
264-
"^/readme\\.md(#.*)?$": ("/index.rst\\1", "/overview/intro.rst\\1"),
265-
"^/?(overview/)?intro(\\.rst)?(#.*)?$": ("/overview/index.rst\\3",),
266-
"^/?(singularity|docker)/readme\\.md(#.*)?$": ("/overview/\\1.md\\2",),
267-
f"^/?({'|'.join(_script_dirs)})/readme\\.md(#.*)?$": ("/scripts/\\1.rst\\2",),
268-
"^/?doc/": ("/",),
269-
"^/?license": ("/overview/license.rst",),
268+
f"{_up}readme{_end}": ("/index.rst\\1", "/overview/intro.rst\\1"),
269+
"^/overview/intro(#.*)?$": ("/overview/index.rst\\2",),
270+
f"{_up}(singularity|docker)/readme{_end}": ("/overview/\\1.rst\\2",),
271+
f"{_up}({_re_script_dirs})/readme{_end}": ("/scripts/\\1.rst\\2",),
272+
f"{_up}license": ("/overview/license.rst",),
270273
}
271274
fix_links_alternative_targets = {
272-
"overview/intro": ("/index.rst", "/overview/index.rst"),
275+
"/overview/intro": ("/index.rst", "/overview/index.rst"),
273276
}
274-
277+
fix_links_project_root = Path("..")
275278

doc/index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
.. include:: ../README.md
1111
:parser: fix_links.parser
12+
:relative-docs: .
1213
:start-after: <!-- start of content -->
1314
:end-before: <!-- start of image requirements -->
1415

1516
.. include:: ../README.md
1617
:parser: fix_links.parser
18+
:relative-docs: .
1719
:start-after: <!-- start of references -->
1820

1921
.. toctree::

doc/overview/DOCKER.md

-7
This file was deleted.

doc/overview/EXAMPLES.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Note, that the paths following `--fs_license`, `--t1`, and `--sd` are __inside__
3838

3939
A directory with the name as specified in `--sid` (here subjectX) will be created in the output directory if it does not exist. So in this example output will be written to /home/user/my_fastsurfer_analysis/subjectX/ . Make sure the output directory is empty, to avoid overwriting existing files.
4040

41-
If you do not have a GPU, you can also run our CPU-Docker by dropping the `--gpus all` flag and specifying `--device cpu` at the end as a FastSurfer flag. See [Docker/README.md](Docker/README.md) for more details.
41+
If you do not have a GPU, you can also run our CPU-Docker by dropping the `--gpus all` flag and specifying `--device cpu` at the end as a FastSurfer flag, see also [FastSurfer's docker documentation](../../Docker/README.md) for more details.
4242

4343
## Example 2: FastSurfer Singularity
44-
After building the Singularity image (see below or instructions in ./Singularity/README.md), you also need to register at the FreeSurfer website (https://surfer.nmr.mgh.harvard.edu/registration.html) to acquire a valid license (for free) - same as when using Docker. This license needs to be passed to the script via the `--fs_license` flag. This is not necessary if you want to run the segmentation only.
44+
After building the Singularity image (see below or [these instructions](../../Singularity/README.md)), you also need to register at the FreeSurfer website (https://surfer.nmr.mgh.harvard.edu/registration.html) to acquire a valid license (for free) - same as when using Docker. This license needs to be passed to the script via the `--fs_license` flag. This is not necessary if you want to run the segmentation only.
4545

4646
To run FastSurfer on a given subject using the Singularity image with GPU access, execute the following commands from a directory where you want to store singularity images. This will create a singularity image from our Dockerhub image and execute it:
4747

@@ -91,7 +91,7 @@ For a native install you may want to make sure that you are on our stable branch
9191
git clone --branch stable https://github.com/Deep-MI/FastSurfer.git
9292
```
9393

94-
More details (e.g. you need all dependencies in the right versions and also FreeSurfer locally) can be found in our [INSTALL.md file](INSTALL.md).
94+
More details (e.g. you need all dependencies in the right versions and also FreeSurfer locally) can be found in our [Installation guide](INSTALL.md).
9595
Given you want to analyze data for subject which is stored on your computer under /home/user/my_mri_data/subjectX/t1-weighted.nii.gz, run the following command from the console (do not forget to source FreeSurfer!):
9696

9797
```bash

doc/overview/INSTALL.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Assuming you have singularity installed already (by a system admin), you can bui
2222
```bash
2323
singularity build fastsurfer-gpu.sif docker://deepmi/fastsurfer:latest
2424
```
25-
Additionally, [the Singularity README](Singularity/README.md) contains detailed directions for building your own Singularity images from Docker.
25+
Additionally, [the Singularity README](../../Singularity/README.md) contains detailed directions for building your own Singularity images from Docker.
2626

27-
Our [README](doc/overview/EXAMPLES.md#example-2-fastsurfer-singularity) explains how to run FastSurfer (for the full pipeline you will also need a FreeSurfer .license file!) and you can find details on how to build your own images here: [Docker](Docker/README.md) and [Singularity](Singularity/README.md).
27+
[Example 2](EXAMPLES.md#example-2-fastsurfer-singularity) explains how to run FastSurfer (for the full pipeline you will also need a FreeSurfer .license file!) and you can find details on how to build your own images here: [Docker](../../Docker/README.md) and [Singularity](../../Singularity/README.md).
2828

2929

3030
### Docker
@@ -35,7 +35,7 @@ This is very similar to Singularity. Assuming you have Docker installed (by a sy
3535
docker pull deepmi/fastsurfer:latest
3636
```
3737

38-
Our [README](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker) explains how to run FastSurfer (for the full pipeline you will also need a FreeSurfer .license file!) and you can find details on how to [build your own image](https://github.com/Deep-MI/FastSurfer/blob/dev/Docker/README.md).
38+
[Example 1](EXAMPLES.md#example-1-fastsurfer-docker) explains how to run FastSurfer (for the full pipeline you will also need a FreeSurfer .license file!) and you can find details on how to [build your own image](https://github.com/Deep-MI/FastSurfer/blob/dev/Docker/README.md).
3939

4040

4141
### Native (Ubuntu 20.04 or Ubuntu 22.04)
@@ -113,7 +113,7 @@ You can also download all network checkpoint files (this should be done if you a
113113
python3 FastSurferCNN/download_checkpoints.py --all
114114
```
115115

116-
Once all dependencies are installed, you are ready to run the FastSurfer segmentation-only (!!) pipeline by calling ```./run_fastsurfer.sh --seg_only ....``` , see the [README](doc/overview/EXAMPLES.md#example-3-native-fastsurfer-on-subjectx-with-parallel-processing-of-hemis) for command line flags.
116+
Once all dependencies are installed, you are ready to run the FastSurfer segmentation-only (!!) pipeline by calling ```./run_fastsurfer.sh --seg_only ....``` , see [Example 3](EXAMPLES.md#example-3-native-fastsurfer-on-subjectx-with-parallel-processing-of-hemis) for command line flags.
117117

118118
#### 5. FreeSurfer
119119
To run the full pipeline, you will need to install FreeSurfer (we recommend and support version 7.3.2) according to their [Instructions](https://surfer.nmr.mgh.harvard.edu/fswiki/rel7downloads). There is a freesurfer email list, if you run into problems during this step.
@@ -130,7 +130,7 @@ Build the Docker container with ROCm support.
130130
python Docker/build.py --device rocm --tag my_fastsurfer:rocm
131131
```
132132

133-
You will need to add a couple of flags to your docker run command for AMD, see [the Readme](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker) for `**other-docker-flags**` or `**fastsurfer-flags**`:
133+
You will need to add a couple of flags to your docker run command for AMD, see [Example 1](EXAMPLES.md#example-1-fastsurfer-docker) for `**other-docker-flags**` or `**fastsurfer-flags**`:
134134
```bash
135135
docker run --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --device=/dev/kfd \
136136
--device=/dev/dri --group-add video --ipc=host --shm-size 8G \
@@ -160,7 +160,7 @@ Second, pull one of our Docker containers. Open a terminal window and run:
160160
docker pull deepmi/fastsurfer:latest
161161
```
162162

163-
Continue with the example in our [README](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker).
163+
Continue with the example in [Example 1](EXAMPLES.md#example-1-fastsurfer-docker).
164164

165165

166166
### Native
@@ -215,7 +215,7 @@ You can also download all network checkpoint files (this should be done if you a
215215
python3 FastSurferCNN/download_checkpoints.py --all
216216
```
217217

218-
Once all dependencies are installed, run the FastSurfer segmentation only (!!) by calling ```bash ./run_fastsurfer.sh --seg_only ....``` with the appropriate command line flags, see the [README](README.md#usage).
218+
Once all dependencies are installed, run the FastSurfer segmentation only (!!) by calling ```bash ./run_fastsurfer.sh --seg_only ....``` with the appropriate command line flags, see the [commandline documentation](../../README.md#usage).
219219

220220
Note: You may always need to prepend the command with `bash` (i.e. `bash run_fastsurfer.sh <...>`) to ensure that bash 4.0 is used instead of the system default.
221221

@@ -247,7 +247,7 @@ After everything is installed, start Windows PowerShell and run the following co
247247
docker pull deepmi/fastsurfer:cpu-latest
248248
```
249249

250-
Now you can run Fastsurfer the same way as described in our [README](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker) for the CPU build, for example:
250+
Now you can run Fastsurfer the same way as described in [Example 1](EXAMPLES.md#example-1-fastsurfer-docker) for the CPU build, for example:
251251
```bash
252252
docker run -v C:/Users/user/my_mri_data:/data \
253253
-v C:/Users/user/my_fastsurfer_analysis:/output \
@@ -279,7 +279,7 @@ After everything is installed, start Windows PowerShell and run the following co
279279
docker pull deepmi/fastsurfer:latest
280280
```
281281

282-
Now you can run Fastsurfer the same way as described in our [README](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker), for example:
282+
Now you can run Fastsurfer the same way as described in [Example 1](EXAMPLES.md#example-1-fastsurfer-docker), for example:
283283
```bash
284284
docker run --gpus all
285285
-v C:/Users/user/my_mri_data:/data \

doc/overview/SINGULARITY.md

-6
This file was deleted.

doc/overview/docker.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Docker Support
2+
--------------
3+
4+
.. include:: ../../Docker/README.md
5+
:parser: fix_links.parser
6+
:relative-docs: .
7+
:relative-images:
8+
:start-line: 1

doc/overview/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ User Guide
99
EXAMPLES.md
1010
FLAGS.md
1111
OUTPUT_FILES.md
12-
DOCKER.md
13-
SINGULARITY.md
12+
docker
13+
singularity
1414
EDITING.md
1515
SECURITY.md
1616
CODE_OF_CONDUCT.md

doc/overview/intro.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ Introduction to FastSurfer
44

55
.. include:: ../../README.md
66
:parser: fix_links.parser
7-
:relative-docs: doc/
7+
:relative-docs: .
88
:relative-images:
99
:start-after: <!-- start of getting started -->
1010
:end-before: <!-- start of flags -->
1111

1212
.. include:: ../../README.md
1313
:parser: fix_links.parser
14-
:relative-docs: doc/
14+
:relative-docs: .
1515
:relative-images:
1616
:start-after: <!-- start of image requirements -->
1717
:end-before: <!-- end of image requirements -->
1818

1919
.. include:: ../../README.md
2020
:parser: fix_links.parser
21-
:relative-docs: doc/
21+
:relative-docs: .
2222
:relative-images:
2323
:start-after: <!-- start of system requirements -->

doc/overview/singularity.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Singularity Support
2+
-------------------
3+
4+
.. include:: ../../Singularity/README.md
5+
:parser: fix_links.parser
6+
:relative-docs: .
7+
:relative-images:
8+
:start-line: 1

doc/scripts/cerebnet.rst

+5
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ situations, it will be called from `run_fastsurfer.sh` a direct call to
1212
:module: CerebNet.run_prediction
1313
:func: setup_options
1414
:prog: CerebNet/run_prediction.py
15+
16+
17+
.. include:: ../../CerebNet/README.md
18+
:parser: fix_links.parser
19+
:start-line: 1

doc/scripts/fastsurfercnn.generate_hdf5.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FastSurferCNN: generate_hdf5.py
33

44
.. include:: ../../FastSurferCNN/README.md
55
:parser: fix_links.parser
6-
:relative-docs: doc/
6+
:relative-docs: .
77
:relative-images:
88
:start-after: <!-- after inference heading -->
99
:end-before: <!-- before generate_hdf5 -->

doc/scripts/fastsurfercnn.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FastSurferCNN: run_prediction.py
66

77
.. include:: ../../FastSurferCNN/README.md
88
:parser: fix_links.parser
9-
:relative-docs: doc/
9+
:relative-docs: .
1010
:relative-images:
1111
:start-after: <!-- after inference heading -->
1212
:end-before: <!-- before generate_hdf5 -->

doc/scripts/fastsurfercnn.run_model.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FastSurferCNN: run_model.py
33

44
.. include:: ../../FastSurferCNN/README.md
55
:parser: fix_links.parser
6-
:relative-docs: doc/
6+
:relative-docs: .
77
:relative-images:
88
:start-after: <!-- after training heading -->
99

doc/scripts/recon_surf.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Surface pipeline: recon-surf.sh
22
===============================
33

44
.. include:: ../../recon_surf/README.md
5-
:parser: myst_parser.sphinx_
6-
:relative-docs: doc/
5+
:parser: fix_links.parser
6+
:relative-docs: .
77
:relative-images:
88
:heading-offset: 1
99

0 commit comments

Comments
 (0)