Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Aug 29, 2022
2 parents 64ffc85 + f7f966f commit a4a86a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Release 2.1.12
--------------

* Improved the masking functionality in `bragg_peaks_persistence`.

Release 2.1.11
--------------

Expand Down
2 changes: 1 addition & 1 deletion skued/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
__author__ = "Laurent P. René de Cotret"
__email__ = "[email protected]"
__license__ = "GPLv3"
__version__ = "2.1.11"
__version__ = "2.1.12"

from .affine import (
affine_map,
Expand Down
15 changes: 13 additions & 2 deletions skued/image/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ def bragg_peaks_persistence(
"""
if mask is None:
mask = np.ones_like(im, dtype=bool)
im[~mask] = 0.0
if center is None:
center = autocenter(im=im, mask=mask)
image = im

g0 = Persistence(im).persistence
birth_death = list()
Expand Down Expand Up @@ -237,6 +235,19 @@ def bragg_peaks_persistence(
sorted(candidates, key=lambda p: np.linalg.norm(p - center))
).reshape(-1, 2)
birth_death = np.array(birth_death).reshape(-1, 2)

# remove peaks that are within the masked area
if mask.sum() != mask.shape[0] * mask.shape[1]:
peaks = np.array([p for p in peaks if mask[p[1], p[0]]])
birth_death = np.array(
[bd for p, bd in zip(peaks, birth_death) if mask[p[1], p[0]]]
)
birth_death_indices = np.array(
[bdi for p, bdi in zip(peaks, birth_death_indices) if mask[p[1], p[0]]]
)
persistencies = np.array(
[pers for p, pers in zip(peaks, persistencies) if mask[p[1], p[0]]]
)
return peaks, birth_death, birth_death_indices, persistencies


Expand Down

0 comments on commit a4a86a1

Please sign in to comment.