Skip to content

Commit

Permalink
Merge pull request #391 from jo-mueller/use-sorted-semi-axes-for-curv…
Browse files Browse the repository at this point in the history
…ature-calculation

fix axes ordering for curvature calculation
  • Loading branch information
jo-mueller authored Sep 5, 2024
2 parents d924581 + 26b540a commit 8683b9e
Show file tree
Hide file tree
Showing 12 changed files with 16,697 additions and 26,736 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [windows-latest, ubuntu-latest, macos-latest] # ubuntu-latest is failing anyway
platform: [windows-latest, ubuntu-latest] # ubuntu-latest is failing anyway
python-version: ['3.9', '3.10', '3.11']

steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
(point_and_click:visualize_features)=
# Visualize measurements

Napari-stress (and the [measurement toolbox](toolboxes:stress_toolbox:stress_toolbox_interactive), in partciular) generate a number of measurements that can be visualized using the [napari-matplotlib](https://napari-matplotlib.github.io/) plugin. It is automatically installed with napari-stress and can be activated from the plugins menu (`Plugins > napari Matplotlib`).

In order to use it, check out the documentation on the [napari-matplotlib page](https://napari-matplotlib.github.io/). In the scope of napari-stress, what you will need, is the Features Histogram (`Plugins > napari Matplotlib > FeaturesHistogram`).
Napari-stress (and the [measurement toolbox](toolboxes:stress_toolbox:stress_toolbox_interactive), in partciular) generate a number of measurements that can be visualized using the [napari-matplotlib](https://napari-matplotlib.github.io/) plugin. In order to use it, check out the documentation on the [napari-matplotlib page](https://napari-matplotlib.github.io/). In the scope of napari-stress, what you will need, is the Features Histogram (`Plugins > napari Matplotlib > FeaturesHistogram`).

![](./imgs/demo_visualize_featureHistogram.png)

Expand Down
6 changes: 2 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@ install_requires =
joblib
mpmath
napari
napari-matplotlib>=1.1.0
napari-process-points-and-surfaces>=0.4.0
napari-process-points-and-surfaces
napari-segment-blobs-and-things-with-membranes
napari-tools-menu>=0.1.15
numpy<1.24.0
pandas
pygeodesic
pyocclient
scikit-image
scipy>=1.9.0
seaborn
tqdm
vedo>=2023.5.0
vispy
deprecation
bokeh >= 3.1.0
#bokeh >= 3.1.0

python_requires = >=3.7
include_package_data = True
Expand Down
26 changes: 10 additions & 16 deletions src/napari_stress/_approximation/expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ def properties(self):
The maximum and minimum curvatures :math:`H_{max}` and :math:`H_{min}` are calculated as follows:
.. math::
H_{max} = 1 / (2 * a^2) + 1 / (2 * b^2)
H_{max} = a / (2 * c^2) + a / (2 * b^2)
H_{min} = 1 / (2 * b^2) + 1 / (2 * a^2)
H_{min} = c / (2 * b^2) + c / (2 * a^2)
where a, b are the largest and smallest axes of the ellipsoid, respectively.
where a, b and c are the lengths of the ellipsoid axes along the three spatial dimensions.
"""
return self._properties

Expand All @@ -572,20 +572,14 @@ def _measure_max_min_curvatures(self):
"""
# get and remove the largest, smallest and medial axis
axes = list(self._axes)
largest_axis = max(axes)
axes.remove(largest_axis)
smallest_axis = min(axes)
axes.remove(smallest_axis)
medial_axis = axes[0]
semi_axis_sorted = np.sort(self._axes)
a = semi_axis_sorted[2]
b = semi_axis_sorted[1]
c = semi_axis_sorted[0]

# accoording to paper (https://www.biorxiv.org/content/10.1101/2021.03.26.437148v1.full)
maximum_mean_curvature = largest_axis / (
2 * smallest_axis**2
) + largest_axis / (2 * medial_axis**2)
minimum_mean_curvature = smallest_axis / (
2 * medial_axis**2
) + smallest_axis / (2 * largest_axis**2)
maximum_mean_curvature = a / (2 * c**2) + a / (2 * b**2)
minimum_mean_curvature = c / (2 * b**2) + c / (2 * a**2)

self._properties["maximum_mean_curvature"] = maximum_mean_curvature
self._properties["minimum_mean_curvature"] = minimum_mean_curvature
Expand Down Expand Up @@ -672,7 +666,7 @@ def _extract_characteristics(self, coefficients: np.ndarray):
coefficients[6] / 2.0,
coefficients[7] / 2.0,
coefficients[8] / 2.0,
-1,
coefficients[9],
],
]
)
Expand Down
8 changes: 6 additions & 2 deletions src/napari_stress/_measurements/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,12 @@ def comprehensive_analysis(
)

max_min_anisotropy = (
Expander_ellipsoid.properties["maximum_mean_curvature"]
- Expander_ellipsoid.properties["minimum_mean_curvature"]
2
* gamma
* (
Expander_ellipsoid.properties["maximum_mean_curvature"]
- Expander_ellipsoid.properties["minimum_mean_curvature"]
)
)

result = measurements.tissue_stress_tensor(
Expand Down
2 changes: 1 addition & 1 deletion src/napari_stress/_measurements/toolbox.ui
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<number>3</number>
</property>
<property name="value">
<double>3.000000000000000</double>
<double>3.300000000000000</double>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit 8683b9e

Please sign in to comment.