Introduction¶
This python package provides methods and utilities to explore the PnP algorithm and MACE framework in the context of image reconstruction problems, along with some simple demos. The ideas leading to this package are outlined in
with more detail in the papers in the references.
Documentation on this package is available at https://pnp-mace.readthedocs.io, which includes installation instructions.
Demo files are available as python scripts and Jupyter notebooks. See the Demos page for more details.
Features¶
Implementation of basic Plug-and-Play method as described in
Implementation of the solution of MACE equations using Mann iterations as in
This is free software with a BSD license.
Indices and tables¶
Introduction¶
This python package provides methods and utilities to explore the PnP algorithm and MACE framework in the context of image reconstruction problems, along with some simple demos. The ideas leading to this package are outlined in
with more detail in the papers in the references.
Documentation on this package is available at https://pnp-mace.readthedocs.io, which includes installation instructions.
Demo files are available as python scripts and Jupyter notebooks. See the Demos page for more details.
Features¶
Implementation of basic Plug-and-Play method as described in
Implementation of the solution of MACE equations using Mann iterations as in
This is free software with a BSD license.
Installation¶
Stable release¶
The pnp_mace package requires python 3.6 or higher, and it’s recommended that you install in a virtual environment. If those conditions are satisfied, you can install pnp_mace by running this command in your activated virtual environment in your terminal:
pip install pnp_mace
Then move on to Running the Demos
Detailed installation instructions¶
If you don’t know which version of python you have or whether you have a virtual environment or if you have pip, you can follow these instructions:
Create a directory, say
pnp_mace_code
and change into this directory (or change to thePnP-MACE/demo
directory if you’ve downloaded from github).In a terminal, enter
python --version
. If this returns 2.X.Y, then use
python3 -m venv new_venv
source new_venv/bin/activate
Otherwise use
python -m venv new_venv
source new_venv/bin/activate
After this step, python
will be mapped to a version of python and supporting code that are appropriate for the pnp_mace package. Even if your original python mapped to version 2, now when you enter python --version
you should get 3.X.Y.
In the same terminal window, enter
pip install pnp_mace
Now the pnp_mace package is available in python using import pnp_mace
or
import pnp_mace as pnpm
When you are finished using pnp_mace, enter deactivate
to exit this virtual
environment.
The next time you want to use pnp_mace, change to the directory you created
above and enter source new_venv/bin/activate
. You do not need to use pip a second time.
Running the demos¶
Follow the installation instructions above and activate the virtual environment.
If you already have the
PnP-MACE/demo
directory fromhttps://github.com/gbuzzard/PnP-MACE
then change into that directory (you can get this by downloading the tarball and uncompress). Otherwise change into the directory you created during installation and download all the files athttps://github.com/gbuzzard/PnP-MACE/tree/master/demo
.In your terminal window, enter
pip install -r requirements_demo.txt
In your terminal window, enter
python ct.py
. You should get some text output regarding the operation of the demo, followed shortly by some images demonstrating the reconstruction. Repeat for the remaining demos.
From sources¶
The sources for PnP-MACE can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone https://github.com/gbuzzard/PnP-MACE
(see https://git-scm.com/downloads to install git) or download the tarball:
$ curl -OJL https://github.com/gbuzzard/PnP-MACE/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Demos¶
The demos folder in the github repo (https://github.com/gbuzzard/PnP-MACE) includes simple demos illustrating an elementary approach to superresolution and a CT example with high-dynamic-range images.
These demos are not meant to be state-of-the-art either in terms of reconstruction quality or run-time performance. Rather, they are meant to be an invitation to explore these algorithms, to try alternative priors, to understand the effect of parameters on the reconstruction, and to adapt the code to other applications.
The demo folder under https://github.com/gbuzzard/PnP-MACE includes both .py files to be run with python and Jupyter notebooks that can be opened in Google colaboratory for experimentation online.
See the instructions under Running the demos in the Installation instructions to run the demos.
Select the demo names below to see more detailed descriptions.
This demo illustrates a 2D tomography example using a high-dynamic range phantom. |
|
This demo illustrates the solution of a MACE problem using Mann iteration and the stacked operators F and G. |
|
Overview: A simple demo to demonstrate the solution of a PnP problem The forward model is a subsampling operation, and the prior agent is the bm3d denoiser. |
|
API Documentation¶
All of the classes and methods are available from the top level import of pnp_mace. That is, if you include import pnp_mace as pnpm
in a file, then you can use pnpm to access the methods in pnp_mace.utils
(for instance pnp_mace.utils.load_img
can be accessed as pnpm.load_img
.) Likewise for the methods and classes in other submodules.
Plug and Play ADMM alorithm. |
|
EquilibriumProblem class and solution methods. |
|
Generic agent. |
|
Forward agents. |
|
Prior agents. |
|
Utility functions. |
|
References¶
- 1
Gregery T. Buzzard, Stanley H. Chan, Suhas Sreehari, and Charles A. Bouman. Plug-and-play unplugged: optimization-free reconstruction using consensus equilibrium. SIAM Journal on Imaging Sciences, 11(3):2001–2020, 2018. doi:10.1137/17M1122451.
- 2
Venkatesh Sridhar, Xiao Wang, Gregery T. Buzzard, and Charles A. Bouman. Distributed iterative CT reconstruction using multi-agent consensus equilibrium. IEEE Transactions on Computational Imaging, 6:1153–1166, 2020. doi:10.1109/tci.2020.3008782.
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/gbuzzard/PnP-MACE/issues.
If you are reporting a bug, please include:
Your operating system name and version.
Any details about your local setup that might be helpful in troubleshooting.
Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
PnP-MACE could always use more documentation, whether as part of the official PnP-MACE docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/gbuzzard/PnP-MACE/issues.
If you are proposing a feature:
Explain in detail how it would work.
Keep the scope as narrow as possible, to make it easier to implement.
Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up pnp_mace for local development.
Fork the pnp_mace repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/pnp_mace.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv pnp_mace $ cd pnp_mace/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 pnp_mace tests $ python setup.py test or pytest $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
The pull request should include tests.
If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.com/gbuzzard/PnP-MACE/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
Gregery T. Buzzard <buzzard@purdue.edu>
Contributors¶
Brendt Wohlberg <brendt@ieee.org>
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.