Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deployment and add version notice #77

Merged
merged 11 commits into from
Sep 7, 2023
39 changes: 22 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ jobs:
build:
machine:
image: ubuntu-2204:2022.10.2
resource_class: large
parameters:
version:
type: string
steps:
- checkout
- restore_cache:
keys:
- v_0-image_cache_fs<< parameters.version >>-{{ checksum "Dockerfile_fs<< parameters.version >>" }}
- run:
name: load and build
command: |
Expand All @@ -28,11 +26,6 @@ jobs:
echo "cHJpbnRmICJEeWxhbi5OaWVsc29uQGdtYWlsLmNvbVxuMzcwNjNcbiAqQ1lrZWhQYUNvRDlNXG4gRlM2N1BTWmRFV2lqb1xuIiA+IH4vbGljZW5zZS9saWNlbnNlLnR4dA==" | base64 -d | sh
cp ~/license/license.txt ~/license_fs<< parameters.version >>/license.txt
rm -r ~/license
- save_cache:
key: v_0-image_cache_fs<< parameters.version >>-{{ checksum "Dockerfile_fs<< parameters.version >>" }}-{{ .Revision }}-{{ epoch }}
paths:
- ~/docker
- ~/license_fs<< parameters.version >>
- persist_to_workspace:
root: /home/circleci
paths:
Expand Down Expand Up @@ -198,20 +191,31 @@ jobs:

# make sure we have a lowercase repo
user_name="bids"
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}_fs<< parameters.version >>" | tr '[:upper:]' '[:lower:]')
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
FS_MAJOR_VERSION=<< parameters.version >>
if [[ FS_MAJOR_VERSION -eq 6 ]]; then
FS_VERSION=6.0.1
else
FS_VERSION=7.4.1
fi

if [[ -n "${DOCKER_TOKEN}" ]]; then
echo "${DOCKER_TOKEN}" | docker login -u "${DOCKER_USER}" --password-stdin

: "Pushing to DockerHub ${user_name}/${repo_name}:unstable"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:unstable"
docker push "${user_name}/${repo_name}:unstable"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FS_VERSION}-unstable"
docker push "${user_name}/${repo_name}:${FS_VERSION}-unstable"

if [[ -n "${CIRCLE_TAG}" ]]; then
: "Pushing to DockerHub ${user_name}/${repo_name}:${FS_VERSION}-${CIRCLE_TAG}"
if [[ FS_MAJOR_VERSION -eq 6 ]]; then
docker push "${user_name}/${repo_name}:latest"
fi

if [[ -n "${CIRCLE_TAG}" ]]; then
: "Pushing to DockerHub ${user_name}/${repo_name}:${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:latest"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:${CIRCLE_TAG}"
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FS_MAJOR_VERSION}"
docker push ${user_name}/${repo_name}:${FS_MAJOR_VERSION}
docker tag "${user_name}/${repo_name}" "${user_name}/${repo_name}:${FS_VERSION}-${CIRCLE_TAG}"
docker push "${user_name}/${repo_name}:${FS_VERSION}-${CIRCLE_TAG}"
fi

fi
Expand Down Expand Up @@ -244,6 +248,7 @@ workflows:
only: /.*/

- test:
name: test_<< matrix.version >>
matrix:
parameters:
version: ['6', '7']
Expand All @@ -263,7 +268,7 @@ workflows:
context:
- dockerhub
requires:
- test
- test_<< matrix.version >>
filters:
branches:
ignore: /.*/
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

### Description
This app implements surface reconstruction using Freesurfer. It reconstructs the surface for each subject individually and then
creates a study specific template. In case there are multiple sessions the Freesurfer longitudinal pipeline is used (creating subject specific templates) unless instructed to combine data across sessions. This app is available for both Freesurfer 6 and 7.
creates a study specific template. In case there are multiple sessions the Freesurfer longitudinal pipeline is used (creating subject specific templates) unless instructed to combine data across sessions. This app is available for both Freesurfer 6 and 7.

The current Freesurfer version for Freesurfer 6 is based on: freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1.tar.gz
The current Freesurfer version for Freesurfer 6 is based on: freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.1.tar.gz
The current Freesurfer version for Freesurfer 7 is based on: freesurfer-linux-centos7_x86_64-7.4.1.tar.gz

We only plan to support ove version of Freesurfer 6 and Freesurfer 7 at a time.

The output of the pipeline consist of the SUBJECTS_DIR created during the analysis.

### How to get it

Freesurfer 6 will remain the default image till 2024, at which point Freesurfer 7 will become the default.

You can get the default version with `docker pull bids/freesurfer`.

Freesurfer 7 is available at `docker pull bids/freesurfer:7`.

Freesurfer 6 is available at `docker pull bids/freesurfer:6`.

### Documentation
- [Surface reconstruction](https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all)
- [Study specific template creation](https://surfer.nmr.mgh.harvard.edu/fswiki/SurfaceRegAndTemplates#CreatingaregistrationtemplateinitializedwithFreeSurfertemplate.28DG.29)
Expand Down
17 changes: 13 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
def run(command, env={}, ignore_errors=False):
merged_env = os.environ
merged_env.update(env)

# DEBUG env triggers freesurfer to produce gigabytes of files
merged_env.pop('DEBUG', None)
process = Popen(command, stdout=PIPE, stderr=subprocess.STDOUT, shell=True, env=merged_env)
Expand All @@ -27,7 +28,17 @@ def run(command, env={}, ignore_errors=False):
if process.returncode != 0 and not ignore_errors:
raise Exception("Non zero return code: %d" % process.returncode)


# warn about freesurfer version
with open(os.path.join(os.environ['FREESURFER_HOME'], 'build-stamp.txt'), 'r') as h:
bs = h.read()
if 'x86_64-7.' in bs:
fsversion=7
else:
fsversion=6
warn("You are using FreeSurver version 6. "
"The FreeSurfer 7 BIDS-App is now available via docker pull bids/freesurfer:v7 . "
"FreeSurfer 7 will become the default version in the FreeSurfer BIDS-App begining in 2024. "
"From that point on, the FreeSurfer 6 BIDS-App will remain available at bids/freesurfer:v6 .")
__version__ = open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'version')).read()

parser = argparse.ArgumentParser(description='FreeSurfer recon-all + custom template generation.')
Expand Down Expand Up @@ -519,9 +530,7 @@ def run(command, env={}, ignore_errors=False):

# The call to python2 is only required if we're running Freesurfer 6, we'll need to check version
# and modify the calls accordingly.
with open(os.path.join(os.environ['FREESURFER_HOME'], 'build-stamp.txt'), 'r') as h:
bs = h.read()
if '-7.' in bs:
if fsversion == 7:
cmd_start = ''
else:
cmd_start = 'python2 '
Expand Down