From SlicerWiki
Jump to: navigation, search
Home < Documentation < Nightly < Modules < Tables

For the stable Slicer documentation, visit the 4.6 page.

Introduction and Acknowledgements

Title: Tables
Author(s)/Contributor(s): Andras Lasso (PerkLab), Kevin Wang (PMH)
License: slicer4
Acknowledgements: This work was was partially funded by OCAIRO, the Applied Cancer Research Unit program of Cancer Care Ontario, and Department of Anesthesia and Critical Care Medicine, Children’s Hospital of Philadelphia.
Contact: Andras Lasso,
Cancer Care Ontario  
Software Platform and Adaptive Radiotherapy Kit  
Ontario Consortium for Adaptive Interventions in Radiation Oncology  
University of Pennsylvania (UPenn)  

Module Description

The Tables module allows displaying and editing of spreadsheets.

Use Cases

  • Add/edit tables in Tables module and in tables view (layout: Four-up table view)
  • Import tables from and save tables to/csv, tsv, txt files
  • Copy-paste table between Slicer and other applications (Excel, etc.)
  • Use tables as inputs or outputs in CLI modules. See for example PET Standard Uptake Value Computation module.
  • Use tables to show results generated by Python scripted. See for example Label statistics module

See this short demo video for an overview of Tables module's features.

Table view used as scripted module output


Panels and their use

A list of all the panels in the interface, their features, what they mean, and how to use them. Parameters:
  • Input:
    • Active table: Select the table node to edit/view.
    • Lock button: Allows locking the table node to read-only. Only applies to the user interface. The node can eb still modified programmatically.
  • Edit:
    • Copy button: Copy contents of selected cells to clipboard.
    • Paste button: Paste contents of clipboard at the current position. Data that does not fit into the table is ignored.
    • Add column button: Add an empty column at the end of the table.
    • Delete column button: Delete all selected columns. If any cell is selected in a column the entire column will be removed.
    • Lock first column button: Use the first column as row header. Header cannot be edited and is not copied to clipboard but still saved to file.
    • Add row button: Add an empty row at the end of the table.
    • Delete row button: Delete all selected rows. If any cell is selected in a row the entire row will be removed.
    • Lock first row button: Use the first row as column header. Header cannot be edited and is not copied to clipboard but still saved to file.

List of parameters generated transforming this XML file using this XSL file. To update the URL of the XML file, edit this page.


Similar Modules



Information for Developers

Create a table node

Tables can be created and values can be defined using Table node. For example:

tableNode = slicer.vtkMRMLTableNode()
tableNode.SetCellText(0,0,'some value in col 1')
tableNode.SetCellText(0,0,'some value 2')
tableNode.SetCellText(0,0,'second column value 1')
tableNode.SetCellText(0,0,'second column value 2')

If large amount of data is to be added to the table then either temporarily disable table updates using

tableWasModified = tableNode.StartModify()

or populate a vtkStringArray object and add it to the table using AddColumn.

How to display a table in the view layout

Switch to a layout where tables are visible, set the table node as active and propagate the selection to views

How to display a table in a module GUI

A table view can be used to show table contents by simply setting the input table using setMRMLTableNode. See details in qMRMLTableView documentation.


Use table in CLI modules

Add a table element in your module XML file:

  <label>Input Table</label>
  <description><![CDATA[Array of Table values to process]]></description>
  <label>Output Table</label>
  <description><![CDATA[Array of processed (output) Table values]]></description>


  • fileExtensions attribute may be specified to change type of the output file. Allowed types: .tsv (default), .txt, .csv. See their description at table storage node documentation
  • The same table element may be used for passing color tables along with volumes. For this case type="color" is specified for the element and the data is read from/written to a color table node instead of a table node.