Skip to content

Instantly share code, notes, and snippets.

@VolkerH
VolkerH / main.py
Created November 8, 2019 01:50 — forked from Bomberus/main.py
Asyncqt, concurrent executor example
import sys, asyncio, random, threading, datetime
from qtpy.QtWidgets import QApplication, QProgressBar
from asyncqt import QEventLoop, QThreadExecutor
app = QApplication(sys.argv)
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
progress = QProgressBar()
@VolkerH
VolkerH / napari_browser.py
Created May 29, 2020 04:23 — forked from bioimage-analysis/napari_browser.py
File browser for napari
from PyQt5.QtWidgets import (
QPushButton,
QComboBox,
QTabWidget,
QHBoxLayout,
QFileDialog,
QDialogButtonBox,
QWidget,
QSlider,
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@VolkerH
VolkerH / feret_diameter.py
Created January 12, 2021 19:45
Calculate minimum and maximum feret diameters for connected components in label images in python
# Volker Hilsenstein
# BSD-3 license
import numpy as np
import skimage.morphology
from rotating_calipers import min_max_feret
def get_min_max_feret_from_labelim(label_im, labels=None):
""" given a label image, calculate the oriented
bounding box of each connected component with
@VolkerH
VolkerH / paramiko_example.py
Created March 2, 2021 20:50 — forked from batok/paramiko_example.py
Paramiko example using private key
import paramiko
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "connecting"
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k )
print "connected"
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ]
for command in commands:
print "Executing {}".format( command )
@VolkerH
VolkerH / map_array_example.ipynb
Created March 4, 2021 10:12
map_array example mapping measurements to labels
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@VolkerH
VolkerH / points_recoloring.py
Last active May 6, 2022 08:59
Point recoloring in napari
import time
import napari
import numpy as np
from napari.qt import thread_worker
from qtpy.QtWidgets import QPushButton, QVBoxLayout, QWidget
PROPNAME_ACQUIRED = "acquired"
#def generate_point_grid(nx=500, ny=100, dx=20, dy=20): # starting to lag with current napari master
def generate_point_grid(nx=1500, ny=100, dx=20, dy=20): # still working with Martin's branch
@VolkerH
VolkerH / points_update.py
Created May 6, 2022 09:37
Update points for point scanner, compare different approaches.
import time
import napari
import numpy as np
from napari.qt import thread_worker
from qtpy.QtWidgets import QPushButton, QVBoxLayout, QWidget
# Point property for MALDI points
PROPNAME_ACQUIRED = "acquired"
@VolkerH
VolkerH / contours.ipynb
Last active May 10, 2022 14:43
Visualize contours from cecog explorer
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.