Commit 2bab8540 authored by Andrea Bizzego's avatar Andrea Bizzego
Browse files

Initial commit

parents
# To test:
# docker pull circleci/picard
# docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):$(pwd) -v ~/.circleci/:/root/.circleci --workdir $(pwd) circleci/picard circleci build
version: 2
jobs:
test-notebooks:
working_directory: /pyradiomics
docker:
- image: jupyter/datascience-notebook
user: root
steps:
- run:
# CircleCI says we need SSH and the docker doesn't have it installed
name: Update
command: |
apt-get update
apt-get install -y openssh-client openssh-server
- run:
name: Avoid hosts unknown for github
command: echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > /etc/ssh/ssh_config
- checkout
- run:
# Jupyter datascience notebook does not support python 2 anymore, install it manually.
# See also https://github.com/jupyter/docker-stacks/issues/432
# Next, install python 2 kernel globally, so it can be found from the root
name: Install Python 2 Kernel
command: |
conda create -n python2 python=2 ipykernel
pip install kernda --no-cache
$CONDA_DIR/envs/python2/bin/python -m ipykernel install
kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json
pip uninstall kernda -y
- run:
name: Install pyradiomics in Python 2 and 3
command: |
source activate python2
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements-dev.txt
python setup.py install
source activate root
python -m pip install --no-cache-dir -r requirements.txt
python -m pip install --no-cache-dir -r requirements-dev.txt
python setup.py install
- run:
name: test notebooks in python 2 and 3
command: |
jupyter nbconvert --ExecutePreprocessor.kernel_name=python2 --ExecutePreprocessor.timeout=-1 --to notebook --output-dir /tmp --execute notebooks/helloRadiomics.ipynb notebooks/helloFeatureClass.ipynb notebooks/PyRadiomicsExample.ipynb
jupyter nbconvert --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.timeout=-1 --to notebook --output-dir /tmp --execute notebooks/helloRadiomics.ipynb notebooks/helloFeatureClass.ipynb notebooks/PyRadiomicsExample.ipynb
build-2.7: &build_template
working_directory: /pyradiomics
docker:
- image: circleci/python:2.7-jessie
user: root
steps:
- checkout
- attach_workspace:
at: /pyradiomics
- run:
name: Setup SciKit-CI
command: |
pip install scikit-ci==0.13.0 scikit-ci-addons==0.11.0
ci_addons --install ../addons
- run:
name: Install
command: ci install
- run:
name: Test
command: ci test
- run:
name: Build Distribution
command: ci after_test
- persist_to_workspace:
root: .
paths: dist
build-3.4:
<<: *build_template
docker:
- image: circleci/python:3.4-jessie
user: root
build-3.5:
<<: *build_template
docker:
- image: circleci/python:3.5-jessie
user: root
build-3.6:
<<: *build_template
docker:
- image: circleci/python:3.6-jessie
user: root
deploy:
working_directory: /pyradiomics
docker:
- image: circleci/python:3.6-jessie
user: root
steps:
- checkout
- run:
name: Setup SciKit-CI
command: |
pip install scikit-ci==0.13.0 scikit-ci-addons==0.11.0
ci_addons --install ../addons
- run:
name: Install
command: ci install
- run:
name: Install patchelf auditwheel, twine
command: |
apt-get install patchelf # needed to run auditwheel
python -m pip install auditwheel
python -m pip install twine
# only attach the workspace at this point to prevent the removal of source distributions
- attach_workspace:
at: /pyradiomics
- run:
name: Create sdist
command: python setup.py sdist
- run:
name: Fix Distribution Wheels
command: |
ls ./dist/*-linux_$(uname -m).whl # This will prevent further deployment if no wheels are found
# Since there are no external shared libraries to bundle into the wheels
# this step will fixup the wheel switching from 'linux' to 'manylinux1' tag
for whl in $(ls ./dist/*-linux_$(uname -m).whl); do
auditwheel repair $whl -w ./dist/
rm $whl
done
- run:
name: Deploy source and linux wheels
command: twine upload ./dist/*.whl ./dist/*.tar.gz -u $PYPI_USER -p $PYPI_PASSWORD
workflows:
version: 2
build_and_deploy:
jobs:
- build-2.7: &build_job_template
filters:
tags:
only:
- /^v?[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
- build-3.4:
<<: *build_job_template
- build-3.5:
<<: *build_job_template
- build-3.6:
<<: *build_job_template
- test-notebooks:
requires:
- build-2.7
- build-3.4
- build-3.5
- build-3.6
- deploy:
requires:
- build-2.7
- build-3.4
- build-3.5
- build-3.6
filters:
branches:
ignore:
- /.*/
tags:
only:
- /^v?[0-9]+(\.[0-9]+)*(-rc[0-9]+)?/
# EditorConfig: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[**]
end_of_line = lf
insert_final_newline = true
# Set default charset
[**.py]
indent_style = space
indent_size = 2
charset = utf-8
# Set indentation for C
[**.{c,h}]
indent_style = space
indent_size = 2
# Tab indentation (no size specified)
[**CMakeLists.txt]
indent_style = space
indent_size = 2
[flake8]
max-line-length: 180
# Whether to display the pep8 instructions on failure (can be quite verbose)
show-pep8: False
# Whether to show source code for each failure
show-source: True
# Maximum cyclomatic complexity allowed
max-complexity: 14
format: pylint
exclude: .git,.idea,.eggs,__pycache__,.tox,docs/conf.py,_skbuild,build,versioneer.py
ignore:
# cycolmatic complexity check
C901,
# indentation is not a multiple of four
E111,
# indentation is not a multiple of four (comment)
E114,
# continuation line under-indented for hanging indent
E121,
# missing whitespace around arithmetic operator
E226,
# at least two spaces before inline comment
E261,
# expected 2 blank lines
E302,
# expected 2 blank lines after class or function definition
E305,
# multiple imports on one line
E401,
# module level import not at top of file
E402,
# multiple statements on one line (colon)
E701,
# .has_key() is deprecated, use 'in'
W601,
select: C,E,W,F,I
# flake8-import-order
application-import-names: radiomics,testUtils
import-order-style: appnexus
radiomics/_version.py export-subst
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
# Temp editor files
*~
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# IDE junk
.idea/*
*.swp
# PyBuilder
target/
# Config file for automatic testing at travis-ci.org
language: python
matrix:
include:
- os: osx
language: generic
env:
- PYTHON_VERSION=2.7.12
- os: osx
language: generic
env:
- PYTHON_VERSION=3.4.8
- os: osx
language: generic
env:
- PYTHON_VERSION=3.5.5
- os: osx
language: generic
env:
- PYTHON_VERSION=3.6.5
cache:
directories:
- $HOME/.pyenv/versions/3.6.5
- $HOME/.pyenv/versions/3.5.5
- $HOME/.pyenv/versions/3.4.8
- $HOME/.pyenv/versions/2.7.12
- $HOME/downloads
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir $HOME/bin; ln -s $(which pip2) $HOME/bin/pip; fi
- pip install scikit-ci==0.13.0 scikit-ci-addons==0.11.0
- ci_addons --install ../addons
install:
- ci install
script:
- ci test
after_success:
- ci after_test
before_deploy:
- sudo pip install twine # Twine installation requires sudo to get access to /usr/local/man
deploy:
provider: script
skip_cleanup: true
script: twine upload dist/*.whl -u $PYPI_USER -p $PYPI_PASSWORD
on:
tags: true
condition: $TRAVIS_TAG =~ ^v?[0-9]+(\.[0-9]+)*(-rc[0-9]+)?$
This diff is collapsed.
.. _radiomics-contributing-label:
===========================
Contributing to pyradiomics
===========================
There are many ways to contribute to pyradiomics, with varying levels of effort. Do try to
look through the documentation first if something is unclear, and let us know how we can
do better.
* Ask a question on the `pyradiomics email list <https://groups.google.com/forum/#!forum/pyradiomics)>`_
* Submit a parameter file you used for your extraction
* Submit a feature request or bug, or add to the discussion on the `pyradiomics issue tracker <https://github.com/Radiomics/pyradiomics/issues)>`_
* Submit a `Pull Request <https://github.com/Radiomics/pyradiomics/pulls>`_ to improve pyradiomics or its documentation
We encourage a range of Pull Requests, from patches that include passing tests and
documentation, all the way down to half-baked ideas that launch discussions.
----------------------------------------------
The PR Process, Circle CI, and Related Gotchas
----------------------------------------------
How to submit a PR ?
####################
If you are new to pyradiomics development and you don't have push access to the pyradiomics
repository, here are the steps:
1. `Fork and clone <https://help.github.com/articles/fork-a-repo/>`_ the repository.
2. Create a branch.
3. `Push <https://help.github.com/articles/pushing-to-a-remote/>`_ the branch to your GitHub fork.
4. Create a `Pull Request <https://github.com/Radiomics/pyradiomics/pulls>`_.
This corresponds to the *Fork & Pull Model* mentioned in the `GitHub flow <https://guides.github.com/introduction/flow/index.html>`_
guides.
If you have push access to pyradiomics repository, you could simply push your branch
into the main repository and create a `Pull Request <https://github.com/Radiomics/pyradiomics/pulls>`_. This corresponds to the
*Shared Repository Model* and will facilitate other developers to checkout your
topic without having to `configure a remote <https://help.github.com/articles/configuring-a-remote-for-a-fork/>`_.
It will also simplify the workflow when you are *co-developing* a branch.
When submitting a PR, make sure to add a ``cc: @Radiomics/developers`` comment to notify pyradiomics
developers of your awesome contributions. Based on the
comments posted by the reviewers, you may have to revisit your patches.
How to integrate a PR ?
#######################
Getting your contributions integrated is relatively straightforward, here
is the checklist:
* Your changes include an update of the documentation if necessary
* Documentation on modules, classes and functions is contained in the respective docstrings
* More global documentation is contained in the ``docs`` folder.
* New modules need to be added to the auto-generated documentation. See
`here <http://pyradiomics.readthedocs.io/en/latest/developers.html#documentation>`_ for more
information on adding new modules to the documentation.
* Your changes are added in the `changelog <https://github.com/Radiomics/pyradiomics/tree/master/CHANGES.rst>`_ in the *Next Release* section.
* All tests pass
* Consensus is reached. This usually means that at least one reviewer reviewed and approved your
changes or added a ``LGTM`` comment, which is an acronym for *Looks Good to Me*.
Next, there are two scenarios:
* You do NOT have push access: A pyradiomics core developer will integrate your PR.
* You have push access: Simply click on the "Merge pull request" button.
Then, click on the "Delete branch" button that appears afterward.
Automatic testing of pull requests
##################################
Every pull request is tested automatically using CircleCI, TravisCI and AppVeyor each time you push
a commit to it. The Github UI will restrict users from merging pull requests until
the builds have returned with a successful result indicating that all tests have
passed and there were no problems detected by the linter. These tests include the following
* flake8 to check adherence to the code style. See ``.flake8`` and ``.editorconfig`` for styles,
exceptions to the PEP8 style, etc.
* If a feature class has a function ``_calculateCMatrix()``, identifying it as a C enhanced class,
output from the C extension is compared to the output from full python calculation. A absolute
difference of 1e-3 is allowed to account for machine precision errors.
* All implemented features and feature classes have docstrings at the class level and feature
definition level.
* A baseline is available for all features extracted from the 5 included test cases and
calculated features match this baseline to within 3% (allowing for machine precision errors)
.. _radiomics-submit-parameter-file-label:
---------------------------
Submitting a parameter file
---------------------------
Different inputs into PyRadiomics require different settings. We encourage users to share their parameter file to help
others extract features using the best settings for their use case.
How to submit your parameter file?
##################################
Parameter files are stored in the repository under ``examples/exampleSettings``. If you wish to submit your parameters
to the community, you can add your file here via a pull request (see above for details on making PRs).
To help you along, here is a small checklist:
* The filename should at least contain the modality (e.g. "MR") for which it is intended, and optionally the body part
(e.g. "prostate").
* Ensure the file has the correct extension (either ".yml" or ".yaml")
* Using comments in the parameter file, briefly explain your use case.
After you've opened a PR to submit your parameter file, it will be checked for validity by the automatic testing. You
don't have to specify your file anywhere, as parameter files are detected automatically in the ``exampleSettings``
folder. If you want, you can also check your file manually using ``bin/testParams.py``.
# Build Pyradiomics inside the Jupyter Datascience Notebook
FROM jupyter/datascience-notebook
MAINTAINER Radiomics Project (http://github.com/radiomics)
# Build information
ARG BUILD_DATE
ARG GIT_REF
LABEL org.label-schema.build-data=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/radiomics/pyradiomics.git" \
org.label-schema.vcs-ref=$GIT_REF \
org.label-schema.schema-version="1.0.0-rc1"
USER root
ADD . /root/pyradiomics
# Jupyter datascience notebook does not support python 2 anymore, install it manually.
# "source activate python2 || (...)" first checks if the python 2 environment exists,
# and only installs if the environment does not exist
# See also https://github.com/jupyter/docker-stacks/issues/432
# Next, also install python 2 kernel globally, so it can be found from the root
RUN /bin/bash -c "source activate python2 \
|| (conda create -n python2 python=2 ipykernel \
&& pip install kernda --no-cache \
&& $CONDA_DIR/envs/python2/bin/python -m ipykernel install \
&& kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json \
&& pip uninstall kernda -y)"
# Install in Python 3
RUN /bin/bash -c "source activate root \
&& cd /root/pyradiomics \
&& python -m pip install --no-cache-dir -r requirements.txt \
&& python setup.py install"
# Python 2
RUN /bin/bash -c "source activate python2 \
&& cd /root/pyradiomics \
&& python -m pip install --no-cache-dir -r requirements.txt \
&& python setup.py install"
# Install sample data and notebooks
ADD data/ /home/jovyan/work/data/
ADD notebooks/RadiomicsExample.ipynb /home/jovyan/work/notebooks/
ADD notebooks/FeatureVisualization.ipynb /home/jovyan/work/notebooks/
ADD notebooks/FeatureVisualizationWithClustering.ipynb /home/jovyan/work/notebooks/
ADD notebooks/FilteringEffects.ipynb /home/jovyan/work/notebooks/
ADD notebooks/helloRadiomics.ipynb /home/jovyan/work/notebooks/
ADD notebooks/helloFeatureClass.ipynb /home/jovyan/work/notebooks/
ADD notebooks/PyRadiomicsExample.ipynb /home/jovyan/work/notebooks/
ADD examples/exampleSettings/Params.yaml /home/jovyan/work/examples/exampleSettings/
# Make a global directory and link it to the work directory
RUN mkdir /data
RUN ln -s /data /home/jovyan/work/data
RUN chown -R jovyan:users /home/jovyan/work
# Trust the notebooks that we've installed
USER jovyan
RUN jupyter trust /home/jovyan/work/notebooks/*.ipynb
# Run the notebooks
RUN jupyter nbconvert --ExecutePreprocessor.kernel_name=python2 --ExecutePreprocessor.timeout=-1 --to notebook --execute /home/jovyan/work/notebooks/helloRadiomics.ipynb /home/jovyan/work/notebooks/helloFeatureClass.ipynb /home/jovyan/work/notebooks/PyRadiomicsExample.ipynb
RUN jupyter nbconvert --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.timeout=-1 --to notebook --execute /home/jovyan/work/notebooks/helloRadiomics.ipynb /home/jovyan/work/notebooks/helloFeatureClass.ipynb /home/jovyan/work/notebooks/PyRadiomicsExample.ipynb
# The user's data will show up as /data
VOLUME /data
Copyright 2017 Harvard Medical School
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include CONTRIBUTING.rst
include LICENSE.txt
include README.md
include requirements.txt
include requirements-dev.txt
include requirements-setup.txt
include versioneer.py
recursive-include radiomics *
recursive-include data/baseline *
recursive-include data *_image.nrrd
recursive-include data *_label.nrrd
include data/README.md
recursive-include examples/exampleSettings *.yaml
recursive-include examples batch*.py
recursive-include examples hello*.py
include examples/testCases.csv
recursive-include tests *
recursive-include bin *.py
recursive-exclude * __pycache__
recursive-exclude * *.py[cod]
recursive-exclude * nosetests.xml
# pyradiomics v2.0.0
## Build Status
| Linux | macOS | Windows |
|--------------------------------|-------------------------------|-------------------------------|
| [![][circleci]][circleci-lnk] | [![][travisci]][travisci-lnk] | [![][appveyor]][appveyor-lnk] |
[appveyor]: https://ci.appveyor.com/api/projects/status/tw69xbbeyluk7fl7/branch/master?svg=true
[appveyor-lnk]: https://ci.appveyor.com/project/Radiomics/pyradiomics/branch/master
[circleci]: https://circleci.com/gh/Radiomics/pyradiomics.svg?style=svg&circle-token=a4748cf0de5fad2c12bc93a485282378551c3584
[circleci-lnk]: https://circleci.com/gh/Radiomics/pyradiomics
[travisci]: https://travis-ci.org/Radiomics/pyradiomics.svg?branch=master
[travisci-lnk]: https://travis-ci.org/Radiomics/pyradiomics
## Radiomics feature extraction in Python
This is an open-source python package for the extraction of Radiomics features from medical imaging.
With this package we aim to establish a reference standard for Radiomic Analysis, and provide a tested and maintained
open-source platform for easy and reproducible Radiomic Feature extraction. By doing so, we hope to increase awareness
of radiomic capabilities and expand the community.
The platform supports both the feature extraction in 2D and 3D. **Not intended for clinical use.**
**If you publish any work which uses this package, please cite the following publication:**
*van Griethuysen, J. J. M., Fedorov, A., Parmar, C., Hosny, A., Aucoin, N., Narayan, V., Beets-Tan, R. G. H.,
Fillon-Robin, J. C., Pieper, S., Aerts, H. J. W. L. (2017). Computational Radiomics System to Decode the Radiographic
Phenotype. Cancer Research, 77(21), e104–e107. https://doi.org/10.1158/0008-5472.CAN-17-0339*
### Join the Community!
Join the PyRadiomics community on google groups [here](https://groups.google.com/forum/#!forum/pyradiomics).
### Feature Classes
Currently supports the following feature classes: