Metadata-Version: 2.4
Name: selfphish
Version: 0.1.1
Summary: A deep neural network data reconstruction platform for phase retreival
Project-URL: homepage, https://github.com/XYangXRay/selfphish
Project-URL: repository, https://github.com/XYangXRay/selfphish
Project-URL: documentation, https://github.com/XYangXRay/selfphish
Author-email: Xiaogang Yang <xiaogang.yang@outlook.com>
License: BSD 3-Clause License
        
        Copyright (c) 2022, Brookhaven National Lab
        All rights reserved.
        
        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.
License-File: AUTHORS.rst
License-File: LICENSE
Keywords: Data reconstruction,GAN,Phase retrieval
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: ipython>=8.36.0
Requires-Dist: matplotlib>=3.7.3
Requires-Dist: numpy>=1.25.0
Requires-Dist: scikit-image>=0.21.1
Requires-Dist: tensorflow[and-cuda]>=2.16.0
Requires-Dist: tifffile>=2024.08.01
Requires-Dist: tqdm>=4.66.1
Provides-Extra: pytorch
Requires-Dist: quantities; extra == 'pytorch'
Requires-Dist: torch>=2.7.0; extra == 'pytorch'
Requires-Dist: torchvision; extra == 'pytorch'
Description-Content-Type: text/markdown


# SELFPHISH: Self-supervised, Physics-Informed Generative Networks for Phase Retrieval

![PyPI](https://img.shields.io/pypi/v/selfphish)
![License](https://img.shields.io/github/license/XYangXRay/selfphish)
![Python](https://img.shields.io/pypi/pyversions/selfphish)

## Overview

**SELFPHISH** is a flexible data reconstruction framework that harnesses self-supervised, physics-informed generative networks. Unlike traditional methods that rely on complex algorithms, SELFPHISH leverages deep generative models guided by physical constraints to advance the phase retrieval process.

Originally designed for complex phase retrieval in tomography and holography, SELFPHISH is highly adaptable and can incorporate user-defined forward models for a wide range of advanced data reconstruction challenges.

## Features

- **Self-supervised, Physics-Informed Networks:** Deep generative networks that are both self-supervised and physics-guided for state-of-the-art reconstruction.
- **Specialized for Phase Retrieval:** Optimized for phase retrieval and tomography tasks, ensuring precise and reliable reconstructions.
- **Modular Design:** Easily integrate custom forward models for diverse reconstruction challenges.
- **Efficient and Scalable:** Handles large datasets efficiently without compromising accuracy.

![The flowchart of Selfphish](docs/source/figures/algorithm_flowchart.png)
---


## Installation

The following steps will help you set up the `selfphish` package in a Conda environment.


### For General Users

1. **Create & Activate a Conda Environment**

   ```bash
   conda create --name selfphish python=3.11
   conda activate selfphish
   ```

2. **Install SELFPHISH from PyPI**

   - For the default TensorFlow backend:
     ```bash
     pip install selfphish
     ```
   - For the PyTorch backend:
     ```bash
     pip install "selfphish[pytorch]"
     ```

---

### For Developers

If you are contributing to SELFPHISH development, follow these steps:

1. **Create & Activate a Conda Environment**
   ```bash
   conda create --name selfphish python=3.11
   conda activate selfphish
   ```

2. **Clone the SELFPHISH Repository**
   ```bash
   git clone https://github.com/XYangXRay/selfphish.git
   cd selfphish
   ```

3. **Install Required Packages in Editable Mode**
   ```bash
   python3 -m pip install -e .
   ```

---

## Additional Notes

- **Choosing a Backend:**
  - *TensorFlow* is recommended for production and TFX integration.
  - *PyTorch* is popular for research and dynamic computation graphs.
- **GPU Support:**
  - SELFPHISH is designed for GPU acceleration. Install the GPU versions of TensorFlow or PyTorch as needed. See their official documentation for details.

---


## Examples

SELFPHISH includes ready-to-run examples for phase retrieval and tomography:

1. **Holography phase retrieval:**
   - [Phase Retrieval Example](https://github.com/XYangXRay/selfphish/blob/main/examples/holography_tf.ipynb)
2. **X-ray tomography:**
   - [Tomography Example](https://github.com/XYangXRay/selfphish/blob/main/examples/tomography_tf.ipynb)

---

## Citation

If you use SELFPHISH in your research or projects, please cite:

J. Synchrotron Rad. (2020). 27, 486-493.  
Available at: [https://doi.org/10.1107/S1600577520000831](https://doi.org/10.1107/S1600577520000831)