Skip to content

Instantly share code, notes, and snippets.

@tlancon
Created July 20, 2018 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlancon/bb9aaabdcd5b151de4eb683fab59aff9 to your computer and use it in GitHub Desktop.
Save tlancon/bb9aaabdcd5b151de4eb683fab59aff9 to your computer and use it in GitHub Desktop.
Retrieves the contents of a specific cell from a tablelike-object (HxLabelAnalysis, HxSpreadSheet, etc.) 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 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
named "chocolate-bar.Label-Analysis" with only one tab:
>>> spreadsheet_data = hx_project.get('chocolate-bar.Label-Analysis')
>>> cell_value = get_cell_contents(spreadsheet_data,4,5)
Parameters
----------
tablelike_object : HxLabelAnalysis, HxSpreadSheet, HxImageAnalysis
The handle to the table-like object.
row : Int
Row number from which to retrieve value (starting at 0).
column : Int
Column number from which to retrieve value (starting at 0).
table : Int
Table (i.e. tab) from which to retrieve value (starting at 0).
Defaults to the first (or only) tab. Useful for results of
spatial graphs, where there are 3+ tabs.
Returns
-------
out : See note
Contents of the specified cell.
Note: returned valued has same type of column the item is
received from.
"""
ssi = tablelike_object.all_interfaces.HxSpreadSheetInterface
return ssi.tables[table].items[row,column]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment