Re: Query regarding segmentation module

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Query regarding segmentation module

lasso2

I’ve added a new ScriptedSegmentEditorEffect template to the Extension Wizard (available in tomorrow’s nightly build). This template can be used for creating new effects for Segment Editor module in Python (using SimpleITK, numpy, VTK, etc).

 

Andras

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 19, 2017 6:09
To: Andras Lasso <[hidden email]>
Subject: RE: Query regarding segmentation module

 

I will be going to implement my own algorithm in  python.

Also, how can I register the existing modules like fast marching effect?

 

On 18-Mar-2017 8:25 PM, "Andras Lasso" <[hidden email]> wrote:

To speed up surface generation several times faster, turn off smoothing (it's one of the parameters of labelmap to closed surface conversion rule, set it to 0). Multi-volume rendering will be available in VTK in about a year, we can update segmentation display to use volume rendering then.

 

You have to register your custom editor effects with the segment editor effects factory and then they will show up in the editor widget automatically. Do you implement your effects in Python or C++?

 

Andras

 

 

 

Thanks Andras, I got it working.

 

Creating surface of segmented labels and then displaying in 3d view is taking time. Instead of creating surface, can I use volume rendering to display segmented parts?

 

And also how can I add more effects(segment algorithms) in segment editor ?

 

On 17-Mar-2017 2:00 AM, "Andras Lasso" <[hidden email]> wrote:

 

Import segmentation classes before you are trying to access them:

 

import vtkSegmentationCorePython as vtkSegmentationCore

 

Andras

 

 

 

While using latest nightly version, getting few other errors.

`    currentSegmentationNode.GetSegmentation().GetSegmentIDs(segmentIDs)
AttributeError: 'vtkCommonCorePython.vtkObject' object has no attribute 'GetSegmentIDs'`

`    addedSegmentID = currentSegmentationNode.GetSegmentation().AddEmptySegment()
AttributeError: 'vtkCommonCorePython.vtkObject' object has no attribute 'AddEmptySegment'`

 

I was not getting error in stable version.

 

On 16-Mar-2017 1:59 AM, "Andras Lasso" <[hidden email]> wrote:

Use latest nightly version of Slicer.

 

Andras

 

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 15, 2017 16:18
To: Andras Lasso <[hidden email]>
Subject: RE: Query regarding segmentation module

 

Getting error 

`    l=slicer.modules.segmentations.logic().ExportSegmentsToLabelmapNode(getNode('Segmentation'),None, getNode('Labelmap'), getNode('Reference'))
AttributeError: 'vtkCommonCorePython.vtkSlicerSegmentationsModuleLo' object has no attribute 'ExportSegmentsToLabelmapNode'

 

On 15-Mar-2017 11:37 PM, "Andras Lasso" <[hidden email]> wrote:

1

 

slicer.mrmlScene.CreateNodeByClass('vtkMRMLLabelMapVolumeNode')

 

2

l=slicer.modules.segmentations.logic().ExportSegmentsToLabelmapNode(getNode('Segmentation'),None, getNode('Labelmap'), getNode('Reference'))

 

Andras

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 15, 2017 13:29
To: Andras Lasso <[hidden email]>
Subject: RE: Query regarding segmentation module

 

Sorry for troubling you again and again.

The module is segmenting perfectly now. I am having issue while saving segmented data.

1)  How can I rewrite below C code in python slicelet. The code is the part of import/export widget.

vtkSmartPointer<vtkMRMLNode> newNode = vtkSmartPointer<vtkMRMLNode>::Take( currentSegmentationNode->GetScene()->CreateNodeByClass("vtkMRMLLabelMapVolumeNode"));

 

​2) I want to save a single segmented node with labeled segments. Such that, whenever I import the segment next time I get the segmented nodes. Can I use the some existing widget for it ?​

 

On 14-Mar-2017 10:29 PM, "Andras Lasso" <[hidden email]> wrote:

If you don’t have mainWindow then your don’t have any module widgets or frame where they would be displayed. You need to create your GUI from reusable widgets. Module widgets are not meant to be reused.

 

Andras

 

From: [hidden email]
Sent: Tuesday, March 14, 2017 12:38 PM
To: [hidden email]
Subject: RE: Query regarding segmentation module

 

As I am working with Slicelet, 
`moduleWidget = slicer.util.mainWindow().moduleSelector().selectModule('SegmentEditor')`
gives error 
`AttributeError: 'NoneType' object has no attribute 'moduleSelector'`



I want to clone the line 
` qSlicerAbstractModuleWidget* moduleWidget = qSlicerSubjectHierarchyAbstractPlugin::switchToModule("SegmentEditor");`
from 
`
https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/qSlicerSegmentationsModuleWidget.cxx`

The above code switches the existing GUI to Segment Editor Widget. I want the same functionality, as I am trying to clone the `Segmentations` module in slicelet as of now.

 

On 14-Mar-2017 8:46 PM, "Andras Lasso" <[hidden email]> wrote:

Ok, in Python connects qt to Python method calls. To connect VTK to Pyhton method calls, use AddObserver.

 

Andras

 

From: [hidden email]
Sent: Tuesday, March 14, 2017 10:19 AM
To: [hidden email]
Subject: RE: Query regarding segmentation module

 


1) I am working with slicelet. I am trying to clone ` qSlicerAbstractModuleWidget* moduleWidget = qSlicerSubjectHierarchyAbstractPlugin::switchToModule("SegmentEditor");` in python.

 

 

2) Got that. How can I do qvtkConnect and qvtkReconnect in python ?

 

On 14-Mar-2017 7:29 PM, "Andras Lasso" <[hidden email]> wrote:

1. Switch module:

mainWindow = slicer.util.mainWindow()

mainWindow.moduleSelector().selectModule('Segmentations')

 

2

Connect: between Qt objects

qvtkConnect: between VTK and Qt objects

qvtkReconnect: between VTK and Qt objects, replaces previous connection

 

Andras

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 14, 2017 9:51
To: Andras Lasso <
[hidden email]>
Subject: RE: Query regarding segmentation module

 

Thanks a lot for helping me. 


1) I am getting below error while trying to switch Module. What may be the issue ? Can you please help me with this?

 

code :
    moduleWidget = slicer.qSlicerSubjectHierarchyAbstractPlugin.switchToModule('SegmentEditor')

Error:
`moduleWidget = slicer.qSlicerSubjectHierarchyAbstractPlugin.switchToModule('SegmentEditor')
ValueError: slot switchToModule(QString moduleName) -> qSlicerAbstractModuleWidget requires qSlicerSubjectHierarchyAbstractPlugin instance as first argument, got str
`

2) What is the difference between connect, qvtkConnect and qvtkReconnect ?

 

On 13-Mar-2017 6:08 PM, "Andras Lasso" <[hidden email]> wrote:

Search for “connect” in all .py files in the Slicer source code.

 

Andras

 

From: [hidden email]
Sent: Monday, March 13, 2017 6:20 AM
To: [hidden email]
Subject: RE: Query regarding segmentation module

 

Thanks for the help.

I am working on cloning the `segmentation` module. Can you please tell how can I use `qvtkReconnect` functionality in python ?

 

On 12-Mar-2017 9:25 PM, "Mukesh Gupta" <[hidden email]> wrote:

​I now used the `getattr(slicer.modules, "segmentations").widgetRepresentation()` to get the `Segmentation` module in my slicer. But the `Add Segment` button disabled this way, even after creating new active segment. What may be the reason ? Is I am going wrong way ? 

 

 

    mainWidget = qt.QWidget()
    mainWidget.objectName = "qSlicerAppMainWindow" 
    vlayout = qt.QVBoxLayout()
    mainWidget.setLayout(vlayout)

    layoutWidget = slicer.qMRMLLayoutWidget() 
    layoutManager = slicer.qSlicerLayoutManager() 
    layoutManager.setMRMLScene(slicer.mrmlScene) 
    layoutManager.setScriptedDisplayableManagerDirectory(slicer.app.slicerHome + "/bin/Python/mrmlDisplayableManager") 
    layoutWidget.setLayoutManager(layoutManager) 
    slicer.app.setLayoutManager(layoutManager) 
    layoutWidget.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView) 
    vlayout.addWidget(layoutWidget)
hlayout = qt.QHBoxLayout()
    vlayout.addLayout(hlayout)

    self.addDataButton = qt.QPushButton("Add Data")
    hlayout.addWidget(self.addDataButton)
    self.addDataButton.connect("clicked()",slicer.app.ioManager().openAddDataDialog)

    loadDataButton = qt.QPushButton("Load Data")
    hlayout.addWidget(loadDataButton)
    loadDataButton.connect('clicked()', slicer.util.openAddVolumeDialog)

    saveDataButton = qt.QPushButton("Save Data")
    hlayout.addWidget(saveDataButton)
    saveDataButton.connect('clicked()', slicer.util.openSaveDataDialog)

    moduleSelector = slicer.qSlicerModuleSelectorToolBar()
    moduleSelector.setModuleManager(slicer.app.moduleManager())
    hlayout.addWidget(moduleSelector)
    moduleSelector.connect('moduleSelected(QString)', onModuleSelected)

    tabWidget = qt.QTabWidget()
    tabWidget.addTab(getattr(slicer.modules, "segmentations").widgetRepresentation(), "Segmentations")
    vlayout.addWidget(tabWidget)
self.parent = qt.QFrame()
    self.parent.setLayout( qt.QVBoxLayout() )
self.parent.layout().addWidget(mainWidget)

    if widgetClass:
      self.widget = widgetClass(self.parent)
      self.widget.setup()
    self.parent.show()

 

On 12-Mar-2017 10:46 AM, "Mukesh Gupta" <[hidden email]> wrote:

Can't I directly use `segmentationWidget =slicer.qSlicerSegmentationModuleWidget` in my slicelet GUI ? I am getting error this way. `AtrributeError: 'module' object has no attribute 'qSlicerSegmentationsModulrWidget'`

 

On 12-Mar-2017 1:42 AM, "Andras Lasso" <[hidden email]> wrote:

There is no simple example, but you can find the source code of the complete widget here:

https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/qSlicerSegmentationsModuleWidget.cxx

 

Andras

 

From: [hidden email]
Sent: Saturday, March 11, 2017 2:41 PM
To: [hidden email]
Subject: RE: Query regarding segmentation module

 

Can you please show some sample code. I am not much experienced. Trying to learn stuff. Can you please just made a simple GUI with only one working widget from `segmentation` widget ?

 

On 09-Mar-2017 9:11 PM, "Andras Lasso" <[hidden email]> wrote:

If you want to show the same widgets as in the Segmentations module then you have to place the same widgets into your module GUI. See the exact layout and what widgets were used and how in this file:

https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/Resources/UI/qSlicerSegmentationsModule.ui

 

Andras

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 9, 2017 9:08
To: Andras Lasso <
[hidden email]>
Subject: RE: Query regarding segmentation module

 

Can I use `Segmentations` module (loadable module) in the slicelet like other regular Qt widget ? If yes, Can you please give sample code to incorporate whole `Segmentations` module( different from segment editor module) in slicelet ?

 

On 09-Mar-2017 5:45 PM, "Andras Lasso" <[hidden email]> wrote:

You can insert the segment editor widget into a slicelet like any other regular Qt widget. Full source code of Slicer is available here: https://github.com/Slicer/Slicer/

 

Andras

 

From: Mukesh Gupta [mailto:[hidden email]]
Sent: March 9, 2017 4:19
To: Andras Lasso <
[hidden email]>
Subject: Query regarding segmentation module

 

Hello Andras,

I am building a module similar to `Segmentation`. I need some help regarding that.

1) Is the slicelet version available for `Segmentation` module?

2) Is the code publicly available ? I need to take reference from there. It will help a lot if you can point me to the code.


_______________________________________________
slicer-devel mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-devel
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/Nightly/Developers/FAQ