External Email - Use Caution
#########STAGE 1: CREATE THE MOUNT AND COPY THE MRIs TO BE SKULL-STRIPPED######### # Use ubuntu as base image FROM ubuntu AS prepare # Set working directory WORKDIR /app # Copy all MRIs COPY . . #########STAGE 2: USE SYNTHSTRIP######### FROM freesurfer/synthstrip # Set working directory WORKDIR /app # Copy all MRIs COPY --from=prepare . . # Create a loop that runs through the MRIs RUN for file in .; do freesurfer/synthstrip -i "$file" -o "$file"; done ENTRYPOINT ["ls"]
#########STAGE 1: CREATE THE SYNTHSTRIP CONTAINER########### # Use synthstrip AS base image FROM freesurfer/synthstrip as builder # Set working directory WORKDIR /app #########STAGE 2: CREATE THE ANACONDA CONTAINER########### # Use miniconda as base image FROM continuumio/miniconda3 # Set working directory WORKDIR /app # Copy the initial image COPY --from=builder . . # Create the environment COPY environment.yml . RUN conda env create -f environment.yml # Make run commands use the new environment SHELL ["conda", "run", "-n", "app", "bin/bash", "-c"] # Code to run when the container is started COPY main.py . ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "app", "python", "main.py"]
import os import subprocess for MRI in os.listdir('./file_with_MRIs'): print(MRI) proc = subprocess.Popen(['docker run freesurfer/synthstrip -i ', MRI, ' -o', MRI], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE ) (out, err) = proc.communicate() print (out)