Skip to content

Instantly share code, notes, and snippets.

@hanjinliu
hanjinliu / microtubule_in_napari.py
Last active June 23, 2022 05:07
Make a microtubule in napari, for illustration.
import napari
import numpy as np
class MtModel:
def __init__(
self,
npf: int = 13,
start: int = 3,
space: float = 4.0,
radius: float = 9.8,
@hanjinliu
hanjinliu / napari_explorer.py
Created September 9, 2021 15:05
Explorer widget
from __future__ import annotations
from qtpy.QtWidgets import QWidget, QFileSystemModel, QTreeView, QGridLayout, QPushButton, QFileDialog
from qtpy.QtCore import Qt, QModelIndex
import os
from skimage import io
import napari
class Explorer(QWidget):
def __init__(self, viewer:"napari.Viewer", path:str=""):
@VolkerH
VolkerH / napari_shapely.py
Created July 20, 2021 15:13
Napari to shapeley
import numpy as np
from shapely.geometry.polygon import Polygon
from shapely.geometry import GeometryCollection, LineString
def napari_shape_to_shapely(coords: np.ndarray, shape_type: str = "polygon"):
"""
Convert an individual napari shape from a shapes layer to a shapely object
There is no direct correspondence between a 'rectangle' in napari and a 'box' in