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

Add Docker for PyRadiomics-dcm Labs #527

Merged
merged 4 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
125 changes: 63 additions & 62 deletions docker/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ FROM centos:6
MAINTAINER http://github.com/radiomics

RUN yum update -y && \
yum groupinstall -y "Development Tools" && \
yum install -y curl \
curl-devel \
coreutils \
freetype-devel \
gcc \
gcc-c++ \
gettext \
libpng-devel \
openssl-devel \
perl \
perl-CPAN \
perl-ExtUtils-MakeMaker \
wget \
zlib-devel
yum groupinstall -y "Development Tools" && \
yum install -y bzip2-devel \
curl \
curl-devel \
coreutils \
freetype-devel \
gcc \
gcc-c++ \
gettext \
libpng-devel \
openssl-devel \
perl \
perl-CPAN \
perl-ExtUtils-MakeMaker \
wget \
zlib-devel

WORKDIR /etc/yum.repos.d
RUN wget http://people.centos.org/tru/devtools-2/devtools-2.repo
RUN yum install -y devtoolset-2-gcc \
devtoolset-2-binutils \
devtoolset-2-gcc-gfortran \
devtoolset-2-gcc-c++
devtoolset-2-binutils \
devtoolset-2-gcc-gfortran \
devtoolset-2-gcc-c++
ENV CC /opt/rh/devtoolset-2/root/usr/bin/gcc
ENV CXX /opt/rh/devtoolset-2/root/usr/bin/g++
ENV FC /opt/rh/devtoolset-2/root/usr/bin/gfortran
Expand All @@ -42,72 +43,72 @@ ENV FC /opt/rh/devtoolset-2/root/usr/bin/gfortran
WORKDIR /usr/src
ENV GIT_VERSION 2.5.0
RUN wget --no-check-certificate https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz && \
tar xvzf git-${GIT_VERSION}.tar.gz && \
cd git-${GIT_VERSION} && \
./configure --prefix=/usr && \
make && \
make install && \
cd .. && rm -rf git-${GIT_VERSION}*
tar xvzf git-${GIT_VERSION}.tar.gz && \
cd git-${GIT_VERSION} && \
./configure --prefix=/usr && \
make && \
make install && \
cd .. && rm -rf git-${GIT_VERSION}*

# Build and install CMake from source.
WORKDIR /usr/src
RUN git clone git://cmake.org/cmake.git CMake && \
cd CMake && \
git checkout v3.7.2 && \
mkdir /usr/src/CMake-build && \
cd /usr/src/CMake-build && \
/usr/src/CMake/bootstrap \
--parallel=$(grep -c processor /proc/cpuinfo) \
--prefix=/usr && \
make -j$(grep -c processor /proc/cpuinfo) && \
./bin/cmake \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_USE_OPENSSL:BOOL=ON . && \
make install && \
cd .. && rm -rf CMake*
cd CMake && \
git checkout v3.7.2 && \
mkdir /usr/src/CMake-build && \
cd /usr/src/CMake-build && \
/usr/src/CMake/bootstrap \
--parallel=$(grep -c processor /proc/cpuinfo) \
--prefix=/usr && \
make -j$(grep -c processor /proc/cpuinfo) && \
./bin/cmake \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_USE_OPENSSL:BOOL=ON . && \
make install && \
cd .. && rm -rf CMake*

# Build and install Python from source.
WORKDIR /usr/src
ENV PYTHON_VERSION 3.6.9
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
tar xvzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure && \
make -j$(grep -c processor /proc/cpuinfo) && \
make install && \
cd .. && rm -rf Python-${PYTHON_VERSION}*
tar xvzf Python-${PYTHON_VERSION}.tgz && \
cd Python-${PYTHON_VERSION} && \
./configure && \
make -j$(grep -c processor /proc/cpuinfo) && \
make install && \
cd .. && rm -rf Python-${PYTHON_VERSION}*

# Build and install ninja from source.
WORKDIR /usr/src
RUN git clone https://github.com/martine/ninja.git && \
cd ninja && \
git checkout v1.6.0 && \
./configure.py --bootstrap && \
mv ninja /usr/bin/ && \
cd .. && rm -rf ninja
cd ninja && \
git checkout v1.6.0 && \
./configure.py --bootstrap && \
mv ninja /usr/bin/ && \
cd .. && rm -rf ninja

# Setup Python package manager (pip)
WORKDIR /usr/src
RUN python3 --version && \
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && rm get-pip.py

# Setup necessary python packages
WORKDIR /usr/src
RUN pip3 install wheel>=0.29.0 && \
pip3 install setuptools>=28.0.0 && \
pip3 install scipy && \
pip3 install trimesh && \
pip3 install scikit-image && \
pip3 install --trusted-host www.itk.org -f https://itk.org/SimpleITKDoxygen/html/PyDownloadPage.html SimpleITK>=0.9.1 && \
python3 -c "import SimpleITK; print('SimpleITK Version:' + SimpleITK.Version_VersionString())"
pip3 install setuptools>=28.0.0 && \
pip3 install scipy && \
pip3 install trimesh && \
pip3 install scikit-image && \
pip3 install --trusted-host www.itk.org -f https://itk.org/SimpleITKDoxygen/html/PyDownloadPage.html SimpleITK>=0.9.1 && \
python3 -c "import SimpleITK; print('SimpleITK Version:' + SimpleITK.Version_VersionString())"

# Install PyRadiomics
# Install PyRadiomics, then remove the source code to reduce image size
WORKDIR /usr/src
RUN git clone https://github.com/radiomics/pyradiomics.git && \
cd pyradiomics && \
pip3 install -r requirements.txt && \
python3 setup.py install
ADD . /usr/src/pyradiomics
RUN cd pyradiomics && \
pip3 install --no-cache-dir -r requirements.txt && \
python3 setup.py install && \
cd .. && rm -rf pyradiomics

WORKDIR /usr/src
ENTRYPOINT ["pyradiomics"]
25 changes: 25 additions & 0 deletions labs/pyradiomics-dcm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM radiomics/pyradiomics:CLI
MAINTAINER https://github.com/Radiomics

# Install required dcm2niix converions tools
WORKDIR /usr/src
RUN git clone https://github.com/rordenlab/dcm2niix.git && \
cd dcm2niix && \
mkdir build && cd build && \
cmake .. && \
make install

# Install additional needed python packages
# Prevent pandas from installing version 0.25.0, as this version is unable to import
# module _lzma (in package lmza). See also https://github.com/pandas-dev/pandas/issues/27543
WORKDIR /usr/src
RUN pip3 install pandas!=0.25.0 && \
pip3 install pydicom

# Copy the required DCMQI tools from the latest DCMQI docker image
COPY --from=qiicr/dcmqi:latest /usr/bin/tid1500writer /usr/bin/segimage2itkimage /usr/bin/
# Copy the pyradiomics-dcm.py script to ensure latest changes are included in the image
COPY ./labs/pyradiomics-dcm/* /usr/src/pyradiomics/labs/pyradiomics-dcm/

WORKDIR /usr/src/pyradiomics/labs/pyradiomics-dcm
ENTRYPOINT ["python3", "pyradiomics-dcm.py"]
3 changes: 1 addition & 2 deletions labs/pyradiomics-dcm/pyradiomics-dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
scriptlogger = logging.getLogger('radiomics.dicom')
scriptlogger.setLevel(logging.DEBUG)


def dcmImageToNRRD(inputDICOMImageDir, tempDir):
scanNRRDFile = os.path.join(tempDir, "image.nrrd")
if not os.path.isfile(scanNRRDFile):
Expand All @@ -35,7 +34,7 @@ def dcmImageToNIfTI(inputDICOMImageDir, tempDir):
scanJSONFile = os.path.join(inputDICOMImageDir, "volume.json")
# will save to volume.nii
if not os.path.isfile(destScanNIfTIFile):
cmd = ['dcm2niix', "-m", "y", inputDICOMImageDir]
cmd = ['dcm2niix', "-m", "y", "-f", "volume", inputDICOMImageDir]
call(cmd)
shutil.move(scanNIfTIFile, destScanNIfTIFile)
if os.path.isfile(scanJSONFile):
Expand Down