Skip to content

Commit

Permalink
Merge pull request #804 from NeuroDesk/synthstrip
Browse files Browse the repository at this point in the history
Added synthstrip 7.4.1
  • Loading branch information
stebo85 authored Sep 13, 2024
2 parents 0a8de25 + b2d0f52 commit 0364d2e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
15 changes: 15 additions & 0 deletions recipes/synthstrip/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

----------------------------------
## synthstrip/toolVersion##

SynthStrip is a skull-stripping tool that extracts brain voxels from a landscape of image types, ranging across imaging modalities, resolutions, and subject populations. It leverages a deep learning strategy to synthesize arbitrary training images from segmentation maps, yielding a robust model agnostic to acquisition specifics.

**Citation:** SynthStrip: Skull-Stripping for Any Brain Image Andrew Hoopes, Jocelyn S. Mora, Adrian V. Dalca, Bruce Fischl*, Malte Hoffmann* (*equal contribution) NeuroImage 260, 2022, 119474 https://doi.org/10.1016/j.neuroimage.2022.119474

**Homepage:** https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/

**Example:** `mri_synthstrip`

**License:** FreeSurfer Software License Agreement

----------------------------------
37 changes: 37 additions & 0 deletions recipes/synthstrip/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e

export toolName='synthstrip'
export toolVersion='7.4.1'

if [ "$1" != "" ]; then
echo "Entering Debug mode"
export debug=$1
fi

source ../main_setup.sh

# Use Singlrity/Apptainer to run TinyRange to generate the rootfs.
singularity run -B /storage:/storage docker://ghcr.io/tinyrange/tinyrange:stable build synthstrip.star:synthstrip_root -o synthstrip.tar

# Make sure the automaticcly included template doesn't add to the final layer.
neurodocker generate ${neurodocker_buildMode} \
--base-image ubuntu \
--pkg-manager apt \
--base-image scratch \
--add synthstrip.tar . \
--run "/init -run-scripts /.pkg/scripts.json" \
--run "/init -run-scripts /wheels/scripts.json" \
--run="printf '#!/bin/bash\nls -la' > /usr/bin/ll" \
--run="chmod +x /usr/bin/ll" \
--run="mkdir -p ${mountPointList}" \
--env FREESURFER_HOME=/freesurfer \
--run="ln -s /usr/bin/python3 /usr/bin/python" \
--entrypoint "/bin/bash" \
--env DEPLOY_BINS=mri_synthstrip \
--copy README.md /README.md \
> ${imageName}.${neurodocker_buildExt}

if [ "$1" != "" ]; then
./../main_build.sh
fi
41 changes: 41 additions & 0 deletions recipes/synthstrip/synthstrip.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
load("//lib/pypi.star", "build_fs_for_requirements")

requirements = "https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/requirements/requirements.txt"

files = [
"https://github.com/freesurfer/freesurfer/raw/v7.4.1/mri_synthstrip/mri_synthstrip",
"https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/requirements/synthstrip.1.pt",
"https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/requirements/synthstrip.nocsf.1.pt",
]

base = define.plan(
builder = "ubuntu@jammy",
packages = [
query("python3-pip"),
query("python3-packaging"),
],
tags = ["level3", "defaults"],
)

requirements_fs = build_fs_for_requirements(base, define.fetch_http(requirements))

def synthstrip_fs(ctx, script, data_1, data_2):
ret = filesystem()

ret["usr/bin/mri_synthstrip"] = file(script, executable = True)

ret["freesurfer/models/synthstrip.1.pt"] = data_1
ret["freesurfer/models/synthstrip.nocsf.1.pt"] = data_2

return ctx.archive(ret)

synthstrip_root = define.build_fs([
base.set_tags([
"level3",
"defaults",
"noScripts",
]),
requirements_fs,
define.build(synthstrip_fs, *[define.fetch_http(file) for file in files]),
directive.builtin("init", "/init"),
], "tar")

0 comments on commit 0364d2e

Please sign in to comment.