Skip to content

Commit 40f2497

Browse files
authored
Merge pull request #25 from AdvancedPhotonSource/mc_dev
Mc dev
2 parents d5cb922 + 1cd04cc commit 40f2497

10 files changed

Lines changed: 246 additions & 68 deletions

File tree

.github/workflows/publish.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
pypi-publish:
10+
name: Upload release to PyPI
11+
runs-on: ubuntu-latest
12+
environment:
13+
name: pypi
14+
url: https://pypi.org/p/pysimplemask
15+
permissions:
16+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
17+
contents: read
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install build twine
31+
32+
- name: Build package
33+
run: |
34+
python -m build
35+
36+
- name: Publish package distributions to PyPI
37+
uses: pypa/gh-action-pypi-publish@release/v1

LICENSE

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
1-
MIT License
1+
Copyright (c) 2026, UChicago Argonne, LLC. All rights reserved.
22

3-
Copyright (c) 2024, Miaoqi Chu
3+
Copyright 2026. UChicago Argonne, LLC. This software was produced
4+
under U.S. Government contract DE-AC02-06CH11357 for Argonne National
5+
Laboratory (ANL), which is operated by UChicago Argonne, LLC for the
6+
U.S. Department of Energy. The U.S. Government has rights to use,
7+
reproduce, and distribute this software. NEITHER THE GOVERNMENT NOR
8+
UChicago Argonne, LLC MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
9+
ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE. If software is
10+
modified to produce derivative works, such modified software should
11+
be clearly marked, so as not to confuse it with the version available
12+
from ANL.
413

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
14+
Additionally, redistribution and use in source and binary forms, with
15+
or without modification, are permitted provided that the following
16+
conditions are met:
1117

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
18+
* Redistributions of source code must retain the above copyright
19+
notice, this list of conditions and the following disclaimer.
1420

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
* Redistributions in binary form must reproduce the above copyright
22+
notice, this list of conditions and the following disclaimer in
23+
the documentation and/or other materials provided with the
24+
distribution.
2225

26+
* Neither the name of UChicago Argonne, LLC, Argonne National
27+
Laboratory, ANL, the U.S. Government, nor the names of its
28+
contributors may be used to endorse or promote products derived
29+
from this software without specific prior written permission.
30+
31+
THIS SOFTWARE IS PROVIDED BY UChicago Argonne, LLC AND CONTRIBUTORS
32+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UChicago
35+
Argonne, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
36+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
37+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
41+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# pySimpleMask
2+
3+
[![PyPI version](https://img.shields.io/pypi/v/pysimplemask.svg)](https://pypi.python.org/pypi/pysimplemask)
4+
[![Build Status](https://img.shields.io/travis/AdvancedPhotonSource/pySimpleMask.svg)](https://travis-ci.com/AdvancedPhotonSource/pySimpleMask)
5+
[![Documentation Status](https://readthedocs.org/projects/pysimplemask/badge/?version=latest)](https://pysimplemask.readthedocs.io/en/latest/?version=latest)
6+
7+
**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.
8+
9+
## Features
10+
11+
* **Versatile Data Support**: Load scattering data from various formats including HDF5, IMM, TIFF, and binary files.
12+
* **Interactive Masking**:
13+
* **Drawing Tools**: Create masks using polygons, circles, rectangles, and lines.
14+
* **Thresholding**: Automatically mask pixels based on intensity limits (low/high).
15+
* **Blemish Maps**: Apply pre-existing blemish (bad pixel) files.
16+
* **Outlier Removal**: Automatically detect and mask outliers using SAXS 1D azimuthal average comparisons.
17+
* **Manual Selection**: Click to mask specific pixels or regions.
18+
* **Partition Generation**:
19+
* Compute Q-Phi partitions (Dynamic/Static).
20+
* Generate X-Y partitions.
21+
* Support for custom mapping modes.
22+
* **Visualization**: Real-time visualization of scattering patterns, masks, and SAXS 1D profiles.
23+
* **Output**:
24+
* Save generated masks as TIFF files.
25+
* Save full partition maps and metadata in Nexus-compatible HDF5/XPCS formats.
26+
27+
## Installation
28+
29+
### From PyPI
30+
```bash
31+
pip install pysimplemask
32+
```
33+
34+
### From Source
35+
1. Clone the repository:
36+
```bash
37+
git clone https://github.com/AdvancedPhotonSource/pySimpleMask.git
38+
cd pysimplemask
39+
```
40+
2. Install the package:
41+
```bash
42+
pip install .
43+
```
44+
45+
## Usage
46+
47+
To launch the GUI, simply run the following command in your terminal:
48+
49+
```bash
50+
pysimplemask
51+
```
52+
53+
You can also specify a starting path for data loading:
54+
55+
```bash
56+
pysimplemask --path /path/to/your/data
57+
```
58+
59+
## Workflow
60+
61+
1. **Load Data**: Click "Select Raw" or "Load" to open your scattering data file.
62+
2. **Define Mask**:
63+
* Use the "Mask" tabs to apply different masking techniques (Draw, Threshold, Blemish, etc.).
64+
* Combine multiple masking methods as needed.
65+
* Use "Evaluate" to preview the mask and "Apply" to finalize it.
66+
3. **Compute Partition**:
67+
* Go to the "Partition" tab.
68+
* Select the desired mode (e.g., Q-Phi) and configure parameters (number of bins, symmetry).
69+
* Click "Compute Partition" to generate the maps.
70+
4. **Save Results**:
71+
* Click "Save" to export the mask (TIFF) or the full partition data (HDF5).
72+
73+
## Credits
74+
75+
This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
76+
77+
* **Author**: Miaoqi Chu (mqichu@anl.gov)
78+
* **License**: BSD 3-Clause license

README.rst

Lines changed: 0 additions & 37 deletions
This file was deleted.

docs/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ You can either clone the public repository:
3232

3333
.. code-block:: console
3434
35-
$ git clone git://github.com/AZjk/pysimplemask
35+
$ git clone https://github.com/AdvancedPhotonSource/pySimpleMask.git
3636
3737
Or download the `tarball`_:
3838

3939
.. code-block:: console
4040
41-
$ curl -OJL https://github.com/AZjk/pysimplemask/tarball/master
41+
$ curl -OJL https://github.com/AdvancedPhotonSource/pySimpleMask/tarball/master
4242
4343
Once you have a copy of the source, you can install it with:
4444

4545
.. code-block:: console
4646
47-
$ python setup.py install
47+
$ pip install .
4848
4949
50-
.. _Github repo: https://github.com/AZjk/pysimplemask
51-
.. _tarball: https://github.com/AZjk/pysimplemask/tarball/master
50+
.. _Github repo: https://github.com/AdvancedPhotonSource/pySimpleMask
51+
.. _tarball: https://github.com/AdvancedPhotonSource/pySimpleMask/tarball/master

docs/readme.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
.. include:: ../README.rst
1+
============
2+
pySimpleMask
3+
============
4+
5+
**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.
6+
7+
Features
8+
--------
9+
10+
* **Versatile Data Support**: Load scattering data from various formats including HDF5, IMM, TIFF, and binary files.
11+
* **Interactive Masking**:
12+
* **Drawing Tools**: Create masks using polygons, circles, rectangles, and lines.
13+
* **Thresholding**: Automatically mask pixels based on intensity limits (low/high).
14+
* **Blemish Maps**: Apply pre-existing blemish (bad pixel) files.
15+
* **Outlier Removal**: Automatically detect and mask outliers using SAXS 1D azimuthal average comparisons.
16+
* **Manual Selection**: Click to mask specific pixels or regions.
17+
* **Partition Generation**:
18+
* Compute Q-Phi partitions (Dynamic/Static).
19+
* Generate X-Y partitions.
20+
* Support for custom mapping modes.
21+
* **Visualization**: Real-time visualization of scattering patterns, masks, and SAXS 1D profiles.
22+
* **Output**:
23+
* Save generated masks as TIFF files.
24+
* Save full partition maps and metadata in Nexus-compatible HDF5/XPCS formats.

docs/usage.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Usage
33
=====
44

5-
To use pySimpleMask in a project::
5+
To launch the pySimpleMask GUI, run::
6+
7+
pysimplemask
8+
9+
To use pySimpleMask as a library::
610

711
import pysimplemask

pyproject.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ build-backend = "setuptools.build_meta"
66
name = "pysimplemask"
77
dynamic = ["version"]
88
description = "A GUI for creating mask and q-partition maps for scattering patterns in preparation for SAXS/WAXS/XPCS data reduction"
9-
readme = "README.rst"
9+
readme = "README.md"
1010
authors = [{ name = "Miaoqi Chu", email = "mqichu@anl.gov" }]
1111
maintainers = [{ name = "Miaoqi Chu", email = "mqichu@anl.gov" }]
12-
license = { text = "MIT license" }
12+
license = { file = "LICENSE" }
1313

1414
classifiers = [
1515
"Development Status :: 4 - Beta",
1616
"Intended Audience :: Science/Research",
17-
"License :: OSI Approved :: MIT License",
17+
"License :: OSI Approved :: BSD License",
1818
"Programming Language :: Python :: 3",
1919
"Programming Language :: Python :: 3.12",
2020
"Topic :: Scientific/Engineering :: Visualization",
@@ -32,7 +32,7 @@ dependencies = [
3232
"PySide6==6.8.3",
3333
"astropy",
3434
"imagecodecs",
35-
"tiffile",
35+
"tifffile",
3636
]
3737

3838
[project.optional-dependencies]
@@ -47,9 +47,9 @@ dev = [
4747
pysimplemask = "pysimplemask.cli:main"
4848

4949
[project.urls]
50-
bugs = "https://github.com/AZjk/pysimplemask/issues"
51-
changelog = "https://github.com/AZjk/pysimplemask/blob/master/changelog.md"
52-
homepage = "https://github.com/AZjk/pysimplemask"
50+
bugs = "https://github.com/AdvancedPhotonSource/pySimpleMask/issues"
51+
changelog = "https://github.com/AdvancedPhotonSource/pySimpleMask/blob/master/changelog.md"
52+
homepage = "https://github.com/AdvancedPhotonSource/pySimpleMask"
5353

5454
[tool.setuptools]
5555
package-dir = { "" = "src" }
@@ -60,6 +60,7 @@ local_scheme = "node-and-timestamp"
6060

6161
[tool.setuptools.package-data]
6262
"*" = ["*.*"]
63+
"pysimplemask.resources" = ["*.svg"]
6364

6465
# ---- Mypy ----
6566
[tool.mypy]
Lines changed: 42 additions & 0 deletions
Loading

src/pysimplemask/simplemask_main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ def __init__(self, path=None):
7979

8080
self.setupUi(self)
8181
self.setWindowTitle(f"pySimpleMask {__version__}")
82+
83+
# Set application icon
84+
try:
85+
from PySide6.QtGui import QIcon
86+
icon_path = os.path.join(os.path.dirname(__file__), "resources", "logo.svg")
87+
if os.path.exists(icon_path):
88+
self.setWindowIcon(QIcon(icon_path))
89+
except Exception:
90+
pass
91+
8292
self.btn_load.clicked.connect(self.load)
8393
self.btn_plot.clicked.connect(self.plot)
8494
self.btn_compute_qpartition.clicked.connect(self.compute_partition)

0 commit comments

Comments
 (0)