Skip to content

Instantly share code, notes, and snippets.

View tlancon's full-sized avatar

Trevor Lancon tlancon

View GitHub Profile
@tlancon
tlancon / TrainWekaOnMultipleImages.ijm
Created April 2, 2021 18:00
Train a Weka model on multiple images by stacking slices from them together as a single stack. The stack is the same size in XY as the largest image, and all smaller images are padded with 0's to the lower-right corner to keep their original scale.
// Requirements:
// Trainable Weka Segmentation
// The list of files to use for training must be described in a text file,
// with each line containing the full path to one image.
listOfImages = File.openDialog("Choose a file with a list of images:");
imagesString = File.openAsString(listOfImages);
images = split(imagesString, "\n");
for (i=0; i<images.length; i++) {
@tlancon
tlancon / copy_lut_napari.py
Last active June 8, 2021 15:30
Copies the main visualization properties from one layer to another in napari.
def copy_lut(from_layer, to_layer, opacity=False):
"""
Copies the visualization properties from one layer to another in napari.
Only the colormap, contrast limits, and gamma values are included by default.
The opacity can be optionally copied as well.
Blending and interpolation are ignored.
@tlancon
tlancon / napari_count_tfpn.py
Last active March 24, 2022 16:01
Call this function to launch a napari window with a given image to begin annotating true positives, false positives, and false negatives on the image with points layers.
import os
import napari
from skimage.io import imread, imsave
def napari_count_tfpn(screenshot_file, point_size=20, save_screenshot=True):
"""
Opens a napari window and initializes three points layers:
- "True Positives" with green points
- "False Positives" with red points
- "False Negatives" with yellow points
@tlancon
tlancon / us_states_dict.py
Last active May 13, 2022 08:58
Dictionary of All US States and their Abbreviations
# Inspired by https://gist.github.com/JeffPaine/3083347
# Access full state names using us_states.keys()
# Access all state abbreviations using us_states.values()
us_states = {
'Alabama': 'AL',
'Alaska': 'AK',
'Arizona': 'AZ',
'Arkansas': 'AR',
'California': 'CA',
'Colorado': 'CO',