Skip to content

Commit

Permalink
Merge branch '2.4.0' into 'master'
Browse files Browse the repository at this point in the history
Version update for new release.

See merge request inm-1/fa/sli/tools/slix!23
  • Loading branch information
Thyre committed Dec 14, 2021
2 parents da11722 + 2710237 commit 202102c
Show file tree
Hide file tree
Showing 47 changed files with 3,084 additions and 457 deletions.
58 changes: 39 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,59 @@
include:
- template: Code-Quality.gitlab-ci.yml

stages:
- test
- install
- pack

before_script:
- apt-get update -qq && apt-get upgrade -y
- apt-get install -y python3 python3-pip
- /usr/bin/python3 -m pip install --upgrade pip
code_quality_html:
extends: code_quality
variables:
REPORT_FORMAT: html
artifacts:
paths: [gl-code-quality-report.html]

lint:python3:
test:python3:
stage: test
allow_failure: true
image: cupy/cupy:v8.0.0
script:
- pip3 install flake8
- flake8 SLIX/ --count --select=E9,F63,F7,F82 --show-source --statistics
- flake8 SLIX/ --count --exit-zero --max-complexity=10 --statistics
- apt-get update -qq && apt-get upgrade -y
- apt-get install -y python3 python3-pip
- /usr/bin/python3 -m pip install --upgrade pip
- pip3 install tifffile numpy nibabel h5py pillow numba matplotlib pytest pytest-cov
# Online preview of tests that did run successfully
- pytest tests --junitxml=report.xml
artifacts:
when: always
reports:
junit: report.xml
tags:
- docker
- gpu

test:python3:
- gpu
test_with_coverage:python3:
stage: test
image: cupy/cupy:v8.0.0
script:
- apt-get install -y python3 python3-pip
- /usr/bin/python3 -m pip install --upgrade pip
- pip3 install tifffile numpy nibabel h5py pillow numba matplotlib pytest pytest-cov
- pytest --cov=SLIX --cov-config=.coveragerc tests --cov-report=html
- coverage run -m pytest --cov-config=.coveragerc tests
- coverage report
- coverage xml
artifacts:
paths:
- htmlcov/
tags:
- docker
- gpu
reports:
cobertura: coverage.xml
only:
- merge_requests

install:python3:
stage: install
image: cupy/cupy:v8.0.0
script:
- apt-get update -qq && apt-get upgrade -y
- apt-get install -y python3 python3-pip
- /usr/bin/python3 -m pip install --upgrade pip
- pip3 install .
tags:
- docker
Expand All @@ -46,8 +63,11 @@ pack:python3:
stage: pack
image: cupy/cupy:v8.0.0
script:
- apt-get update -qq && apt-get upgrade -y
- apt-get install -y python3 python3-pip
- /usr/bin/python3 -m pip install --upgrade pip
- pip3 install pep517
- python3 -m pep517.build --source --binary --out-dir dist/ .
tags:
- docker
- gpu
- gpu
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## v2.4.0
### Added
- Added vector weighting option available for SLIXVisualizeParameter with the parameter `--weight_map`. This parameter is used to weight the length of the shown vectors in both the unit vector visualization as well as the vector distribution.
- Added new options to SLIXVisualizeParameter to allow the user to customize the appearance of the resulting parameter maps such as the vector maps and the FOM.
- Added a new interface to SLIX.visualize called Colormaps. This class contains basic colormaps that can be used to visualize the results of the SLIX.visualize methods.
- Currently this class holds the following color maps:
- Colomaps.rgb
- Colormaps.hsv_black
- Colormaps.hsv_white
- Colormaps.hsv_black_reverse
- Colormaps.hsv_white_reverse
- Colormaps.rgb_reverse
- Added command line parameters for the user to choose the color maps when calling SLIXVisualizeParameter (`-c, --colormap`).
- Added a new color_bubble method to SLIX.visualize.
- Added an inclination parameter to SLIXVisualizeParameter [...] fom to allow the user to choose the inclination of the FOM.
-
### Changed
- When calling SLIXVisualizeParameter, a color bubble associated with the written image will be written as well. This can be disabled by using the `--disable_colorbubble` option.
- Added a new method to SLIX.toolbox to get unit vectors from both direction and inclination images (3D instead of 2D only).
- Added the name of the color map to the filename.
- Added optional paramer name for the directions in SLIXVisualizeParameter (`--direction`).
-
### Fixed
- Fixed a bug in SLIXVisualizeParameter and SLIX.visualize.unit_vectors which caused the unit vectors to be drawn in the wrong direction.

## v2.3.0
### Added
Expand Down
247 changes: 180 additions & 67 deletions README.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions SLIX/CPU/_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _peakdistance(peak_image, centroids, number_of_peaks):
elif number_of_peaks[idx] % 2 == 0:
left = (i + sub_centroid_array[i]) * 360.0 / \
len(sub_peak_array)
right_side_peak = number_of_peaks[idx]//2
right_side_peak = number_of_peaks[idx] // 2
current_position = i
while right_side_peak > 0 and \
current_position < len(sub_peak_array):
Expand All @@ -152,7 +152,7 @@ def _peakdistance(peak_image, centroids, number_of_peaks):

current_pair += 1

if current_pair == number_of_peaks[idx]//2:
if current_pair == number_of_peaks[idx] // 2:
break
return result_image

Expand Down Expand Up @@ -204,8 +204,8 @@ def _direction(peak_array, centroids, number_of_peaks, num_directions, correctdi
if right_side_peak == 0:
right = (current_position +
sub_centroid_array[current_position]) * \
360.0 / len(sub_peak_array) + \
numpy.float32(correctdir)
360.0 / len(sub_peak_array) + \
numpy.float32(correctdir)
# If our peaks are around 180° ± 35° apart,
# we can calculate the direction.
if number_of_peaks[idx] > 2 and \
Expand All @@ -217,7 +217,7 @@ def _direction(peak_array, centroids, number_of_peaks, num_directions, correctdi
(270.0 - ((left + right) / 2.0)) % 180
current_direction += 1

if current_direction == number_of_peaks[idx]//2:
if current_direction == number_of_peaks[idx] // 2:
break
return result_image

Expand Down
27 changes: 27 additions & 0 deletions SLIX/CPU/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,30 @@ def unit_vectors(direction):
UnitY[numpy.isclose(direction, -1)] = 0

return UnitX, UnitY


def unit_vectors_3d(direction, inclination):
"""
Calculate the unit vectors (UnitX, UnitY, UnitZ) from a given direction angle.
Args:
direction: 3D NumPy array - direction angles in degrees
inclination: 3D NumPy array - inclination angles in degrees
Returns:
UnitX, UnitY, UnitZ: 3D NumPy array, 3D NumPy array
x- and y-vector component in arrays
"""
directions_rad = numpy.deg2rad(direction)
UnitX = -numpy.sin(0.5 * numpy.pi) * numpy.cos(directions_rad)
UnitY = numpy.sin(0.5 * numpy.pi) * numpy.sin(directions_rad)
UnitZ = numpy.sin(inclination)

UnitX[numpy.isclose(direction, -1)] = 0
UnitY[numpy.isclose(direction, -1)] = 0
UnitZ[numpy.isclose(direction, -1)] = 0

return UnitX, UnitY, UnitZ
41 changes: 41 additions & 0 deletions SLIX/GPU/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,44 @@ def unit_vectors(direction, return_numpy=True):
if return_numpy:
return UnitX.get(), UnitY.get()
return UnitX, UnitY


def unit_vectors_3d(direction, inclination, return_numpy=True):
"""
Calculate the unit vectors (UnitX, UnitY, UnitZ) from a given direction angle.
Args:
direction: 3D NumPy array - direction angles in degrees
inclination: 3D NumPy array - inclination angles in degrees
return_numpy: Necessary if using `use_gpu`. Specifies if a CuPy or Numpy
array will be returned.
Returns:
UnitX, UnitY, UnitZ: 3D NumPy array, 3D NumPy array
x- and y-vector component in arrays
"""
direction_gpu = cupy.array(direction)
direction_gpu_rad = cupy.deg2rad(direction_gpu)
UnitX = -cupy.sin(0.5 * cupy.pi) * cupy.cos(direction_gpu_rad)
UnitY = cupy.sin(0.5 * cupy.pi) * cupy.sin(direction_gpu_rad)
del direction_gpu_rad

UnitX[cupy.isclose(direction_gpu, -1)] = 0
UnitY[cupy.isclose(direction_gpu, -1)] = 0

inclination_gpu = cupy.array(inclination)
inclination_gpu_rad = cupy.deg2rad(inclination_gpu)
UnitZ = cupy.sin(inclination_gpu_rad)
del inclination_gpu_rad

UnitZ[cupy.isclose(direction_gpu, -1)] = 0
del direction_gpu
del inclination_gpu

if return_numpy:
return UnitX.get(), UnitY.get(), UnitZ.get()
return UnitX, UnitY, UnitZ
9 changes: 5 additions & 4 deletions SLIX/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
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
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.3.0'
__version__ = '2.4.0-alpha2'
__all__ = ['toolbox', 'io', 'visualization', 'preparation',
'attributemanager']
'attributemanager', 'classification']

from . import toolbox, io, visualization, preparation, attributemanager
from . import toolbox, io, visualization, preparation, attributemanager, classification
Loading

0 comments on commit 202102c

Please sign in to comment.