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

24 enh test and push docker container for petdeface to dockerhub #29

Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ integration_testing.sh
petdeface/Dockerfile
petdeface/README.md
petdeface/pyproject.toml
freesurfer_binaries/*
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,32 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libxft2 \
libxrender1 \
libxt6
libxt6 \
ffmpeg \
libsm6

# Install Freesurfer
ENV FREESURFER_HOME="/opt/freesurfer" \
PATH="/opt/freesurfer/bin:$PATH" \
FREESURFER_VERSION=7.4.1

RUN curl -L --progress-bar https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${FREESURFER_VERSION}/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz | tar xzC /opt && \
echo ". /opt/freesurfer/SetUpFreeSurfer.sh" >> ~/.bashrc
# copy over local freesurfer binaries
RUN mkdir /freesurfer_binaries
COPY freesurfer_binaries/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz /freesurfer_binaries/

ARG USE_LOCAL_FREESURFER
RUN echo USE_LOCAL_FREESURFER=${USE_LOCAL_FREESURFER}

RUN if [ "$USE_LOCAL_FREESURFER" = "True" ]; then \
echo "Using local freesurfer binaries."; \
tar xzC /opt -f /freesurfer_binaries/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz && \
echo ". /opt/freesurfer/SetUpFreeSurfer.sh" >> ~/.bashrc; \
fi && \
if [ "$USE_LOCAL_FREESURFER" = "False" ]; then \
echo "Using freesurfer binaries from surfer.nmr.mgh.harvard.edu."; \
curl -L --progress-bar https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${FREESURFER_VERSION}/freesurfer-linux-centos7_x86_64-${FREESURFER_VERSION}.tar.gz | tar xzC /opt && \
echo ". /opt/freesurfer/SetUpFreeSurfer.sh" >> ~/.bashrc; \
fi

# set bash as default terminal
SHELL ["/bin/bash", "-ce"]
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ testall: testlayouts
# install python dependencies
pythondeps:
pip install --upgrade pip && pip install -e .

# create petdafec docker image with tag (petdeface:X.X.X) from toml file by using cat and grep to
# extract the project name from the pyproject.toml file


USE_LOCAL_FREESURFER ?= False
bendhouseart marked this conversation as resolved.
Show resolved Hide resolved
dockerbuild:
docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t $(shell cat pyproject.toml | grep name | cut -d '"' -f 2):$(shell cat pyproject.toml | grep version | head -n 1 | cut -d '"' -f 2) .
docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t $(shell cat pyproject.toml | grep name | cut -d '"' -f 2):latest .

dockerbuildlatest:
docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t $(shell cat pyproject.toml | grep name | cut -d '"' -f 2):latest .
6 changes: 6 additions & 0 deletions freesurfer_binaries/freesurfer_binaries_readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This folder exists as a place to keep copies of freesurfer binaries downloaded from:

https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/${Version}/freesurfer-linux-centos7_x86_64-${Version}.tar.gz

This folder solely exists to speed up docker builds! All content in this folder barring this text file should
be git ignored!!!
15 changes: 13 additions & 2 deletions petdeface/petdeface.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def deface(args: Union[dict, argparse.Namespace]) -> None:
)

# clean up and create derivatives directories
if args.output_dir is None:
if args.output_dir == "None" or args.output_dir is None:
bendhouseart marked this conversation as resolved.
Show resolved Hide resolved
output_dir = os.path.join(args.bids_dir, "derivatives", "petdeface")
else:
output_dir = args.output_dir
Expand Down Expand Up @@ -276,8 +276,15 @@ def init_single_subject_wf(
workflow_name = f"t1w_{anat_string}_wf"

t1w_wf = Workflow(name=workflow_name)

# create preview pics
if determine_in_docker():
preview_pics = False
else:
preview_pics = True

deface_t1w = Node(
Mideface(in_file=pathlib.Path(t1w_file), pics=True, odir=".", code=f"{anat_string}"),
Mideface(in_file=pathlib.Path(t1w_file), pics=preview_pics, odir=".", code=f"{anat_string}"),
name=f"deface_t1w_{anat_string}",
)
t1w_wf.connect(
Expand Down Expand Up @@ -732,6 +739,10 @@ def main(): # noqa: max-complexity: 12

input_mount_point = str(args.input_dir)
output_mount_point = str(args.output_dir)

if output_mount_point == "None" or output_mount_point is None:
output_mount_point = str(args.input_dir / "derivatives" / "petdeface")

args.input_dir = pathlib.Path("/input")
args.output_dir = pathlib.Path("/output")
print(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bids_version = "1.8.0"
python = ">=3.10, <4.0"
niworkflows = { git = "https://github.com/nipreps/niworkflows.git" }
setuptools = "^68.1.2"
petutils = "^0.0.0"
petutils = "^0.0.1"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
Expand Down