Skip to content

Commit 550e845

Browse files
authored
Merge pull request #572 from Deep-MI/dev
merge dev into stable for new release
2 parents 818acf1 + fde7304 commit 550e845

File tree

217 files changed

+22363
-8219
lines changed

Some content is hidden

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

217 files changed

+22363
-8219
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
**/.github
33
checkpoints
44
Singularity
5-
images
5+
doc
66
venv
77
Tutorial
88
**/*.md

.github/ISSUE_TEMPLATE/questions-help-support.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,24 @@ assignees: ''
77

88
---
99

10-
## Question/Support Request
11-
<!-- A clear and concise description of a question you may have or a problem for which you would like to request support -->
12-
...
10+
**IMPORTANT**: Please make sure to fill out the information about your environment (see below). This is often critical information we need to help you.
1311

14-
## Screenshots
15-
<!-- If possible, add screenshots to help illustrate your problem. -->
16-
...
12+
## Question/Support Request
13+
A clear and concise description of a question you may have or a problem for which you would like to request support.
1714

18-
<!-- If applicable, provide error messages, stack traces, and any snippets useful in describing your problem here -->
15+
## Screenshots / Log files
16+
Please provide error messages (can be a screenshot), stack traces, log files (specifically `$SUBJECTS_DIR/$SUBJECT_ID/scripts/deep-seg.log` and `$SUBJECTS_DIR/$SUBJECT_ID/scripts/recon-surf.log`) and any snippets useful in describing your problem here.
1917

2018
## Environment
21-
- FastSurfer Version: ...
22-
- FreeSurfer Version: ... <!-- if applicable -->
23-
- OS: ...
24-
- CPU: ...
25-
- GPU: ...
26-
<!-- Add any other relevant information on the environment here -->
19+
- FastSurfer Version: please run `run_fastsurfer.sh --version all` and copy/attach the resulting output
20+
- Installation type: official docker/custom docker/singularity/native <!-- please remove not applicable; if you are running a custom docker please add how you built it. -->
21+
- FreeSurfer Version: 7.4.1/7.3.2 <!-- if applicable -->
22+
- OS: Windows/Linux/macOS <!-- please specify -->
23+
- GPU: none/RTX 2080/... <!-- please specify -->
2724

28-
<!-- If you ran FastSurfer locally, include a snapshot of the python software package versions you have (for e.g., using pip freeze or conda list) here -->
25+
<!-- more infos -->
26+
...
2927

3028
### Execution
31-
<!-- If you ran FastSurfer in a docker container, include the commands used to build and run the container here -->
32-
33-
<!-- If you ran FastSurfer locally, include the command you used to run FastSurfer here -->
34-
Run Command: <!-- For e.g. `\run_fastsurfer.sh ...` -->
29+
Include the command you used to run FastSurfer that cause the problem, e.g.
30+
`./run_fastsurfer.sh --sid test --sd /path/to/dir --t1 /path/to/file.nii`.

.github/workflows/QUICKTEST.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# FastSurfer Singularity GitHub Actions Workflow
2+
3+
This GitHub Actions workflow is designed to automate the integration testing of new code into the FastSurfer repository using Singularity containers. The workflow is triggered whenever new code is pushed to the repository.
4+
5+
The workflow runs on a self-hosted runner labelled 'ci-gpu' to ensure security.
6+
7+
## Jobs
8+
9+
The workflow consists of several jobs that are executed in sequence:
10+
11+
### Checkout
12+
13+
This job checks out the repository using the `actions/checkout@v2` action.
14+
15+
### Prepare Job
16+
17+
This job sets up the necessary environments for the workflow. It depends on the successful completion of the `checkout` job. The environments set up in this job include:
18+
19+
- Python 3.10, using the `actions/setup-python@v3` action.
20+
- Go, using the `actions/setup-go@v5` action with version `1.13.1`.
21+
- Singularity, using the `eWaterCycle/setup-singularity@v7` action with version `3.8.3`.
22+
23+
### Build Singularity Image
24+
25+
This job builds a Docker image and converts it to a Singularity image. It depends on the successful completion of the `prepare-job`. The Docker image is built using a Python script `Docker/build.py` with the `--device cuda --tag fastsurfer_gpu:cuda` flags. The Docker image is then converted to a Singularity image.
26+
27+
### Run FastSurfer
28+
29+
This job runs FastSurfer on sample MRI data using the Singularity image built in the previous job. It depends on the successful completion of the `build-singularity-image` job. The Singularity container is executed with the `--nv`, `--no-home`, and `--bind` flags to enable GPU access, prevent home directory mounting, and bind the necessary directories respectively. The `FASTSURFER_HOME` environment variable is set to `/fastsurfer-dev` inside the container.
30+
31+
### Test File Existence
32+
33+
This job tests for the existence of certain files after running FastSurfer. It depends on the successful completion of the `run-fastsurfer` job. The test is performed using a Python script `test/test_file_existence.py`.
34+
35+
### Test Error Messages
36+
37+
This job tests for errors in log files after running FastSurfer. It runs on a self-hosted runner labeled `ci-gpu` and depends on the successful completion of both the `run-fastsurfer` and `test-file-existence` jobs. The test is performed using a Python script `test/test_error_messages.py`.
38+
39+
## Usage
40+
41+
To use this workflow, you need to have a self-hosted runner labeled `ci-gpu` set up on your machine. You also need to update the environment variables of the runner, by going to `/home/your_runner/.env` file and adding the following environment variables with the actual paths you want to use.
42+
43+
44+
### Environment variables
45+
`RUNNER_FS_MRI_DATA`: Path to MRI Data
46+
47+
`RUNNER_FS_OUTPUT`: Path to Output directory
48+
49+
`RUNNER_FS_LICENSE`: Path to License directory
50+
51+
`RUNNER_SINGULARITY_IMGS`: Path to where Singularity images should be stored
52+
53+
`RUNNER_FS_OUTPUT_FILES`: Path to output files to be tested
54+
55+
`RUNNER_FS_OUTPUT_LOGS`: Path to output log files to check for errors
56+
57+
58+
Once everything is set up, you can trigger the workflow manually from the GitHub Actions tab in your repository, as well as by pushing code to the repository.

.github/workflows/code-style.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: code-style
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
4+
cancel-in-progress: true
5+
on:
6+
# pull_request:
7+
# push:
8+
# branches: [dev]
9+
workflow_dispatch:
10+
11+
jobs:
12+
style:
13+
timeout-minutes: 10
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Setup Python 3.10
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.10'
22+
architecture: 'x64'
23+
cache: 'pip' # caching pip dependencies
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --progress-bar off --upgrade pip setuptools wheel
27+
python -m pip install --progress-bar off .[style]
28+
- name: Run Ruff
29+
run: ruff check .
30+
- name: Run codespell
31+
uses: codespell-project/actions-codespell@master
32+
with:
33+
check_filenames: true
34+
check_hidden: true
35+
skip: './.git,./build,./.mypy_cache,./.pytest_cache'
36+
ignore_words_file: ./.codespellignore
37+
- name: Run pydocstyle
38+
run: pydocstyle .
39+
- name: Run bibclean
40+
run: bibclean-check doc/references.bib

.github/workflows/doc.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: doc
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request:
7+
push:
8+
branches: [dev, stable]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
timeout-minutes: 10
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
shell: bash
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
path: src
23+
- name: Setup Python 3.10
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.10'
27+
architecture: 'x64'
28+
cache: 'pip' # caching pip dependencies
29+
- name: Install package
30+
run: |
31+
python -m pip install --progress-bar off --upgrade pip setuptools wheel
32+
python -m pip install --progress-bar off src/.[doc]
33+
- name: Build doc
34+
run: PYTHONPATH=$PYTHONPATH:src TZ=UTC sphinx-build src/doc doc-build -W --keep-going
35+
- name: Upload documentation
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: doc
39+
path: |
40+
doc-build
41+
!doc-build/.doctrees
42+
43+
deploy:
44+
# only on push to dev or stable
45+
if: ${{ github.event_name == 'push' && contains(fromJSON('["dev", "stable"]'), github.ref_name) }}
46+
needs: build
47+
timeout-minutes: 10
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
defaults:
52+
run:
53+
shell: bash
54+
steps:
55+
- name: Download documentation
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: doc
59+
path: doc
60+
- name: Deploy {dev,stable} documentation
61+
uses: peaceiris/actions-gh-pages@v4
62+
with:
63+
github_token: ${{ secrets.GITHUB_TOKEN }}
64+
publish_dir: doc
65+
# destination_dir: github.ref_name will be dev or stable
66+
destination_dir: ${{ github.ref_name }}
67+
user_name: 'github-actions[bot]'
68+
user_email: 'github-actions[bot]@users.noreply.github.com'

.github/workflows/quicktest.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: FastSurfer Singularity
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
# Checkout repo
8+
checkout:
9+
runs-on: ci-gpu
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
# Prepare job: Set up Python, Go, Singularity
14+
prepare-job:
15+
runs-on: ci-gpu
16+
needs: checkout
17+
steps:
18+
- name: Set up Python 3.10
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: "3.10"
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
26+
- name: Set up Singularity
27+
uses: eWaterCycle/setup-singularity@v7
28+
with:
29+
singularity-version: 3.8.3
30+
31+
# Build Docker Image and convert it to Singularity
32+
build-singularity-image:
33+
runs-on: ci-gpu
34+
needs: prepare-job
35+
steps:
36+
- name: Build Docker Image and convert to Singularity
37+
run: |
38+
cd $RUNNER_SINGULARITY_IMGS
39+
FILE="fastsurfer-gpu.sif"
40+
if [ ! -f "$FILE" ]; then
41+
# If the file does not exist, build the file
42+
echo "SIF File does not exist. Building file."
43+
PYTHONPATH=$PYTHONPATH
44+
cd $PYTHONPATH
45+
python3 Docker/build.py --device cuda --tag fastsurfer_gpu:cuda
46+
cd $RUNNER_SINGULARITY_IMGS
47+
singularity build --force fastsurfer-gpu.sif docker-daemon://fastsurfer_gpu:cuda
48+
else
49+
echo "File already exists"
50+
cd $PYTHONPATH
51+
fi
52+
53+
# Run FastSurfer on MRI data
54+
run-fastsurfer:
55+
runs-on: ci-gpu
56+
needs: build-singularity-image
57+
steps:
58+
- name: Run FastSurfer
59+
run: |
60+
singularity exec --nv \
61+
--no-home \
62+
--bind $GITHUB_WORKSPACE:/fastsurfer-dev \
63+
--env FASTSURFER_HOME=/fastsurfer-dev \
64+
-B $RUNNER_FS_MRI_DATA:/data \
65+
-B $RUNNER_FS_OUTPUT:/output \
66+
-B $RUNNER_FS_LICENSE:/fs_license \
67+
$RUNNER_SINGULARITY_IMGS/fastsurfer-gpu.sif \
68+
/fastsurfer/run_fastsurfer.sh \
69+
--fs_license /fs_license/.license \
70+
--t1 /data/subjectx/orig.mgz \
71+
--sid subjectX --sd /output \
72+
--parallel --3T
73+
74+
# Test file existence
75+
test-file-existence:
76+
runs-on: ci-gpu
77+
needs: run-fastsurfer
78+
steps:
79+
- name: Test File Existence
80+
run: |
81+
python3 test/quick_test/test_file_existence.py $RUNNER_FS_OUTPUT_FILES
82+
83+
# Test for errors in log files
84+
test-error-messages:
85+
runs-on: ci-gpu
86+
needs: [run-fastsurfer, test-file-existence]
87+
steps:
88+
- name: Test Log Files For Error Messages
89+
run: |
90+
python3 test/quick_test/test_errors.py $RUNNER_FS_OUTPUT_LOGS

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
/BUILD.info
2-
/.idea/**
2+
/.idea/**
3+
/rough_work/**
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+

CerebNet/README.md

Lines changed: 5 additions & 0 deletions
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/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__all__ = [
2+
"apply_warp",
3+
"config",
4+
"datasets",
5+
"data_loader",
6+
"inference",
7+
"models",
8+
"run_prediction",
9+
"utils",
10+
]

0 commit comments

Comments
 (0)