ptyrad


Nameptyrad JSON
Version 0.1.0b9 PyPI version JSON
download
home_pageNone
SummaryPtyRAD: Ptychographic Reconstruction with Automatic Differentiation
upload_time2025-07-10 06:35:06
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords ptychography
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PtyRAD: Ptychographic Reconstruction with Automatic Differentiation
![PyPI - Version](https://img.shields.io/pypi/v/ptyrad)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/version.svg)](https://anaconda.org/conda-forge/ptyrad)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/ptyrad)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/downloads.svg)](https://anaconda.org/conda-forge/ptyrad)
[![arXiv](https://img.shields.io/badge/arXiv-2505.07814-b31b1b.svg)](https://arxiv.org/abs/2505.07814)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15392805.svg)](https://doi.org/10.5281/zenodo.15392805)

[**Docs**](https://ptyrad.readthedocs.io/en/latest/index.html)
| [**Install Guide**](https://ptyrad.readthedocs.io/en/latest/installation.html)
| [**Quickstart**](https://ptyrad.readthedocs.io/en/latest/quickstart.html)
| [**Paper**](https://arxiv.org/abs/2505.07814)
| [**Youtube**](https://www.youtube.com/@ptyrad_official)

*PtyRAD* performs ptychographic reconstruction using an [automatic differention](https://en.wikipedia.org/wiki/Automatic_differentiation) (AD) framework powered by [*PyTorch*](https://pytorch.org/), which enables flexible and efficient implementation of gradient descent optimization. See our [arXiv paper](https://arxiv.org/abs/2505.07814) and the [Zenodo record](https://doi.org/10.5281/zenodo.15273176) for more information and demo datasets.

## Features
- Gradient descent algorithms (Adam, SGD, LBFGS, etc.)
- Mixed-state probe and object
- Position correction
- Position-dependent object tilt correction
- Interoperability with *PtychoShelves (fold_slice)* and *py4DSTEM*
- Streamlined preprocessing of cropping, padding, resampling, adding noises, and many more
- Hyperparameter tuning
- Multi-GPU reconstructions

## Recommended Tools
We recommend using [*Miniforge*](https://github.com/conda-forge/miniforge) for Python environment management, and  
[*Visual Studio Code*](https://code.visualstudio.com/Download) for code editing and execution.

## Major dependencies

* Python 3.10 or above
* PyTorch 2.0 or above
* While *PtyRAD* can run on CPU, GPU is strongly suggested for high-speed ptychographic reconstructions. 
    - *PtyRAD* supports both NVIDIA GPUs with CUDA and Apple Silicon (MPS)
* *PtyRAD* was tested on Windows, MacOS, and Linux

## Installation



We recommend installing *PtyRAD* using `pip` inside a fresh conda environment.

First, create and activate a new conda environment **(ptyrad)** with Python > 3.10:
```sh
conda create -n ptyrad python=3.12
conda activate ptyrad
```
> 💡 **Note:** After activating the environment, your terminal prompt should show **(ptyrad)** at the beginning, indicating that the environment is active.

Then install *PtyRAD* using:
```sh
pip install ptyrad
```

*PtyRAD* can also be installed via `conda`. For detailed instructions on installing *PtyRAD* on different machines or pinning specific CUDA versions, see [the installation guide](https://ptyrad.readthedocs.io/en/latest/installation.html).



### How do I check if my installed PtyRAD has the GPU support?
CUDA version, GPU support, and PyTorch build across platforms can be extremely confusing, so *PtyRAD* provides handy CLI tools to help check these information for you!

Once you activated `(ptyrad)` environment and installed *PtyRAD* via `pip insall ptyrad`, you'll have access to the following command:

```bash
# You can run this command anywhere from your terminal, as long as `ptyrad` is installed in the environment
ptyrad check-gpu
```

This command will print out relevant information of your CUDA information if available.

## Get Started with the Demo

> 💡 **Note:** Download the demo datasets and scripts from our [Box folder](https://cornell.box.com/s/n5balzf88jixescp9l15ojx7di4xn1uo), which contains `demo/` and other tutorial slides and videos.

Before running the demo, please check the following:
1. Demo datasets are downloaded and placed to the correct location under `demo/data/`
2. `(ptyrad)` environment is created and activated (in VS Code it's the "Select Kernel")
3. *PtyRAD* is installed in the `(ptyrad)` environment
   
Now you're ready to run a quick demo using one of two interfaces:

- **Interactive Jupyter interface (Recommended)**
 
    Use `demo/scripts/run_ptyrad_quick_example.ipynb` to quickly reconstruct the demo dataset in a Jupyter notebook

- **Command-line interface** (like your *Miniforge Prompt* terminal)
    ```bash
    # Here we assume working directory is set at `demo/`
    ptyrad run --params_path "params/tBL_WSe2_reconstruct.yml"
    ```

## Documentation
*PtyRAD* documentation is available at https://ptyrad.readthedocs.io/en/latest/index.html.

## Author

Chia-Hao Lee (cl2696@cornell.edu)

Developed at the Muller Group, Cornell University.

## Acknowledgments

Besides great support from the entire Muller group, this package gets inspiration from lots of community efforts, and specifically from the following packages. Some of the functions in *PtyRAD* are directly translated or modified from these packages as noted in their docstrings/comments to give explicit acknowledgment.
* [PtychoShelves](https://journals.iucr.org/j/issues/2020/02/00/zy5001/index.html)
* [fold_slice](https://github.com/yijiang1/fold_slice)
* [py4dstem](https://github.com/py4dstem/py4DSTEM)
* [adorym](https://github.com/mdw771/adorym)
* [SciComPty](https://www.mdpi.com/2410-3896/6/4/36)

## Other resources

* [ptycho-packages](https://github.com/chiahao3/ptycho-packages) lists many available ptychography packages
* [Cornell Box folder](https://cornell.box.com/s/n5balzf88jixescp9l15ojx7di4xn1uo) compiled by myself that keeps demo data, tutorial recordings, and slides for PtyRAD
* [Argonne Box folder](https://anl.box.com/s/f7lk410lf62rnia70fztd5l7n567btyv) compiled by Dr. Yi Jiang that holds tutorial slides of `fold_slice`
* [Blog post](https://chiahao-blog.super.site/posts/theory-algorithm-and-code-structure-of-ptychoshelves) written by myself that details the algorithms and code structure of `PtychoShelves` / `fold_slice`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ptyrad",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "Ptychography",
    "author": null,
    "author_email": "Chia-Hao Lee <cl2696@cornell.edu>",
    "download_url": "https://files.pythonhosted.org/packages/1d/ef/189f64e711bd1ce30413e54d15855989a7d47973418b52a1b65465b97e79/ptyrad-0.1.0b9.tar.gz",
    "platform": null,
    "description": "# PtyRAD: Ptychographic Reconstruction with Automatic Differentiation\n![PyPI - Version](https://img.shields.io/pypi/v/ptyrad)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/version.svg)](https://anaconda.org/conda-forge/ptyrad)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/ptyrad)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/ptyrad/badges/downloads.svg)](https://anaconda.org/conda-forge/ptyrad)\n[![arXiv](https://img.shields.io/badge/arXiv-2505.07814-b31b1b.svg)](https://arxiv.org/abs/2505.07814)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15392805.svg)](https://doi.org/10.5281/zenodo.15392805)\n\n[**Docs**](https://ptyrad.readthedocs.io/en/latest/index.html)\n| [**Install Guide**](https://ptyrad.readthedocs.io/en/latest/installation.html)\n| [**Quickstart**](https://ptyrad.readthedocs.io/en/latest/quickstart.html)\n| [**Paper**](https://arxiv.org/abs/2505.07814)\n| [**Youtube**](https://www.youtube.com/@ptyrad_official)\n\n*PtyRAD* performs ptychographic reconstruction using an [automatic differention](https://en.wikipedia.org/wiki/Automatic_differentiation) (AD) framework powered by [*PyTorch*](https://pytorch.org/), which enables flexible and efficient implementation of gradient descent optimization. See our [arXiv paper](https://arxiv.org/abs/2505.07814) and the [Zenodo record](https://doi.org/10.5281/zenodo.15273176) for more information and demo datasets.\n\n## Features\n- Gradient descent algorithms (Adam, SGD, LBFGS, etc.)\n- Mixed-state probe and object\n- Position correction\n- Position-dependent object tilt correction\n- Interoperability with *PtychoShelves (fold_slice)* and *py4DSTEM*\n- Streamlined preprocessing of cropping, padding, resampling, adding noises, and many more\n- Hyperparameter tuning\n- Multi-GPU reconstructions\n\n## Recommended Tools\nWe recommend using [*Miniforge*](https://github.com/conda-forge/miniforge) for Python environment management, and  \n[*Visual Studio Code*](https://code.visualstudio.com/Download) for code editing and execution.\n\n## Major dependencies\n\n* Python 3.10 or above\n* PyTorch 2.0 or above\n* While *PtyRAD* can run on CPU, GPU is strongly suggested for high-speed ptychographic reconstructions. \n    - *PtyRAD* supports both NVIDIA GPUs with CUDA and Apple Silicon (MPS)\n* *PtyRAD* was tested on Windows, MacOS, and Linux\n\n## Installation\n\n\n\nWe recommend installing *PtyRAD* using `pip` inside a fresh conda environment.\n\nFirst, create and activate a new conda environment **(ptyrad)** with Python > 3.10:\n```sh\nconda create -n ptyrad python=3.12\nconda activate ptyrad\n```\n> \ud83d\udca1 **Note:** After activating the environment, your terminal prompt should show **(ptyrad)** at the beginning, indicating that the environment is active.\n\nThen install *PtyRAD* using:\n```sh\npip install ptyrad\n```\n\n*PtyRAD* can also be installed via `conda`. For detailed instructions on installing *PtyRAD* on different machines or pinning specific CUDA versions, see [the installation guide](https://ptyrad.readthedocs.io/en/latest/installation.html).\n\n\n\n### How do I check if my installed PtyRAD has the GPU support?\nCUDA version, GPU support, and PyTorch build across platforms can be extremely confusing, so *PtyRAD* provides handy CLI tools to help check these information for you!\n\nOnce you activated `(ptyrad)` environment and installed *PtyRAD* via `pip insall ptyrad`, you'll have access to the following command:\n\n```bash\n# You can run this command anywhere from your terminal, as long as `ptyrad` is installed in the environment\nptyrad check-gpu\n```\n\nThis command will print out relevant information of your CUDA information if available.\n\n## Get Started with the Demo\n\n> \ud83d\udca1 **Note:** Download the demo datasets and scripts from our [Box folder](https://cornell.box.com/s/n5balzf88jixescp9l15ojx7di4xn1uo), which contains `demo/` and other tutorial slides and videos.\n\nBefore running the demo, please check the following:\n1. Demo datasets are downloaded and placed to the correct location under `demo/data/`\n2. `(ptyrad)` environment is created and activated (in VS Code it's the \"Select Kernel\")\n3. *PtyRAD* is installed in the `(ptyrad)` environment\n   \nNow you're ready to run a quick demo using one of two interfaces:\n\n- **Interactive Jupyter interface (Recommended)**\n \n    Use `demo/scripts/run_ptyrad_quick_example.ipynb` to quickly reconstruct the demo dataset in a Jupyter notebook\n\n- **Command-line interface** (like your *Miniforge Prompt* terminal)\n    ```bash\n    # Here we assume working directory is set at `demo/`\n    ptyrad run --params_path \"params/tBL_WSe2_reconstruct.yml\"\n    ```\n\n## Documentation\n*PtyRAD* documentation is available at https://ptyrad.readthedocs.io/en/latest/index.html.\n\n## Author\n\nChia-Hao Lee (cl2696@cornell.edu)\n\nDeveloped at the Muller Group, Cornell University.\n\n## Acknowledgments\n\nBesides great support from the entire Muller group, this package gets inspiration from lots of community efforts, and specifically from the following packages. Some of the functions in *PtyRAD* are directly translated or modified from these packages as noted in their docstrings/comments to give explicit acknowledgment.\n* [PtychoShelves](https://journals.iucr.org/j/issues/2020/02/00/zy5001/index.html)\n* [fold_slice](https://github.com/yijiang1/fold_slice)\n* [py4dstem](https://github.com/py4dstem/py4DSTEM)\n* [adorym](https://github.com/mdw771/adorym)\n* [SciComPty](https://www.mdpi.com/2410-3896/6/4/36)\n\n## Other resources\n\n* [ptycho-packages](https://github.com/chiahao3/ptycho-packages) lists many available ptychography packages\n* [Cornell Box folder](https://cornell.box.com/s/n5balzf88jixescp9l15ojx7di4xn1uo) compiled by myself that keeps demo data, tutorial recordings, and slides for PtyRAD\n* [Argonne Box folder](https://anl.box.com/s/f7lk410lf62rnia70fztd5l7n567btyv) compiled by Dr. Yi Jiang that holds tutorial slides of `fold_slice`\n* [Blog post](https://chiahao-blog.super.site/posts/theory-algorithm-and-code-structure-of-ptychoshelves) written by myself that details the algorithms and code structure of `PtychoShelves` / `fold_slice`\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "PtyRAD: Ptychographic Reconstruction with Automatic Differentiation",
    "version": "0.1.0b9",
    "project_urls": {
        "Changelog": "https://github.com/chiahao3/ptyrad/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/chiahao3/ptyrad",
        "Issues": "https://github.com/chiahao3/ptyrad/issues",
        "Repository": "https://github.com/chiahao3/ptyrad"
    },
    "split_keywords": [
        "ptychography"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bfd50b86325cf1a27076a65d54009ced502afc1d71e16670bf1e120d128b5f49",
                "md5": "06ece462195d230062cb6566f09c7932",
                "sha256": "83d024a5f52a5198251ff8a5549f3833c8f4fd4a8eb28866905f97a65cce9d4a"
            },
            "downloads": -1,
            "filename": "ptyrad-0.1.0b9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "06ece462195d230062cb6566f09c7932",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 150708,
            "upload_time": "2025-07-10T06:35:04",
            "upload_time_iso_8601": "2025-07-10T06:35:04.861188Z",
            "url": "https://files.pythonhosted.org/packages/bf/d5/0b86325cf1a27076a65d54009ced502afc1d71e16670bf1e120d128b5f49/ptyrad-0.1.0b9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1def189f64e711bd1ce30413e54d15855989a7d47973418b52a1b65465b97e79",
                "md5": "9f048e6758db4d450727e888a2136188",
                "sha256": "010964eeaa680a97dc5c83594dfb572cd9541765bfccaa3c7abf746132232894"
            },
            "downloads": -1,
            "filename": "ptyrad-0.1.0b9.tar.gz",
            "has_sig": false,
            "md5_digest": "9f048e6758db4d450727e888a2136188",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 141372,
            "upload_time": "2025-07-10T06:35:06",
            "upload_time_iso_8601": "2025-07-10T06:35:06.730521Z",
            "url": "https://files.pythonhosted.org/packages/1d/ef/189f64e711bd1ce30413e54d15855989a7d47973418b52a1b65465b97e79/ptyrad-0.1.0b9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 06:35:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chiahao3",
    "github_project": "ptyrad",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ptyrad"
}
        
Elapsed time: 0.78194s