Skip to content

Commit

Permalink
Fixed an issue regarding the background mask
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Andre Reuter <[email protected]>
  • Loading branch information
Thyre committed Jul 19, 2021
1 parent b559d5f commit a8976d2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v2.2.1
### Added

### Changed

### Fixed
- Fixed an error regarding the mask caluclation which sometimes would not create a mask because of an error when using the average histogram

## v2.2.0
### Added
- Added SLIXVisualizeParameter to the toolbox which enables visualizing directions either as a fiber orientation map or as vectors seen before in the example Jupyter notebook
Expand Down
4 changes: 2 additions & 2 deletions SLIX/CPU/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def background_mask(image):
reversed_peaks = SLIX.toolbox.significant_peaks(image=avg_hist).flatten()

# We can now calculate the index of our background threshold using the reversed_peaks
index = numpy.argmax(reversed_peaks)
index = numpy.argmax(peaks) + numpy.argmax(reversed_peaks[numpy.argmax(peaks):])
# Reverse from 0 to 1 to original image scale and calculate the threshold position
threshold = avg_bins[index] * numpy.percentile(avg_image, 99)

Expand All @@ -56,7 +56,7 @@ def background_mask(image):

def peaks(image):
"""
Detect all peaks from a full SLI measurement. Peaks will not be filtered
Detect all peaks from a full SLI measurement. Peaks will not be filtered
in any way. To detect only significant peaks, filter the peaks by using
the prominence as a threshold.
Expand Down
4 changes: 1 addition & 3 deletions SLIX/GPU/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ def background_mask(image, return_numpy=True):
# Reverse the histogram to search for minimal values with SLIX (again)
avg_hist = -avg_hist
reversed_peaks = SLIX.toolbox.significant_peaks(image=avg_hist).flatten()

# We can now calculate the index of our background threshold using the reversed_peaks
index = numpy.argmax(reversed_peaks)
index = numpy.argmax(peaks) + numpy.argmax(reversed_peaks[numpy.argmax(peaks):])
# Reverse from 0 to 1 to original image scale and calculate the threshold position
threshold = avg_bins[index] * numpy.percentile(gpu_average, 99)

# Return a mask with the calculated background image
gpu_mask = gpu_average < threshold

Expand Down
2 changes: 1 addition & 1 deletion SLIX/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Scattered Light Imaging ToolboX (SLIX) – an open-source Python package that allows a fully automated evaluation of SLI measurements and the generation of different parameter maps
"""
__version__ = '2.2.0'
__version__ = '2.2.1'
__all__ = ['toolbox', 'io', 'visualization', 'preparation',
'attributemanager', 'CPU', 'GPU']

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = SLIX
version = 2.2.0
version = 2.2.1
author = Jan Andre Reuter, Miriam Menzel
author_email = [email protected], [email protected]
url = https://github.com/3d-pli/SLIX
Expand Down

0 comments on commit a8976d2

Please sign in to comment.