diff --git a/qim3d/__init__.py b/qim3d/__init__.py index ebb4e7b2a6ddca670caf5da98b580a05f0451de9..cd6ab5c23cf8f56a59e78bc4264e38d5a46c147c 100644 --- a/qim3d/__init__.py +++ b/qim3d/__init__.py @@ -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() diff --git a/qim3d/viz/detection.py b/qim3d/viz/detection.py index f6ff1bf102c44106696b2eda97b868e83d4dff67..3e83a458662e71ef7e3e29805b2bf5b533ca2829 100644 --- a/qim3d/viz/detection.py +++ b/qim3d/viz/detection.py @@ -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: diff --git a/qim3d/viz/img.py b/qim3d/viz/img.py index f2293565675af6b6fc7cf76b4577d6fbedd2fa22..f8b9bfee14c8e1e5cb4cc2b950b0440065cc99e5 100644 --- a/qim3d/viz/img.py +++ b/qim3d/viz/img.py @@ -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( ```  """ + 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(  """ + 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(  """ + if img_size: + img_height = img_size + img_width = img_size + z_slicer = slicer( vol, axis=0, diff --git a/qim3d/viz/structure_tensor.py b/qim3d/viz/structure_tensor.py index 77265aa6713216bf8e698741e693d7a1651494f6..fde3457b0aac8095258f70f36e81ab7823b25162 100644 --- a/qim3d/viz/structure_tensor.py +++ b/qim3d/viz/structure_tensor.py @@ -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, @@ -48,7 +49,7 @@ def vectors( # Visualize the structure tensor qim3d.viz.vectors(vol, vec, axis=2, slice_idx=0.5, interactive=True) ``` -  +  """ @@ -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 diff --git a/setup.py b/setup.py index 5efe335ace5499180d50bd4e582ac2b8de4c317d..bacc5a95af43c125c0ab7c7298f1fe7029604dbb 100644 --- a/setup.py +++ b/setup.py @@ -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",