<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.8%2FModules%2FTables</id>
	<title>Documentation/4.8/Modules/Tables - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.8%2FModules%2FTables"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/Modules/Tables&amp;action=history"/>
	<updated>2026-05-04T23:34:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.8/Modules/Tables&amp;diff=55847&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.8</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/Modules/Tables&amp;diff=55847&amp;oldid=prev"/>
		<updated>2017-10-18T07:07:50Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.8&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}} }}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-acknowledgements}}&lt;br /&gt;
:'''Contact:''' Andras Lasso, &amp;lt;email&amp;gt;lasso@queensu.ca&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|{{collaborator|logo|cco}}|{{collaborator|longname|cco}}&lt;br /&gt;
|{{collaborator|logo|sparkit}}|{{collaborator|longname|sparkit}}&lt;br /&gt;
|{{collaborator|logo|ocairo}}|{{collaborator|longname|ocairo}}&lt;br /&gt;
|{{collaborator|logo|upenn}}|{{collaborator|longname|upenn}}&lt;br /&gt;
}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Module Description}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-description}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;|Examples:&lt;br /&gt;
* Add/edit tables in Tables module and in tables view (layout: Four-up table view)&lt;br /&gt;
* Import tables from and save tables to/csv, tsv, txt files&lt;br /&gt;
* Copy-paste table between Slicer and other applications (Excel, etc.)&lt;br /&gt;
* Use tables as inputs or outputs in CLI modules. See for example [[Documentation/{{documentation/version}}/Modules/PETStandardUptakeValueComputation|PET Standard Uptake Value Computation]] module.&lt;br /&gt;
* Use tables to show results generated by Python scripted. See for example [[Documentation/{{documentation/version}}/Modules/LabelStatistics|Label statistics]] module&lt;br /&gt;
&lt;br /&gt;
See this '''[https://youtu.be/tNrAut6WD_k short demo video]''' for an overview of Tables module's features.&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;|[[File:Slicer45-Tables-TableView.png|left|300px|Table view used as scripted module output]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* Tutorial about [http://wiki.na-mic.org/Wiki/index.php/Slicer3:Training loading and viewing data]. &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| A list of all the panels in the interface, their features, what they mean, and how to use them. {{documentation/{{documentation/version}}/module-parametersdescription}}&lt;br /&gt;
|valign=&amp;quot;top&amp;quot;| [[File:Slicer45-Tables-GUI.png|thumb|200px]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Modules}}&lt;br /&gt;
* [[Documentation/{{documentation/version}}/Modules/PETStandardUptakeValueComputation|PET Standard Uptake Value Computation]] CLI module uses table as output.&lt;br /&gt;
* [[Documentation/{{documentation/version}}/Modules/LabelStatistics|Label statistics]] scripted module can optionally create a table as output.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
N/A&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
&amp;lt;!-- {{documentation/{{documentation/version}}/module-developerinfo}} --&amp;gt;&lt;br /&gt;
===Create a table node===&lt;br /&gt;
Tables can be created and values can be defined using [http://slicer.org/doc/html/classvtkMRMLTableNode.html Table node]. For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tableNode = slicer.vtkMRMLTableNode()&lt;br /&gt;
col=tableNode.AddColumn()&lt;br /&gt;
col.SetName('First')&lt;br /&gt;
col=tableNode.AddColumn()&lt;br /&gt;
col.SetName('Seconf')&lt;br /&gt;
tableNode.AddEmptyRow()&lt;br /&gt;
tableNode.AddEmptyRow()&lt;br /&gt;
tableNode.SetCellText(0,0,'some value in col 1')&lt;br /&gt;
tableNode.SetCellText(0,0,'some value 2')&lt;br /&gt;
tableNode.SetCellText(0,0,'second column value 1')&lt;br /&gt;
tableNode.SetCellText(0,0,'second column value 2')&lt;br /&gt;
slicer.mrmlScene.AddNode(tableNode)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If large amount of data is to be added to the table then either temporarily disable table updates using&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tableWasModified = tableNode.StartModify()&lt;br /&gt;
...&lt;br /&gt;
tableNode.EndModify(tableWasModified)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or populate a ''vtkStringArray'' object and add it to the table using ''AddColumn''.&lt;br /&gt;
&lt;br /&gt;
===How to display a table in the view layout===&lt;br /&gt;
Switch to a layout where tables are visible, set the table node as active and propagate the selection to views&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpTableView)&lt;br /&gt;
slicer.app.applicationLogic().GetSelectionNode().SetReferenceActiveTableID(tableNode.GetID())&lt;br /&gt;
slicer.app.applicationLogic().PropagateTableSelection()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How to display a table in a module GUI==&lt;br /&gt;
A table view can be used to show table contents by simply setting the input table using setMRMLTableNode. See details in [http://slicer.org/doc/html/classqMRMLTableView.html qMRMLTableView documentation].&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tableView=slicer.qMRMLTableView()&lt;br /&gt;
tableView.setMRMLTableNode(tableNode)&lt;br /&gt;
tableView.show()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Use table in CLI modules===&lt;br /&gt;
Add a ''table'' element in your module XML file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;inputDT&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;channel&amp;gt;input&amp;lt;/channel&amp;gt;&lt;br /&gt;
  &amp;lt;label&amp;gt;Input Table&amp;lt;/label&amp;gt;&lt;br /&gt;
  &amp;lt;longflag&amp;gt;inputTable&amp;lt;/longflag&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;&amp;lt;![CDATA[Array of Table values to process]]&amp;gt;&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
  &amp;lt;name&amp;gt;outputDT&amp;lt;/name&amp;gt;&lt;br /&gt;
  &amp;lt;channel&amp;gt;output&amp;lt;/channel&amp;gt;&lt;br /&gt;
  &amp;lt;label&amp;gt;Output Table&amp;lt;/label&amp;gt;&lt;br /&gt;
  &amp;lt;longflag&amp;gt;outputTable&amp;lt;/longflag&amp;gt;&lt;br /&gt;
  &amp;lt;description&amp;gt;&amp;lt;![CDATA[Array of processed (output) Table values]]&amp;gt;&amp;lt;/description&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
* ''fileExtensions'' attribute may be specified to change type of the output file. Allowed types: .tsv (default), .txt, .csv. See their description at [http://slicer.org/doc/html/classvtkMRMLTableStorageNode.html table storage node documentation]&lt;br /&gt;
* The same ''table'' element may be used for passing color tables along with volumes. For this case ''type=&amp;quot;color&amp;quot;'' is specified for the element and the data is read from/written to a color table node instead of a table node.&lt;br /&gt;
&lt;br /&gt;
===Table column properties===&lt;br /&gt;
&lt;br /&gt;
Properties can be defined for each column of the table using a schema file. Standard properties include data type, default value, long name, description, unit label. See complete list in [http://apidocs.slicer.org/master/classvtkMRMLTableNode.html#a01b263899f7eedb5ebfbc74298c2a1ca table node API documentation]. Properties are stored in a separate .csv file, with exactly the same name and extension as the table file, but with the ''.schema'' word inserted before the extension (ExampleTable.csv -&amp;gt; ExampleTable.schema.csv).&lt;br /&gt;
&lt;br /&gt;
Example table file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID,Structure,Volume,Surface,Verified&lt;br /&gt;
1,bone,12.4,11.2,1&lt;br /&gt;
2,tumor,32.1,22.5,1&lt;br /&gt;
3,cartilage,33.2,63.2,0&lt;br /&gt;
4,soft tissue,66.5,19.3,1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example schema file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
columnName,type,defaultValue,longName,description,unitLabel&lt;br /&gt;
ID,string,,Measurement identifier,This text describes in detail what the column content is.,&lt;br /&gt;
Structure,string,,Structure name,Description &amp;lt;b&amp;gt;can&amp;lt;/b&amp;gt; use html for formatting.,&lt;br /&gt;
Volume,double,0,Measured volume,,cc&lt;br /&gt;
Surface,double,0,Measured surface,,mm2&lt;br /&gt;
Verified,bit,0,Correctness verified,This column appears as a checkbox in the user interface.,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Table display in Slicer:&lt;br /&gt;
[[File:Slicer47-ExampleTableProperties.png|left|Table properties are displayed in the tooltip and may be used for defining the column appearance (values in bit type column appear as checkbox)]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>