This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for /r %%f in (*MP4) do ( | |
ffmpeg -i %%f -q:a 0 -map a "%%~nf.wav" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reject_outliers(arr, window_size, threshold): | |
""" | |
Given a 1D signal, replace outliers with the average of the surrounding points. | |
Does the following for every point: | |
1. Computes the median of the sliding window | |
2. Computes the percentage difference between the current point and the | |
sliding window median | |
3. If that deviation exceeds the given threshold, replaces that point with | |
the average of the surrounding two points. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage import io | |
from skimage.measure import regionprops | |
# ---------------------------------------------------------- | |
# Input | |
wdir = os.path.dirname('<DIRECTORY_CONTAINING_IMAGES>') | |
fname = '<LABELED_IMAGE_NAME>.tif' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
x = np.array([0, 1, 2, 3, 4, 5]) | |
y = np.array([4, 5, 6, 7, 8, 9]) | |
displacement = np.sqrt(np.diff(x, prepend=x[0])**2 + np.diff(y, prepend=y[0])**2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sarcastify(my_string): | |
""" | |
Returns a sarcastic version of the provided string. | |
Example: | |
>>> sarcastify('Do you really think that\'s a good idea?') | |
"dO YoU ReAlLy tHiNk tHaT'S A GoOd iDeA?" | |
Useful for arguing online or replying all to that email that accidentally | |
went to the whole company. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy/paste into the Avizo/Amira Python console. | |
# Alternatively, save to a file, add that file to your path, and import. | |
# See docstring for usage. | |
def get_cell_contents(tablelike_object,row,column,table=0): | |
""" | |
Retrieves contents of cell i,j in a table through | |
HxSpreadSheetInterface. | |
You must use the object handle, not just the name of the object! For example, | |
to get the contents of row 4 from column 5 of a HxLabelAnalysis data object |
NewerOlder