From b2d0f521f1381701711ed5ae0e6b49132b6e5dfa Mon Sep 17 00:00:00 2001 From: Joshua Scarsbrook Date: Thu, 12 Sep 2024 18:53:57 +1000 Subject: [PATCH] Added synthstrip 7.4.1 --- recipes/synthstrip/README.md | 15 +++++++++++ recipes/synthstrip/build.sh | 37 +++++++++++++++++++++++++++ recipes/synthstrip/synthstrip.star | 41 ++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 recipes/synthstrip/README.md create mode 100755 recipes/synthstrip/build.sh create mode 100644 recipes/synthstrip/synthstrip.star diff --git a/recipes/synthstrip/README.md b/recipes/synthstrip/README.md new file mode 100644 index 00000000..862ad23f --- /dev/null +++ b/recipes/synthstrip/README.md @@ -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 + +---------------------------------- diff --git a/recipes/synthstrip/build.sh b/recipes/synthstrip/build.sh new file mode 100755 index 00000000..b935f8ee --- /dev/null +++ b/recipes/synthstrip/build.sh @@ -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 diff --git a/recipes/synthstrip/synthstrip.star b/recipes/synthstrip/synthstrip.star new file mode 100644 index 00000000..e25fe119 --- /dev/null +++ b/recipes/synthstrip/synthstrip.star @@ -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")