Medical Image Analysis using Python and Docker
Rudolph Pienaar, PhD
Staff Scientist, Boston Children's Hospital
rudolph.pienaar@childrens.harvard.edu
quick "bio"
- MRI analysis
- Software development
- Web-based workflows
- Imaging on the web
- HPC via web front end
- encapsulating compute in "docks"
overview
- introduction to docks
- "lay of the land"
- practical examples
- coding our own example in a dock!
what are docks?
- simply: docks are a mechanism to encapsulate an application and all its dependencies in a manner that is logically isolated from other contained apps;
- can be thought of as something between a chroot and a virtual machine
the view from 30,000 feet...
or 10,000m :-)
the lay of the land...
- what are we going to do?
- how are we going to do this?
- why are we going to do this?
what are we going to do?
- talk about docks;
- use some sample/example docks;
- create a python app in a dock;
- create a web-server dock;
- seamlessly share data and results between the python dock and the web server dock;
how are we going to do it?
- fire up some docks ourselves;
- interface with these docks;
- follow a tutorial;
- build our own!
why are we going to do it?
- demonstrate how powerful and portable docks are;
- and how fun they can be!
first...
- some conceptual views on apps...
application / hardware
application / VM hardware
application / VM full
application / streamline
application / containers
application / containers
practicalities...
- all docks/containers run on the same underlying kernel as the host
- pros:
- fast (almost immediate) execution
- no startup penalty
- cons:
- all "apps" must inherently run on the same underlying Linux kernel
- all "apps" are thus ultimately Linux apps
practicalities...
- install the docker app on
- linux (easiest)
- mac (close second)
- windows (depends... :-)
- import some pre-made docker images
http://book.orthanc-server.com/users/docker.html
exercise
- start a docker running a PACS server
- start another dock running a stripped down ubuntu
- send information stored on the host from one dock to another...
# Run the Orthanc PACS container
docker run -p 4242:4242 -p 8042:8042 --rm \
-v ~/research/chris/data/orthanc-db/:/var/lib/orthanc/db/ \
jodogne/orthanc-plugins
# Run the "FNNDSC" ubuntu container
docker run -v /Users:/Users -it ubuntu-fnndsc
# On first setup, create group and user:
addgroup --gid 1102 fnndsc
adduser --disabled-password --gecos '' --uid 6244 --gid 1102 rudolph
# exit
exit
# "commit" the changes in this dock:
docker ps -a
docker commit 3f06ea36c5ad ubuntu-fnndsc
# Now run the container again, and connect tunnels...
docker run -v /Users:/Users -it ubuntu-fnndsc
# connect a forward tunnel from 4242 in the dock to the host 4242
ssh -g -f -N -X -L 4242:localhost:4242 rudolph.pienaar@172.16.32.31
# Now, goto some dir containing DCM files on the host FS
cd someDir
# and transmit them via the tunnel to the Orthanc dock!
dicom_dirSend.bash -v 10 -a rudolph -h localhost -p 4242 -E dcm [a-z]* [A-Z]*
# For kicks, attach to the Orthanc dock
docker ps
docker exec -i -t e99a7e5897dd /bin/bash
exercise
- start a docker running a web server
- edit a document on the host and display via the docked web server!
# Run the web server container
docker run -d -p 8000:80 nginx
# Connect to this container and look at the html dir...
docker exec -it <ID> /bin/bash
# The nginx html dir is
cd /usr/share/nginx/html
# exit the container
exit
# and map a local dir "over" this one
docker run -d -p 8000:80 \
-v ~/research/chris/web/:/usr/share/nginx/html/ \
--name webserver nginx
exercise
- Now, let's build our python app!
# Run the ubuntu dock with port forwarding for the ipython notebook
docker run -v /Users:/Users \
-p 8888:8888 -p 8000:80 \
-it ubuntu-fnndsc
# Now run the ipython notebook in the dock
ipython3 notebook --ip="*"
# and connect to it from the host on localhost:8888
# useful cleanup!
docker rm -v $(docker ps -a -q -f status=exited)
let's program!
finis
Medical image analysis with Python and docks
By Rudolph Pienaar
Medical image analysis with Python and docks
- 1,320