Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 79 additions & 40 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,94 @@
name: MAN deploy-docker

on:
# release:
# types:
# - published
release:
types:
- published
workflow_dispatch:

jobs:
deploy-gpu:
runs-on: ubuntu-latest
deploy-mac:
runs-on: macos-14
timeout-minutes: 120

env:
VERSION: 242
FREESURFER_URL: https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-macOS-darwin_x86_64-7.4.1.tar.gz
RELEASE_ASSETS: true
strategy:
matrix:
arch: [intel, arm]
steps:
- name: Get repository name.
run: echo "FASTSURFER_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Docker
uses: docker/login-action@v2
- name: Set up python environment
uses: actions/setup-python@v6
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image GPU
run: python Docker/build.py --device cuda --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }}
- name: Add additional tags
python-version: '3.10'
- name: install dependencies
run: |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-latest
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:latest
- name: Push Docker image GPU
run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }}
deploy-cpu:
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image CPU
run: python Docker/build.py --device cpu --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }}
- name: Add additional tags
run: |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-latest
- name: Push Docker image CPU
run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }}
python -m pip install py2app

brew update
brew upgrade || true
- name: package app for ${{ matrix.arch }}
run: tools/macos_build/build_release_package.sh ${{ env.VERSION }} ${{ matrix.arch }} ${{ env.FASTSURFER_DIR }} ${{ env.FREESURFER_URL }}
- name: Move assets.
if: env.RELEASE_ASSETS == 'true'
run: |
mkdir assets
mv tools/macos_build/installer/* assets/
- name: Upload release assets.
uses: softprops/action-gh-release@v2
if: env.RELEASE_ASSETS == 'true'
with:
files: ${{ env.FASTSURFER_DIR }}/assets/*
# deploy-gpu:
# runs-on: ubuntu-latest
# timeout-minutes: 120
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Login to Docker
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Build Docker image GPU
# run: python Docker/build.py --device cuda --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }}
# - name: Add additional tags
# run: |
# docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-latest
# docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:latest
# - name: Push Docker image GPU
# run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }}
# deploy-cpu:
# runs-on: ubuntu-latest
# timeout-minutes: 120
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Login to Docker
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Build Docker image CPU
# run: python Docker/build.py --device cpu --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }}
# - name: Add additional tags
# run: |
# docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-latest
# - name: Push Docker image CPU
# run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ All installation methods use the `run_fastsurfer.sh` call interface (replace `*f
```
The `--nv` flag is needed to allow FastSurfer to run on the GPU (otherwise FastSurfer will run on the CPU).

The `--no-home` flag tells singularity to not mount the home directory (see [Singularity documentation](Singularity/README.md#mounting-home) for more info).
The `--no-home` flag tells singularity to not mount the home directory (see [Singularity documentation](tools/Singularity/README.md#mounting-home) for more info).

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

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.
See also __[Example 2](doc/overview/EXAMPLES.md#example-2-fastsurfer-singularity)__ for a full singularity FastSurfer run command and [the Singularity documentation](tools/Singularity/README.md#fastsurfer-singularity-image-usage) for details on more singularity flags.

(b) For __docker__, the syntax is
```
Expand All @@ -96,7 +96,7 @@ All installation methods use the `run_fastsurfer.sh` call interface (replace `*f

The `-v` flag is used to tell docker, which folders FastSurfer can read and write to.

See also __[Example 1](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker)__ for a full FastSurfer run inside a Docker container and [the Docker documentation](Docker/README.md#docker-flags) for more details on the docker flags including `--rm` and `--user`.
See also __[Example 1](doc/overview/EXAMPLES.md#example-1-fastsurfer-docker)__ for a full FastSurfer run inside a Docker container and [the Docker documentation](tools/Docker/README.md#docker-flags) for more details on the docker flags including `--rm` and `--user`.

2. For a __native install__, you need to activate your FastSurfer environment (e.g. `conda activate fastsurfer_gpu`) and make sure you have added the FastSurfer path to your `PYTHONPATH` variable, e.g. `export PYTHONPATH=$(pwd)`.

Expand Down
Binary file added doc/images/fastsurfer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions doc/overview/EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Note, that the paths following `--fs_license`, `--t1`, and `--sd` are __inside__

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.

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.
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](../../tools/Docker/README.md) for more details.

## Example 2: FastSurfer Singularity
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.
After building the Singularity image (see below or [these instructions](../../tools/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.

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:

Expand Down
10 changes: 5 additions & 5 deletions doc/overview/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Assuming you have singularity installed already (by a system admin), you can bui
```bash
singularity build fastsurfer-gpu.sif docker://deepmi/fastsurfer:latest
```
Additionally, [the Singularity README](../../Singularity/README.md) contains detailed directions for building your own Singularity images from Docker.
Additionally, [the Singularity README](../../tools/Singularity/README.md) contains detailed directions for building your own Singularity images from Docker.

[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).
[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](../../tools/Docker/README.md) and [Singularity](../../tools/Singularity/README.md).


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

[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).
[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](../../tools/Docker/README.md).

If you are using the **rootless mode**, you have to install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) and follow the [configuration for the rootless mode](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#rootless-mode). Otherwise, running FastSurfer with Docker will give you this error message ```docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]```.

Expand Down Expand Up @@ -97,7 +97,7 @@ conda env create -f ./env/fastsurfer.yml
conda activate fastsurfer
```

If you do not have an NVIDIA GPU, you can create appropriate ymls on the fly with `python ./Docker/install_env.py -m $MODE -i ./env/FastSurfer.yml -o ./fastsurfer_$MODE.yml`. Here `$MODE` can be for example `cpu`, see also `python ./Docker/install_env.py --help` for other options like rocm or cuda versions. Finally, replace `./env/fastsurfer.yml` with your custom environment file `./fastsurfer_$MODE.yml`.
If you do not have an NVIDIA GPU, you can create appropriate ymls on the fly with `python ./tools/Docker/install_env.py -m $MODE -i ./env/FastSurfer.yml -o ./fastsurfer_$MODE.yml`. Here `$MODE` can be for example `cpu`, see also `python ./tools/Docker/install_env.py --help` for other options like rocm or cuda versions. Finally, replace `./env/fastsurfer.yml` with your custom environment file `./fastsurfer_$MODE.yml`.
If you only want to run the surface pipeline, use `./env/fastsurfer_reconsurf.yml`.

Next, add the fastsurfer directory to the python path (make sure you have changed into it already):
Expand Down Expand Up @@ -129,7 +129,7 @@ We have successfully run the segmentation on an AMD GPU (Radeon Pro W6600) using
Build the Docker container with ROCm support.

```bash
python Docker/build.py --device rocm --tag my_fastsurfer:rocm
python tools/Docker/build.py --device rocm --tag my_fastsurfer:rocm
```

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**`:
Expand Down
10 changes: 10 additions & 0 deletions doc/overview/MACOS.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also be renamed to something like MACOS.md

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Running FastSurfer
==================

If you want to run only segmentation (replace placeholders starting with "<" and ending with ">", see https://deep-mi.org/FastSurfer/stable):
`run_fastsurfer.sh --seg_only --sd <path/to/output/dir> --sid <subject_id> --t1 <path/to/subjects/t1/image>`
To full run fastsurfer:
`run_fastsurfer.sh --device mps --sd <path/to/output/dir> --sid <subject_id> --t1 <path/to/subjects/t1/image> --fs_license </path/to/freesurfer/license>`
Some files of **FreeSurfer** binaries require bypassing MacOS security, which is
significantly easier to do with the following command than manually and one by one.
`

xattr -dr com.apple.quarantine /Applications/freesurfer/*`
2 changes: 1 addition & 1 deletion doc/overview/docker.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Docker Support
--------------

.. include:: ../../Docker/README.md
.. include:: ../../tools/Docker/README.md
:parser: fix_links.parser
:relative-docs: .
:relative-images:
Expand Down
2 changes: 1 addition & 1 deletion doc/overview/singularity.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Singularity Support
-------------------

.. include:: ../../Singularity/README.md
.. include:: ../../tools/Singularity/README.md
:parser: fix_links.parser
:relative-docs: .
:relative-images:
Expand Down
2 changes: 1 addition & 1 deletion recon_surf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Check [Dockerhub](https://hub.docker.com/r/deepmi/fastsurfer/tags) to find out t
* The `-B` commands mount your output, and directory with the FreeSurfer license file into the Singularity container.
Inside the container these are visible under the name following the colon (in this case /data, /output, and /fs_license).

* The `--no-home` command disables the automatic mount of the users home directory (see [Best Practice](../Singularity/README.md#mounting-home))
* The `--no-home` command disables the automatic mount of the users home directory (see [Best Practice](../tools/Singularity/README.md#mounting-home))

The `--t1` and `--asegdkt_segfile` flags point to the already existing conformed T1 input and segmentation from the
segmentation module. Also other files from that pipeline will be reused (e.g. the `mask.mgz`, `orig_nu.mgz`). The
Expand Down
2 changes: 1 addition & 1 deletion Docker/Dockerfile → tools/Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ RUN python /install/install_env.py -m ${DEVICE} -i /install/fastsurfer.yml -o /i
FROM build_base AS build_freesurfer

# get install scripts into docker
COPY ./Docker/install_fs_pruned.sh /install/
COPY ./tools/install_fs_pruned.sh /install/
SHELL ["/bin/bash", "--login", "-c"]

ARG FREESURFER_URL=default
Expand Down
4 changes: 2 additions & 2 deletions Docker/README.md → tools/Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ docker run --gpus all -v /home/user/my_mri_data:/data \
* The `--t1` points to the t1-weighted MRI image to analyse (full path, with mounted name inside docker: /home/user/my_mri_data => /data)
* The `--sid` is the subject ID name (output folder name)
* The `--sd` points to the output directory (its mounted name inside docker: /home/user/my_fastsurfer_analysis => /output)
* [more flags](../doc/overview/FLAGS.md#fastsurfer-flags)
* [more flags](../../doc/overview/FLAGS.md#fastsurfer-flags)

Note, that the paths following `--fs_license`, `--t1`, and `--sd` are __inside__ the container, not global paths on your system, so they should point to the places where you mapped these paths above with the `-v` arguments.

A directory with the name as specified in `--sid` (here subjectX) will be created in the output directory (specified via `--sd`). 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.

All other available flags are identical to the ones explained on the main page [README](../README.md).
All other available flags are identical to the ones explained on the main page [README](../../README.md).

### Docker Best Practice
* Do not mount the user home directory into the docker container as the home directory.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading