Difference between revisions of "Documentation/Nightly/Developers/Tutorials/MigrationGuide/Slicer"

From Slicer Wiki
Jump to: navigation, search
Line 24: Line 24:
 
                       ^
 
                       ^
  
<b>Solution (Update node selector configuration):</b>
+
<b>Solution (part1: down cast to <tt>vtkMRMLLabelMapVolumeNode</tt>, remove call to <tt>SetLabelMap</tt>)</b>
  
 
Replace lines like:
 
Replace lines like:
  
  nodeSelector.setNodeTypes(QStringList("vtkMRMLScalarVolumeNode"));
+
    vtkMRMLNode* outputNode = d->OutputLabelVolumeMRMLNodeComboBox->currentNode();
  nodeSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", "1");
+
    vtkMRMLScalarVolumeNode* outputVolumeNode = vtkMRMLScalarVolumeNode::SafeDownCast(outputNode);
 +
    outputVolumeNode->SetOrigin(inputVolumeNode->GetOrigin());
 +
    outputVolumeNode->CopyOrientation(inputVolumeNode);
 +
    outputVolumeNode->SetAndObserveImageData(m_rssPointer->mp_label_mask);
 +
    outputVolumeNode->SetLabelMap(1);
 +
 
  
 
with:
 
with:
  
  nodeSelector.setNodeTypes(QStringList("vtkMRMLLabelMapVolumeNode"));
+
    vtkMRMLLabelMapVolumeNode* outputVolumeNode =
 +
      vtkMRMLLabelMapVolumeNode::SafeDownCast(d->OutputLabelVolumeMRMLNodeComboBox->currentNode());
 +
    outputVolumeNode->SetOrigin(inputVolumeNode->GetOrigin());
 +
    outputVolumeNode->CopyOrientation(inputVolumeNode);
 +
    outputVolumeNode->SetAndObserveImageData(m_rssPointer->mp_label_mask);
  
  
<b>Solution (Update UI file):</b>
+
<b>Solution (part2: Update UI file):</b>
  
 
Replace lines like:
 
Replace lines like:
Line 59: Line 68:
 
   [...]
 
   [...]
 
   </widget>
 
   </widget>
 +
 +
 +
<b>Solution (part3: Update node selector configuration):</b>
 +
 +
Replace lines like:
 +
 +
  nodeSelector.setNodeTypes(QStringList("vtkMRMLScalarVolumeNode"));
 +
  nodeSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", "1");
 +
 +
with:
 +
 +
  nodeSelector.setNodeTypes(QStringList("vtkMRMLLabelMapVolumeNode"));
 +
  
 
<b>References:</b>
 
<b>References:</b>
 
* http://www.slicer.org/slicerWiki/index.php/Documentation/Labs/Segmentations#vtkMRMLLabelMapVolumeNode_integration
 
* http://www.slicer.org/slicerWiki/index.php/Documentation/Labs/Segmentations#vtkMRMLLabelMapVolumeNode_integration
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=24291
 
* http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=24291

Revision as of 05:17, 30 August 2017

Home < Documentation < Nightly < Developers < Tutorials < MigrationGuide < Slicer


MRML: Slicer 4.5: Introduction of vtkMRMLLabelMapVolumeNode

Rational:

Before vtkMRMLScalarVolumeNode was used for both scalar and label map volumes and the LabelMap custom MRML node attribute was used for distinguishing between them (0=scalar; 1=label map volume).

This made conversion between labelmap/scalar volumes very easy but made it difficult to customize behavior, display, processing of segmentation information.

Now a new vtkMRMLLabelMapVolumeNode class is used for storing segmentation information (still using vtkMRMLScalarVolume used as base class for backward compatibility; but in the future the base class may be changed to reflect that segmentation can be represented in various ways, not just as volumes).

Error message similar to:

 error: ‘class vtkMRMLScalarVolumeNode’ has no member named ‘SetLabelMap’
    outputVolumeNode->SetLabelMap(1);
                      ^

Solution (part1: down cast to vtkMRMLLabelMapVolumeNode, remove call to SetLabelMap)

Replace lines like:

    vtkMRMLNode* outputNode = d->OutputLabelVolumeMRMLNodeComboBox->currentNode();
    vtkMRMLScalarVolumeNode* outputVolumeNode = vtkMRMLScalarVolumeNode::SafeDownCast(outputNode);
    outputVolumeNode->SetOrigin(inputVolumeNode->GetOrigin());
    outputVolumeNode->CopyOrientation(inputVolumeNode);
    outputVolumeNode->SetAndObserveImageData(m_rssPointer->mp_label_mask);
    outputVolumeNode->SetLabelMap(1);


with:

    vtkMRMLLabelMapVolumeNode* outputVolumeNode =
      vtkMRMLLabelMapVolumeNode::SafeDownCast(d->OutputLabelVolumeMRMLNodeComboBox->currentNode());
    outputVolumeNode->SetOrigin(inputVolumeNode->GetOrigin());
    outputVolumeNode->CopyOrientation(inputVolumeNode);
    outputVolumeNode->SetAndObserveImageData(m_rssPointer->mp_label_mask);


Solution (part2: Update UI file):

Replace lines like:

 <widget class="qMRMLNodeComboBox" name="InputLabelVolumeMRMLNodeComboBox">
  <property name="nodeTypes">
   <stringlist>
    <string>vtkMRMLScalarVolumeNode</string>
   </stringlist>
  </property>
  [...]
 </widget>

with:

 <widget class="qMRMLNodeComboBox" name="InputLabelVolumeMRMLNodeComboBox">
  <property name="nodeTypes">
   <stringlist>
    <string>vtkMRMLLabelMapVolumeNode</string>      <------------- Update Here
   </stringlist>
  </property>
  [...]
 </widget>


Solution (part3: Update node selector configuration):

Replace lines like:

 nodeSelector.setNodeTypes(QStringList("vtkMRMLScalarVolumeNode"));
 nodeSelector.addAttribute("vtkMRMLScalarVolumeNode", "LabelMap", "1");

with:

 nodeSelector.setNodeTypes(QStringList("vtkMRMLLabelMapVolumeNode"));


References: