Need to convert vtkMRMLScalarVolume to Numpy Array

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Need to convert vtkMRMLScalarVolume to Numpy Array

Abubakar Siddique
This post has NOT been accepted by the mailing list yet.
I am using slicer module in my own module to get bias corrected volume. The following function is working correctly.

def biascorrection(volumeNode1):
  parameters = {}
  parameters["inputImageName"] = volumeNode1.GetID()
  outModel = slicer.vtkMRMLScalarVolumeNode()
  slicer.mrmlScene.AddNode(outModel)
  parameters["outputImageName"] = outModel.GetID()
  biascorrect = slicer.modules.n4itkbiasfieldcorrection
  return (slicer.cli.run(biascorrect, None, parameters))

Vol1_biasCorrect = biascorrection(nodet1)

Output node is (vtkCommonCorePython.vtkMRMLCommandLineModuleNode)0x7fc11452a808. To get numpy array of this vtk node, I have been used the following code:

Vol1_biasCorrectNode = slicer.util.getNode('Volume')
Vol1_biasCorrect_array = slicer.util.array(Vol1_biasCorrectNode.GetID())

The following error appears:
File "/home/siddique/Slicer-4.6.2-linux-amd64/bin/Python/slicer/util.py", line 583, in array
    shape = list(n.GetImageData().GetDimensions())
AttributeError: 'NoneType' object has no attribute 'GetDimensions'

As output volume is created as vtkMRMLScalarVolumeNode(),  I think this volume should be converted to numpy array. Please help me to get the numpy array of bias corrected volume.
.............
Best Regards,
Abubakar Siddique
PhD Student and Research Assistant
Department of Electrical and Computer Engineering
Old Dominion University (ODU)
Norfolk, VA 23529
Cell# 5168514137
ODU mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Need to convert vtkMRMLScalarVolume to Numpy Array

Abubakar Siddique
I am using slicer module in my own module to get bias corrected volume. The following function is working correctly.

def biascorrection(volumeNode1):
  parameters = {}
  parameters["inputImageName"] = volumeNode1.GetID()
  outModel = slicer.vtkMRMLScalarVolumeNode()
  slicer.mrmlScene.AddNode(outModel)
  parameters["outputImageName"] = outModel.GetID()
  biascorrect = slicer.modules.n4itkbiasfieldcorrection
  return (slicer.cli.run(biascorrect, None, parameters))

Vol1_biasCorrect = biascorrection(nodet1)

Output node is (vtkCommonCorePython.vtkMRMLCommandLineModuleNode)0x7fc11452a808. To get numpy array of this vtk node, I have been used the following code:

Vol1_biasCorrectNode = slicer.util.getNode('Volume')
Vol1_biasCorrect_array = slicer.util.array(Vol1_biasCorrectNode.GetID())

The following error appears:
File "/home/siddique/Slicer-4.6.2-linux-amd64/bin/Python/slicer/util.py", line 583, in array
    shape = list(n.GetImageData().GetDimensions())
AttributeError: 'NoneType' object has no attribute 'GetDimensions'

As output volume is created as vtkMRMLScalarVolumeNode(),  I think this volume should be converted to numpy array. Please help me to get the numpy array of bias corrected volume.
.............
Best Regards,
Abubakar Siddique
PhD Student and Research Assistant
Department of Electrical and Computer Engineering
Old Dominion University (ODU)
Norfolk, VA 23529
Cell# 5168514137
ODU mail: [hidden email]



View this message in context: Need to convert vtkMRMLScalarVolume to Numpy Array
Sent from the slicer-devel mailing list archive at Nabble.com.

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Need to convert vtkMRMLScalarVolume to Numpy Array

lasso2

We moved discussions to http://discourse.slicer.org. Please post this question there, in the Development category. Thank you,

Andras

 

 

From: slicer-devel [mailto:[hidden email]] On Behalf Of Abubakar Siddique
Sent: Friday, April 28, 2017 4:41 PM
To: SPL Slicer Devel <[hidden email]>
Subject: [slicer-devel] Need to convert vtkMRMLScalarVolume to Numpy Array

 

I am using slicer module in my own module to get bias corrected volume. The following function is working correctly.


def biascorrection(volumeNode1):
  parameters = {}
  parameters["inputImageName"] = volumeNode1.GetID()
  outModel = slicer.vtkMRMLScalarVolumeNode()
  slicer.mrmlScene.AddNode(outModel)
  parameters["outputImageName"] = outModel.GetID()
  biascorrect = slicer.modules.n4itkbiasfieldcorrection
  return (slicer.cli.run(biascorrect, None, parameters))

Vol1_biasCorrect = biascorrection(nodet1)

Output node is (vtkCommonCorePython.vtkMRMLCommandLineModuleNode)0x7fc11452a808. To get numpy array of this vtk node, I have been used the following code:

Vol1_biasCorrectNode = slicer.util.getNode('Volume')
Vol1_biasCorrect_array = slicer.util.array(Vol1_biasCorrectNode.GetID())

The following error appears:
File "/home/siddique/Slicer-4.6.2-linux-amd64/bin/Python/slicer/util.py", line 583, in array
    shape = list(n.GetImageData().GetDimensions())
AttributeError: 'NoneType' object has no attribute 'GetDimensions'

As output volume is created as vtkMRMLScalarVolumeNode(),  I think this volume should be converted to numpy array. Please help me to get the numpy array of bias corrected volume.

.............

Best Regards,
Abubakar Siddique
PhD Student and Research Assistant
Department of Electrical and Computer Engineering
Old Dominion University (ODU)
Norfolk, VA 23529
Cell# 5168514137
ODU mail: [hidden email]

 


View this message in context: Need to convert vtkMRMLScalarVolume to Numpy Array
Sent from the slicer-devel mailing list archive at Nabble.com.


_______________________________________________
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