<?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.2%2FDevelopers%2FIO</id>
	<title>Documentation/4.2/Developers/IO - 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.2%2FDevelopers%2FIO"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/IO&amp;action=history"/>
	<updated>2026-04-17T22:51:54Z</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.2/Developers/IO&amp;diff=32840&amp;oldid=prev</id>
		<title>UpdateBot: Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/IO&amp;diff=32840&amp;oldid=prev"/>
		<updated>2013-06-14T07:47:35Z</updated>

		<summary type="html">&lt;p&gt;Prepend documentation/versioncheck template. See http://na-mic.org/Mantis/view.php?id=2887&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 07:47, 14 June 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Read=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Read=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:IOOverview.png|600px|center]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Image:IOOverview.png|600px|center]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/IO&amp;diff=28789&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.2</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.2/Developers/IO&amp;diff=28789&amp;oldid=prev"/>
		<updated>2012-10-31T21:59:55Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.2&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Read=&lt;br /&gt;
[[Image:IOOverview.png|600px|center]]&lt;br /&gt;
== Main classes ==&lt;br /&gt;
* &amp;lt;code&amp;gt;vtkSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;Node&amp;lt;/code&amp;gt; is a [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLStorableNode.h?view=markup storable node] that represents the data from file (e.g. [[http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLModelNode.h?view=markup vtkMRMLModelNode])&lt;br /&gt;
* &amp;lt;code&amp;gt;vtkSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;StorageNode&amp;lt;/code&amp;gt; is the file reader. It populates the storable node using the method  &amp;lt;code&amp;gt;vtkMRML&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;StorageNode::ReadData(vtkMRMLStorableNode*,bool)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;code&amp;gt;vtkSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;sLogic&amp;lt;/code&amp;gt; is the MRML logic of the &amp;lt;code&amp;gt;XYZ&amp;lt;/code&amp;gt; module. It exposes a convenient method &amp;lt;code&amp;gt;AddXYZ(const char* fileName, const char* nodeName=0);&amp;lt;/code&amp;gt; that creates a MRML &amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt; node (&amp;lt;code&amp;gt;vtkMRML&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;Node&amp;lt;/code&amp;gt;)and its associated storage node (&amp;lt;code&amp;gt;vtkMRML&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;StorageNode&amp;lt;/code&amp;gt;), add them into the scene, and call &amp;lt;code&amp;gt;vtkMRML&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;StorageNode::ReadData(vtkMRMLStorableNode*,bool);&amp;lt;/code&amp;gt; on the storage node to load the file. If the loading fails, it removes the previously created nodes from the scene.&lt;br /&gt;
* &amp;lt;code&amp;gt;qSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;sIO&amp;lt;/code&amp;gt; is a plugin that is registered by modules into the &amp;lt;code&amp;gt;qSlicerCoreIOManager&amp;lt;/code&amp;gt;. It is the interface between Qt and MRML logics. It internally calls &amp;lt;code&amp;gt;vtkSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;sLogic::Add&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt;().&lt;br /&gt;
* &amp;lt;code&amp;gt;qSlicer&amp;lt;i&amp;gt;XYZ&amp;lt;/i&amp;gt;sIOOptionsWidget&amp;lt;/code&amp;gt; is a widget that sets loading options that gets passed to the logic.&lt;br /&gt;
* &amp;lt;code&amp;gt;qSlicerCoreIOManager&amp;lt;/code&amp;gt; is the central class where any IO operation must go through. qSlicerIOs can be registered using &amp;lt;code&amp;gt;qSlicerCoreIOManager::registerIO(qSlicerIO*)&amp;lt;/code&amp;gt; and nodes can be loaded using &amp;lt;code&amp;gt;qSlicerCoreIOManager::loadNodes(...)&amp;lt;/code&amp;gt;. It exposes a set of convenient methods such as &amp;quot;what reader must be used for what file&amp;quot;.&lt;br /&gt;
* &amp;lt;code&amp;gt;qSlicerDataDialog&amp;lt;/code&amp;gt; is the dialog that allows the user to select the files to load.&lt;br /&gt;
&lt;br /&gt;
==How to add support for reading a new file format ?==&lt;br /&gt;
# Write method &amp;lt;code&amp;gt;vtkMRMLXYZStorageNode::ReadDataInternal(vtkMRMLStorableNode*, bool temporary);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Write method &amp;lt;code&amp;gt;vtkMRMLXYZsLogic::AddXYZ(const char* fileName, const char nodeName =0);&amp;lt;/code&amp;gt;&lt;br /&gt;
# Write class &amp;lt;code&amp;gt;qSlicerXYZsIO&amp;lt;/code&amp;gt;&lt;br /&gt;
# Optional: Write class &amp;lt;code&amp;gt;qSlicerXYZsIOOptionsWidget&amp;lt;/code&amp;gt; if you want the user to optionally specify loading options.&lt;br /&gt;
# In &amp;lt;code&amp;gt;qSlicerXYZsModule::setup()&amp;lt;/code&amp;gt;, instantiate and register &amp;lt;code&amp;gt;qSlicerXYZsIO&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;qSlicerCoreIOManager&amp;lt;/code&amp;gt;&lt;br /&gt;
# Add file format to [Documentation/{{documentation/version}}/SlicerApplication/SupportedDataFormat|SupportedDataFormat] wiki page&lt;br /&gt;
&lt;br /&gt;
== ModifiedSinceRead ==&lt;br /&gt;
In order to inform the user what data has been changed since it was last read, a ModifiedSinceRead mechanism is in place to track when was the file last read and when was the data last modified. If a modification happened , the storable node &amp;lt;code&amp;gt;vtkMRMLStorableNode::GetModifiedSinceRead()&amp;lt;/code&amp;gt; must return true. If the data in the node is the same as in the file, then &amp;lt;code&amp;gt;vtkMRMLStorableNode::GetModifiedSinceRead()&amp;lt;/code&amp;gt; must return false.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;vtkMRMLStorageNode&amp;lt;/code&amp;gt; keeps track of when a file was last read or written (&amp;lt;code&amp;gt;vtkTimeStamp* vtkMRMLStorageNode::StoredTime&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;vtkMRMLStorableNode&amp;lt;/code&amp;gt; keeps track of when the data was last modified (&amp;lt;code&amp;gt;vtkTimeStamp vtkMRMLStorableNode::StorableModifiedTime&amp;lt;/code&amp;gt;). Anytime a &amp;lt;code&amp;gt;vtkMRMLStorableNode&amp;lt;/code&amp;gt; property that is saved in file is modified, the &amp;lt;code&amp;gt;StorableModifiedTime&amp;lt;/code&amp;gt; time stamp must be modified.&lt;br /&gt;
&lt;br /&gt;
At exit time (&amp;lt;code&amp;gt;qSlicerMainWindow::closeEvent()&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;vtkMRMLStorableNode::GetModifiedSinceRead()&amp;lt;/code&amp;gt; is called to check if the data in the node is the same as in the file or if it has been modified after the file was last read or written. It internally checks &amp;lt;code&amp;gt;vtkTimeStamp* vtkMRMLStorageNode::StoredTime&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;vtkTimeStamp vtkMRMLStorableNode::StorableModifiedTime&amp;lt;/code&amp;gt;. If the data is more recent, then a message dialog is shown to the user telling him that some data is different from file; leaving without saving will loose the changes.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
* Models &lt;br /&gt;
** [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLModelNode.h?view=markup Libs/MRML/Core/vtkMRMLModelNode]&lt;br /&gt;
** [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Libs/MRML/Core/vtkMRMLModelStorageNode.h?view=markup Libs/MRML/Core/vtkMRMLModelStorageNode]&lt;br /&gt;
** [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Models/Logic/vtkSlicerModelsLogic.h?view=markup Modules/Loadable/Models/Logic/vtkSlicerModelsLogic]&lt;br /&gt;
** [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Models/qSlicerModelsIO.h?view=markup Modules/Loadable/Models/qSlicerModelsIO]&lt;br /&gt;
** [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/Models/qSlicerModelsModule.h?view=markup Modules/Loadable/Models/qSlicerModelsModule]&lt;br /&gt;
&lt;br /&gt;
== How to load files programmatically ==&lt;br /&gt;
{|width = &amp;quot;100%&amp;quot;&lt;br /&gt;
! style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;|C++&lt;br /&gt;
! style=&amp;quot;border-bottom: 1px solid darkgrey;font-size: 75%;&amp;quot;|Python&lt;br /&gt;
|-&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
 [http://slicer.org/doc/html/classqSlicerCoreIOManager.html qSlicerCoreIOManager]* coreIOManager = qSlicerCoreApplication::application()-&amp;gt;coreIOManager();&lt;br /&gt;
 qSlicerIO::IOProperties fileParameters;&lt;br /&gt;
 fileParameters[&amp;quot;filename&amp;quot;] = &amp;quot;/path/of/file.ext&amp;quot;;&lt;br /&gt;
 vtkMRMLNode* volumeNode = coreIOManager-&amp;gt;[http://slicer.org/doc/html/classqSlicerCoreIOManager.html#a36a78dba553b52f395f997fe11aaff23 loadNodesAndGetFirst](&amp;quot;VolumeFile&amp;quot;, parameters);&lt;br /&gt;
Works also with &amp;quot;ModelFile&amp;quot;, &amp;quot;TransformFile&amp;quot;, &amp;quot;SceneFile&amp;quot;...&lt;br /&gt;
| valign=&amp;quot;top&amp;quot; |&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; volumeNode = slicer.util.loadVolume('/path/of/file.ext')&lt;br /&gt;
It works also with loadModel, loadTransform, loadScene...&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Write=&lt;br /&gt;
The mechanism is similar to '''Read'''. &amp;lt;code&amp;gt;vtkMRMLXYZStorageNode::WriteDataInternal(...)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;qSlicerXYZWriter&amp;lt;/code&amp;gt; must implemented.&lt;br /&gt;
&lt;br /&gt;
=IO Dialogs=&lt;br /&gt;
By default, all the IOs must be done through &amp;lt;code&amp;gt;qSlicerDataDialog&amp;lt;/code&amp;gt; for reading files and &amp;lt;code&amp;gt;qSlicerSaveDataDialog&amp;lt;/code&amp;gt; for writting files. However, due to historical reasons, it is possible to have custom dialogs for each node types.&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>