Skip to content

Commit

Permalink
ENH: Allow selecting volume sequence nodes as CLI module input (Slice…
Browse files Browse the repository at this point in the history
…r#6482)

If an input `image` parameter's `type` is set to "dynamic-contrast-enhanced", "signal", or "multichannel" then the generated node selector
allows selection of `vtkMRMLSequenceNode` node that contains `vtkMRMLScalarVolume` nodes in it.
  • Loading branch information
lassoan authored Jul 27, 2022
1 parent 91acebf commit 38e026f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Base/QTCLI/qSlicerCLIModuleUIHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,19 @@ QWidget* qSlicerCLIModuleUIHelperPrivate::createImageTagWidget(const ModuleParam
else
{
QString nodeType = Self::nodeTypeFromMap(Self::ImageTypeAttributeToNodeType, type, "vtkMRMLScalarVolumeNode");
widget->setNodeTypes(QStringList(nodeType));
}
// If node type is vtkMRMLMultiVolumeNode then allow selecting volume sequences, too
if (nodeType == "vtkMRMLMultiVolumeNode")
{
QStringList nodeTypes;
nodeTypes << nodeType << "vtkMRMLSequenceNode";
widget->setNodeTypes(nodeTypes);
widget->addAttribute("vtkMRMLSequenceNode", "DataNodeClassName", "vtkMRMLScalarVolumeNode");
}
else
{
widget->setNodeTypes(QStringList(nodeType));
}
}

// TODO - title + " Volume"

Expand Down
7 changes: 7 additions & 0 deletions Libs/MRML/Core/vtkMRMLSequenceNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ vtkMRMLNode* vtkMRMLSequenceNode::SetDataNodeAtValue(vtkMRMLNode* node, const st
vtkErrorMacro("vtkMRMLSequenceNode::SetDataNodeAtValue failed, invalid node");
return nullptr;
}
MRMLNodeModifyBlocker blocker(this);
// Make sure the sequence scene is created
this->GetSequenceScene();
// Add a copy of the node to the sequence's scene
Expand All @@ -419,6 +420,12 @@ vtkMRMLNode* vtkMRMLSequenceNode::SetDataNodeAtValue(vtkMRMLNode* node, const st
}
this->IndexEntries[seqItemIndex].DataNode = newNode;
this->IndexEntries[seqItemIndex].DataNodeID.clear();
// Save the sequence data node class namein a node attribute to allow easy access
// (e.g., for filtering on the GUI).
if (this->GetNumberOfDataNodes() <= 1)
{
this->SetAttribute("DataNodeClassName", this->GetDataNodeClassName().c_str());
}
this->Modified();
this->StorableModifiedTime.Modified();
return newNode;
Expand Down
4 changes: 4 additions & 0 deletions Libs/MRML/Core/vtkMRMLSequenceNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
///
/// If an index is numeric then it is sorted differently and equality determined using
/// a numerical tolerance instead of exact string matching.
///
/// Class name of data nodes stored in the sequence is set into the `DataNodeClassName`
/// node attribute, which may be used for attribute-based filters (for example,
/// to show only certain type of sequence node in a node selector).

class VTK_MRML_EXPORT vtkMRMLSequenceNode : public vtkMRMLStorableNode
{
Expand Down
6 changes: 6 additions & 0 deletions Modules/CLI/ExecutionModelTour/ExecutionModelTour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
<label>Input image</label>
<channel>input</channel>
</image>
<image type="dynamic-contrast-enhanced">
<longflag>image4d</longflag>
<label>Input 4D Image</label>
<channel>input</channel>
<description><![CDATA[Input 4D Image (txyz)]]></description>
</image>
<image reference="image1">
<longflag>image2</longflag>
<description><![CDATA[An output image]]></description>
Expand Down

0 comments on commit 38e026f

Please sign in to comment.