2014 Summer Project Week:Parameter Node Serialization
From NAMIC Wiki
Home < 2014 Summer Project Week:Parameter Node Serialization
Key Investigators
- Kevin Wang (Princess Margaret Cancer Center)
- Steve Pieper
- Jim Miller (GE)
- Jc (Kitware)
- Matt (Kitware)
Project Description
The module parameter node is a very useful data structure and serialization/deserialization would be very beneficial to many uses cases.However, currently the only way to serialize/deserialize is to save the entire mrml scene which is not optimal. There has been some work done by Matt to facilite this using Json. At project week, we will have discussion and finalize the plan to develop code for this purpose.
Objective
- To develop utility for serialization/deserialization of module parameter node.
Approach, Plan
- Meet and discuss with all interested parties to come up with a plan.
- prototype code development.
Progress
- Group discussion on various approaches including Matt's Json serializer.
- Tested Python script for importing and exporting parameter node.
to do:
- Create extension? too simple for extension.
- Put this concept into CLI/Loadable module template?
Google Hangout 2014-06-24
Attendees: Kevin, Csaba, Andriy, Jim, Steve, Nicole, Michael, Jc, Andras
Topic discussed:
- Parameter Serializer
- Json-ld
- Identify module with version.
- Issue with saving vs exporting.
- Extend Parameter node to be reusable by loadable module.
Action items:
- short term: Extension to save a subset of nodes to a dedicated scene.
- medium term: Generalize approach of ParameterSerializer (json export) to regular parameter nodes.
Python script to export parameter node
>>> pnode = slicer.mrmlScene.GetNodeByID('vtkMRMLCommandLineModuleNode1') >>> tmpScene = slicer.vtkMRMLScene() >>> tmpScene.AddNode(pnode) >>> tmpScene.Commit('c:\\wangk\\tmp\\tmpScene.mrml')
Python script to import parameter node
>>> tmpScene = slicer.vtkMRMLScene() >>> node = slicer.vtkMRMLCommandLineModuleNode() >>> tmpScene.RegisterNodeClass(node) >>> tmpScene.SetURL('c:\\wangk\\tmp\\tmpScene.mrml') >>> tmpScene.Import() >>> tmpScene.InitTraversal() >>> pnode = tmpScene.GetNextNode() >>> slicer.mrmlScene.AddNode(pnode)