Skip to content
Snippets Groups Projects
Commit 18a53cf1 authored by fima's avatar fima :beers:
Browse files

Pre workshop refactoring

parent b73ef9a0
No related branches found
No related tags found
1 merge request!103Pre workshop refactoring
......@@ -8,14 +8,16 @@ Documentation available at https://platform.qim.dk/qim3d/
"""
__version__ = "0.3.7"
__version__ = "0.3.8"
from . import io
from . import gui
from . import viz
from . import utils
from . import processing
from . import models
# commented out to avoid torch import
# from . import models
examples = io.ImgExamples()
io.logger.set_level_info()
......@@ -5,6 +5,7 @@ import ipywidgets as widgets
from IPython.display import clear_output, display
import qim3d
def circles(blobs, vol, alpha=0.5, color="#ff9900", **kwargs):
"""
Plots the blobs found on a slice of the volume.
......@@ -32,10 +33,9 @@ def circles(blobs, vol, alpha=0.5, color="#ff9900", **kwargs):
vol,
n_slices=1,
position=z_slice,
img_height=3,
img_width=3,
cmap="gray",
show_position=False,
**kwargs
)
# Add circles from deteced blobs
for detected in blobs:
......
......@@ -232,6 +232,7 @@ def slices(
show: bool = False,
show_position: bool = True,
interpolation: Optional[str] = "none",
img_size = None,
**imshow_kwargs,
) -> plt.Figure:
"""Displays one or several slices from a 3d volume.
......@@ -271,6 +272,9 @@ def slices(
```
![Grid of slices](assets/screenshots/viz-slices.png)
"""
if img_size:
img_height = img_size
img_width = img_size
# Numpy array or Torch tensor input
if not isinstance(vol, (np.ndarray, torch.Tensor, da.core.Array)):
......@@ -409,6 +413,7 @@ def slicer(
img_width: int = 3,
show_position: bool = False,
interpolation: Optional[str] = "none",
img_size = None,
**imshow_kwargs,
) -> widgets.interactive:
"""Interactive widget for visualizing slices of a 3D volume.
......@@ -435,6 +440,10 @@ def slicer(
![viz slicer](assets/screenshots/viz-slicer.gif)
"""
if img_size:
img_height = img_size
img_width = img_size
# Create the interactive widget
def _slicer(position):
fig = slices(
......@@ -472,6 +481,7 @@ def orthogonal(
img_width: int = 3,
show_position: bool = False,
interpolation: Optional[str] = None,
img_size = None,
):
"""Interactive widget for visualizing orthogonal slices of a 3D volume.
......@@ -496,6 +506,10 @@ def orthogonal(
![viz orthogonal](assets/screenshots/viz-orthogonal.gif)
"""
if img_size:
img_height = img_size
img_width = img_size
z_slicer = slicer(
vol,
axis=0,
......
......@@ -5,6 +5,7 @@ from matplotlib.gridspec import GridSpec
import ipywidgets as widgets
import logging as log
def vectors(
volume: np.ndarray,
vec: np.ndarray,
......@@ -120,10 +121,10 @@ def vectors(
# Orientations histogram
nbins = 36
angles = np.arctan2(vectors_slice_y, vectors_slice_x) # angles from 0 to pi
distribution, bin_edges = np.histogram(angles, bins=nbins, range=(0.0, np.pi))
distribution, bin_edges = np.histogram(angles, bins=nbins, range=(0, np.pi))
# Find the bin with the maximum count
peak_bin_idx = np.argmax(distribution)
peak_bin_idx = np.argmax(abs(distribution))
# Calculate the center of the peak bin
peak_angle_rad = (bin_edges[peak_bin_idx] + bin_edges[peak_bin_idx + 1]) / 2
# Convert the peak angle to degrees
......
......@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as f:
setup(
name="qim3d",
version="0.3.7",
version="0.3.8",
author="Felipe Delestro",
author_email="fima@dtu.dk",
description="QIM tools and user interfaces",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment