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
# 1. Copy/paste this into Avizo/Amira console | |
# 2. Select one or more Ortho Slices to auto-adjust and press F3 | |
# Note: Can change 'onKeyFX' to the desired keybinding | |
proc onKeyF3 {} { | |
foreach slice [all -selected HxOrthoSlice] { | |
$slice colormap adjustRange; $slice fire | |
} | |
} |
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
# 1. Copy/paste this into Avizo/Amira console | |
# 2. Select two datasets to compare and press Shift+F3 | |
# Note: Can change 'onKeyFX' to the desired keybinding | |
# Note: Requires Avizo (not Avizo Lite) or the XImagePAQ extension for Amira | |
proc onKeyShiftF3 {} { | |
if {[llength [all -selected]] != 2} { | |
echo "Please select two data objects." | |
} else { | |
set before [lindex [all -selected] 0] | |
set after [lindex [all -selected] 1] |
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 labelanalysis_to_dataframe(tablelike_object): | |
""" | |
Converts a tablelike object (HxSpreadSheet, HxLabelAnalysis, or anything with | |
.all_interfaces.HxSpreadSheetInterface) to a Pandas data frame with the column names intact. | |
You must use the object handle, not just the name of the object! For example, | |
to convert a HxLabelAnalysis data object named "chocolate-bar.Label-Analysis": |
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 parse_response(multiple_choice, prompt=None): | |
""" | |
Splits a user's input into individual words and searches a list | |
of allowable responses for a unique match, then returns the word | |
that matches one of the options. | |
List comprehension syntax explained for my own reference: | |
1. for i in response.split() - breaks every word of response | |
into individual strings | |
2. if i in multiple_choice - searches for ALL recognized words |
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 |
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
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
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
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 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' |
OlderNewer