Skip to content

Instantly share code, notes, and snippets.

@Svidro
Svidro / !Classifying objects in QuPath
Last active October 24, 2024 02:06
Classification based groovy scripts for QuPath
Collection of scripts mostly from Pete, but also taken from the forums. Note you can always run a saved classifier using the
runClassifier() command, with the file path included as a string.
TOC
A simple cell classifier.groovy - One way to classify cells.
A simple classifier 2.groovy - Another way.
Annotation Classifications to Name field.groovy - Sets the Name of the annotation to its classification. Useful for applying a second
from math import ceil
"""from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *"""
from PyQt4.QtCore import *
from PyQt4.QtGui import *

Installing Cool-Retro-Term on Windows10

First of all, this document is just a recompilation of different resources that already existed on the web previously that I personally tested some ones did work and other not. I liked the idea to make a full guide from start to end so all of you could also enjoy playing with cool-retro-term on windows 10. Personally I installed it on a windows 10 pro version. Fingers crossed!

result

@jsomers
jsomers / websockets.md
Created September 27, 2018 12:50
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

@eric-wieser
eric-wieser / pprint_numpy.py
Created November 6, 2018 08:18
A super janky example of how _repr_html_ could be implemented
import numpy as np
def _html_repr_helper(contents, index=()):
dims_left = contents.ndim - len(index)
if dims_left == 0:
s = contents[index]
else:
s = ''.join(_html_repr_helper(contents, index + (i,)) for i in range(contents.shape[len(index)]))
return "<div class='numpy-array-ndim-{} numpy-array-ndim-m{}' title='[{}]'>{}</div>".format(
@giswqs
giswqs / build-conda-package
Last active March 2, 2021 02:02
Building a conda package and uploading it to Anaconda Cloud
#!/bin/bash
# change the package name to the existing PyPi package you would like to build and adjust the Python versions
pkg='whitebox'
array=( 3.5 3.6 3.7 )
echo "Building conda package ..."
cd ~
conda skeleton pypi $pkg
cd $pkg
@ksugar
ksugar / keras_weighted_binary_crossentropy.py
Last active February 9, 2019 14:27
Custom loss function for weighted binary crossentropy in Keras with Tensorflow
# code picked up from https://github.com/keras-team/keras/blob/master/keras/backend/tensorflow_backend.py
# Just used tf.nn.weighted_cross_entropy_with_logits instead of tf.nn.sigmoid_cross_entropy_with_logits with input pos_weight in calculation
import tensorflow as tf
from keras import backend as K
""" Weighted binary crossentropy between an output tensor and a target tensor.
# Arguments
pos_weight: A coefficient to use on the positive examples.
# Returns
@NicoKiaru
NicoKiaru / CachedBorders.groovy
Last active April 27, 2019 13:30
Lazy and cached border computation of a Label Image with BigDataViewer
/**
* GROOVY SCRIPT COMPUTING ON THE FLY EDGES OF A LABEL IMAGE
* -----
* - Computes a sample label image
* - Computes lazily with a disk cached cell img an image which finds the border of the labels in 3D
* - Displays both images in BigDataViewer
*
* Code to create the label image mainly copied from:
* - https://imagej.net/ImgLib2_Examples#Example_8_-_Working_with_sparse_data
* - And https://github.com/imglib/imglib2-cache-examples
@Bomberus
Bomberus / main.py
Last active November 8, 2019 01:50
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()
@bioimage-analysis
bioimage-analysis / napari_browser.py
Last active May 30, 2020 23:34
File browser for napari
from qtpy.QtWidgets import (
QPushButton,
QComboBox,
QTabWidget,
QHBoxLayout,
QFileDialog,
QDialogButtonBox,
QWidget,
QSlider,
)