Skip to content

Instantly share code, notes, and snippets.

View tlancon's full-sized avatar

Trevor Lancon tlancon

View GitHub Profile
@tlancon
tlancon / MultipleChoice.py
Created June 24, 2018 18:54
Compares a user's input to a list of allowable reponses and returns the keyword.
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
@tlancon
tlancon / LabelAnalysisToDataFrame.py
Created June 11, 2018 17:53
Converts HxLabelAnalysis or HxSpreadSheet objects to Pandas data frames in Amira/Avizo.
# 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":
@tlancon
tlancon / CompareTwoDatasets.tcl
Last active June 11, 2018 14:36
Compares to selected datasets in Amira/Avizo
# 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]
@tlancon
tlancon / AutoAdjustOrthoSliceColormap.tcl
Created May 2, 2018 12:45
Auto-adjusts the colormap for Avizo/Amira Ortho Slice modules
# 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
}
}