Skip to content

Instantly share code, notes, and snippets.

Trevor Lancon tlancon

  • Texas
Block or report user

Report or block tlancon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tlancon
tlancon / SeabornPaletteToAiviaColoring.py
Created Dec 2, 2019
Convert a Seaborn palette to an Aivia coloring
View SeabornPaletteToAiviaColoring.py
from seaborn import color_palette
# --- 1 Choose your palette ---
# Change the lines below to the directory where you want to save the file
# And the name of the seaborn/matplotlib color palette you want to convert
palette_directory = 'C:/FILES/Scratch/'
desired_palette = 'cubehelix'
# --- 1a If there is an error, update the list of possible palettes ---
# To update this, issue sns.color_palettes('with a completely incorrect palette name like this')
@tlancon
tlancon / sarcastify.py
Last active Jul 2, 2019
Make any string sarcastic!
View sarcastify.py
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.
@tlancon
tlancon / us_states_dict.py
Last active Nov 6, 2019
Dictionary of All US States and their Abbreviations
View us_states_dict.py
# 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',
@tlancon
tlancon / GetLabelAnalysisCellContents.py
Created Jul 20, 2018
Retrieves the contents of a specific cell from a tablelike-object (HxLabelAnalysis, HxSpreadSheet, etc.) in Amira/Avizo.
View GetLabelAnalysisCellContents.py
# 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
@tlancon
tlancon / MultipleChoice.py
Created Jun 24, 2018
Compares a user's input to a list of allowable reponses and returns the keyword.
View MultipleChoice.py
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 Jun 11, 2018
Converts HxLabelAnalysis or HxSpreadSheet objects to Pandas data frames in Amira/Avizo.
View LabelAnalysisToDataFrame.py
# 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 Jun 11, 2018
Compares to selected datasets in Amira/Avizo
View CompareTwoDatasets.tcl
# 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
Auto-adjusts the colormap for Avizo/Amira Ortho Slice modules
View AutoAdjustOrthoSliceColormap.tcl
# 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
}
}
You can’t perform that action at this time.