diff --git a/Dockerfile b/Dockerfile index 902d725..fa54d73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ -# warning: unofficial base image is not stable and may change in the future! -FROM docker.io/fnndsc/mni-conda-base:unofficial +FROM docker.io/fnndsc/pl-fetal-surface-extract:base-1 LABEL org.opencontainers.image.authors="Jennings Zhang " \ org.opencontainers.image.title="pl-fetal-surface-extract" \ diff --git a/base/.dockerignore b/base/.dockerignore new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/base/.dockerignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/base/Dockerfile b/base/Dockerfile new file mode 100644 index 0000000..97b4f4b --- /dev/null +++ b/base/Dockerfile @@ -0,0 +1,41 @@ +FROM docker.io/fnndsc/microminc-builder:latest as builder + +RUN microminc.sh \ + adapt_object_mesh \ + dilate_volume \ + minccalc \ + mincchamfer \ + mincdefrag \ + mincresample \ + mincreshape \ + param2xfm \ + sphere_mesh \ + surface_mask2 \ + transform_objects \ + inflate_to_sphere_implicit \ + inflate_to_sphere \ + create_tetra \ + print_n_polygons \ + subdivide_polygons \ + interpolate_sphere \ + depth_potential \ + vertstats_math \ + volume_object_evaluate \ + adapt_metric \ + depth_potential \ + /microminc + +# perl libraries need to be copied manually +RUN cp -r /opt/CIVET/dist/perl /microminc/perl + +# MNI data needs to be copied manually +RUN mkdir -vp /microminc/share \ + && cp -rv "$MNI_DATAPATH/surface-extraction" "/microminc/share" + +FROM fnndsc/conda:python3.11.2 +COPY --from=builder /microminc /opt/microminc +ENV PATH=/opt/microminc/bin:$PATH \ + LD_LIBRARY_PATH=/opt/microminc/lib:$LD_LIBRARY_PATH \ + MINC_FORCE_V2=1 MINC_COMPRESS=4 VOLUME_CACHE_THRESHOLD=-1 \ + MNI_DATAPATH=/opt/microminc/share \ + PERL5LIB=/opt/microminc/perl diff --git a/base/README.md b/base/README.md new file mode 100644 index 0000000..8cb5e7f --- /dev/null +++ b/base/README.md @@ -0,0 +1,5 @@ +Uses [microminc](https://github.com/FNNDSC/microminc) +to create a minimized base image for `pl-fetal-surface-extract`, +which copies the necessary minc-tool binaries to a multi-arch conda image. + +This image is built and pushed manually. diff --git a/base/build.sh b/base/build.sh new file mode 100755 index 0000000..c7dfa5e --- /dev/null +++ b/base/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash -ex + +exec docker buildx build --push \ + --platform linux/amd64,linux/arm64,linux/ppc64le \ + --build-arg http_proxy=$http_proxy \ + -t docker.io/fnndsc/pl-fetal-surface-extract:base-1 . diff --git a/extract_cp/extract_surface.py b/extract_cp/extract_surface.py index a5ff4a5..6ffded7 100644 --- a/extract_cp/extract_surface.py +++ b/extract_cp/extract_surface.py @@ -241,9 +241,9 @@ def __pick_side(mask: Path, side: SideStr) -> Optional[Side]: return Side.RIGHT if side == 'auto': path = str(mask).lower() - if 'left' in path: + if 'left' in path or mask.name.startswith('lh.'): return Side.LEFT - if 'right' in path: + if 'right' in path or mask.name.startswith('rh.'): return Side.RIGHT raise ValueError(f'Substring "left" nor "right" found in: {path}') if side == 'none':