Wait for cli command MatLabBridge

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

Wait for cli command MatLabBridge

lui8errador
This post has NOT been accepted by the mailing list yet.
Hello all,

I'm trying to run a matlab module (with matlab bridge) in my module Python. My problem is that I need the output of the matlab module to continue my process in python. I tried to use the IsBusy() method, also the getStatusString as it is explained here: http://slicer-devel.65872.n3.nabble.com/Regarding-batch-processing-of-data-using-python-evalpython-execpython-td2328846.html

My problem is that when I use state.IsBusy() or state.GetStatusString != 'Completed', 3DSlicer stops and I cannot continue. Does anyone can take a look on the code? The navigation module is my matlab module that has a linear transform as output.

    T = slicer.vtkMRMLLinearTransformNode()
    T.SetName('T')
    slicer.mrmlScene.AddNode(T)
    fidNode=slicer.vtkMRMLMarkupsFiducialNode()
    slicer.mrmlScene.AddNode(fidNode)
    displayNode = slicer.vtkMRMLMarkupsDisplayNode()
    slicer.mrmlScene.AddNode(displayNode)
    fidNode.SetAndObserveDisplayNodeID(displayNode.GetID())

    parameters={};
    parameters['transform2']=T
    tool_pos = slicer.modules.navigation
    state = slicer.cli.run(tool_pos, None, parameters)

    while state.IsBusy(): #If I don't make this loop the matrix is not updated
      print state.GetStatusString()

    fst_coor = T.GetMatrixTransformToParent().GetElement(0,3)     # Is 0 because it is not updated
    snd_coor = T.GetMatrixTransformToParent().GetElement(1,3)   # Is 0 because it is not updated
    trd_coor = T.GetMatrixTransformToParent().GetElement(2,3)     # Is 0 because it is not updated

    fidNode.AddFiducial(fst_coor,snd_coor,trd_coor)