Metadata-Version: 2.4
Name: pysimplemask
Version: 0.3.2
Summary: A GUI for creating mask and q-partition maps for scattering patterns in preparation for SAXS/WAXS/XPCS data reduction
Author-email: Miaoqi Chu <mqichu@anl.gov>
Maintainer-email: Miaoqi Chu <mqichu@anl.gov>
License: Copyright (c) 2026, UChicago Argonne, LLC. All rights reserved.
        
        Copyright 2026. UChicago Argonne, LLC. This software was produced
        under U.S. Government contract DE-AC02-06CH11357 for Argonne National
        Laboratory (ANL), which is operated by UChicago Argonne, LLC for the
        U.S. Department of Energy. The U.S. Government has rights to use,
        reproduce, and distribute this software.  NEITHER THE GOVERNMENT NOR
        UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
        ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.  If software is
        modified to produce derivative works, such modified software should
        be clearly marked, so as not to confuse it with the version available
        from ANL.
        
        Additionally, redistribution and use in source and binary forms, with
        or without modification, are permitted provided that the following
        conditions are met:
        
            * Redistributions of source code must retain the above copyright
              notice, this list of conditions and the following disclaimer.
        
            * 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.
        
            * Neither the name of UChicago Argonne, LLC, Argonne National
              Laboratory, ANL, the U.S. Government, 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 UChicago Argonne, LLC 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 UChicago
        Argonne, LLC 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.
Project-URL: bugs, https://github.com/AdvancedPhotonSource/pySimpleMask/issues
Project-URL: changelog, https://github.com/AdvancedPhotonSource/pySimpleMask/blob/master/changelog.md
Project-URL: homepage, https://github.com/AdvancedPhotonSource/pySimpleMask
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: h5py
Requires-Dist: hdf5plugin
Requires-Dist: scikit-image
Requires-Dist: matplotlib
Requires-Dist: pyqtgraph
Requires-Dist: PySide6==6.8.3
Requires-Dist: astropy
Requires-Dist: imagecodecs
Requires-Dist: tifffile
Provides-Extra: dev
Requires-Dist: coverage; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# pySimpleMask

[![PyPI version](https://img.shields.io/pypi/v/pysimplemask.svg)](https://pypi.python.org/pypi/pysimplemask)

**pySimpleMask** is a graphical user interface (GUI) tool designed for creating masks and Q-partition maps for scattering patterns, specifically facilitating SAXS, WAXS, and XPCS data reduction.

## Features

*   **Versatile Data Support**: Load scattering data from various formats including HDF5, IMM, TIFF, and binary files.
*   **Interactive Masking**:
    *   **Drawing Tools**: Create masks using polygons, circles, rectangles, and lines.
    *   **Thresholding**: Automatically mask pixels based on intensity limits (low/high).
    *   **Blemish Maps**: Apply pre-existing blemish (bad pixel) files.
    *   **Outlier Removal**: Automatically detect and mask outliers using SAXS 1D azimuthal average comparisons.
    *   **Manual Selection**: Click to mask specific pixels or regions.
*   **Partition Generation**:
    *   Compute Q-Phi partitions (Dynamic/Static).
    *   Generate X-Y partitions.
    *   Support for custom mapping modes.
*   **Visualization**: Real-time visualization of scattering patterns, masks, and SAXS 1D profiles.
*   **Output**:
    *   Save generated masks as TIFF files.
    *   Save full partition maps and metadata in Nexus-compatible HDF5/XPCS formats.

## Installation

### From PyPI
```bash
pip install pysimplemask
```

### From Source
1. Clone the repository:
   ```bash
   git clone https://github.com/AdvancedPhotonSource/pySimpleMask.git
   cd pysimplemask
   ```
2. Install the package:
   ```bash
   pip install .
   ```

## Usage

To launch the GUI, simply run the following command in your terminal:

```bash
pysimplemask
```

You can also specify a starting path for data loading:

```bash
pysimplemask --path /path/to/your/data
```

## Workflow

1.  **Load Data**: Click "Select Raw" or "Load" to open your scattering data file.
2.  **Define Mask**:
    *   Use the "Mask" tabs to apply different masking techniques (Draw, Threshold, Blemish, etc.).
    *   Combine multiple masking methods as needed.
    *   Use "Evaluate" to preview the mask and "Apply" to finalize it.
3.  **Compute Partition**:
    *   Go to the "Partition" tab.
    *   Select the desired mode (e.g., Q-Phi) and configure parameters (number of bins, symmetry).
    *   Click "Compute Partition" to generate the maps.
4.  **Save Results**:
    *   Click "Save" to export the mask (TIFF) or the full partition data (HDF5).

## Credits

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.

*   **Author**: Miaoqi Chu (mqichu@anl.gov)
*   **License**: BSD 3-Clause license
