Set input data types

Operating system: ubuntu 16.04 / iOS
Slicer version: 4.6
Expected behavior:
Actual behavior:

Good evening,

I guess my question is an easy or basic issue. I have been working with inputvolumes which are usually .nii extension so far. If I want to create the entry for the layout I am doing it this way:

the volume selectors
self.inputFrame1 = qt.QFrame(self.tfgCollapsibleButton)
self.inputFrame1.setLayout(qt.QHBoxLayout())
self.tfgFormLayout.addWidget(self.inputFrame1)
self.inputSelector1 = qt.QLabel("Input Volume: ", self.inputFrame1)
self.inputFrame1.layout().addWidget(self.inputSelector1)
self.inputSelector1 = slicer.qMRMLNodeComboBox(self.inputFrame1)
self.inputSelector1.nodeTypes = ( ("vtkMRMLScalarVolumeNode"), "" )
self.inputSelector1.addEnabled = False
self.inputSelector1.removeEnabled = False
self.inputSelector1.setMRMLScene( slicer.mrmlScene )
self.inputFrame1.layout().addWidget(self.inputSelector1)

Now I need to set input values as integer, float…I have seen that fields in several modules and extensions (as in the image)different_values
but I have not found the code, neither how to set that fields so after introducing the value I could work with it in my python code. Would you show me where could I find this information or how to set that layout fields?

Thanks in advance!
Regards,
Alba

Hi Alba,

What do you need exactly? Have you taken a look at QRadioButton Class?

Hi Fernando,

I need an integer input (it can be a float) as this one:

so I can use this value in my code after user has introduced it. Is there any other Qt class which allow me to do that?
Sorry I was not clear enough, but I am saving that information too because it can be helpful in the future : )

Thank you!
Regards,
Alba

There are Qt and CTK widgets for this (spinbox or slider). Check out source existing Python modules in Slicer or read Qt and CTK documentation.

Good evening,

Thanks! I am working with them : )

Regards!
Alba

Hi Andras,
Just a simple question but I am stuck and I am unable to identify whats wrong.

Why I am unable to load any volume in the input combo box.
image

I am using designers script for the pyhton module.

I did following in updateGUIFromParameterNode

wasBlocked = self.ui.brainVolume.blockSignals(True)
self.ui.brainVolume.setCurrentNode(self._parameterNode.GetNodeReference("inputbrainVolume"))
self.ui.brainVolume.blockSignals(wasBlocked)

if self._parameterNode.GetNodeReference("inputbrainVolume"):
      self.ui.rasButton.toolTip = "Compute RAS Coordinates from MRI and convert electrode coordinates to RAS coordinates"
      self.ui.rasButton.enabled = True
    else:
      self.ui.rasButton.toolTip = "Select brain volume node"
      self.ui.rasButton.enabled = False

In updateParameterNodeFromGUI(self, caller=None, event=None) I did:

    self._parameterNode.SetNodeReferenceID("inputbrainVolume", self.ui.brainVolume.currentNodeID)

in setup(self):

self.ui.brainVolume.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGUI)

What am I missing?

I also set the nodetype in QT designer view to vtkMRMLScalarVolumeNode

You have forgot to set the MRML scene for the node selector widget. To fix this, in Qt designer’s Signal/Slot editor you can add a connection from the top-level qMRMLWidget’s mrmlSceneChanged(vtkMRMLScene*) signal to the node selector’s setMRMLScene(vtkMRMLScene*) slot.

1 Like

Its fixed. Thanks a lot.

How to do in script this thing.

Regards,
Saima Safdar