Can I use plastimatch within python?

598 views
Skip to first unread message

lfra...@ucsc.edu

unread,
Oct 29, 2015, 4:24:24 PM10/29/15
to Plastimatch
...

Paolo Zaffino

unread,
Oct 30, 2015, 6:27:58 AM10/30/15
to plast...@googlegroups.com
Hi,
it is possible to execute registrations by using Plastimatch engine via the Python shell embedded in 3D Slicer.
You have to install the SlicerRT module (it's really easy, just to click "install" into the Slicer Extension Manager).
After that, assuming that you had successfully installed SlicerRT and that you loaded two images called "fixed_img.mha" and "mov_img.mha", you can try to execute this piece of code:

import vtkSlicerPlastimatchPyModuleLogicPython
reg=vtkSlicerPlastimatchPyModuleLogicPython.vtkPlmpyRegistration()
reg.SetMRMLScene(slicer.mrmlScene)

moving="mov_img"
fixed="fixed_img"
reg.SetFixedImageID(getNode(fixed).GetID())
reg.SetMovingImageID(getNode(moving).GetID())

output=slicer.vtkMRMLScalarVolumeNode()
slicer.mrmlScene.AddNode(output)
displayNode=slicer.vtkMRMLScalarVolumeDisplayNode()
slicer.mrmlScene.AddNode(displayNode)
reg.SetOutputVolumeID(output.GetID())

par="[STAGE]\nxform=bspline\noptim=lbfgsb\nimpl=plastimatch\nmetric=mse\nmax_its=100\nconvergence_tol=5\ngrad_tol=1.5\nres=22 1\ngrid_spac=40 40 40"
reg.SetRegistrationParameters(par)

reg.RunRegistration()

Obviously you must redefine the "par" string...it's just an example!
If Slicer freezes don't worry, it's busy to execute Plastimatch registration.

HTH.
Best.
Paolo


On 29/10/2015 21:24, lfra...@ucsc.edu wrote:
... --
You received this message because you are subscribed to the Google Groups "Plastimatch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plastimatch...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sharp, Gregory C.

unread,
Oct 30, 2015, 8:56:36 AM10/30/15
to plast...@googlegroups.com

Paolo, is this possible outside of 3D Slicer?

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Paolo Zaffino

unread,
Oct 30, 2015, 11:54:59 AM10/30/15
to plast...@googlegroups.com
Yes, it is possible.
Some time ago I wrote a very basic wrapper that offers the possibility to execute Plastimatch from Python.
The code is stored into the folder extra/python/pypla (http://forge.abcd.harvard.edu/gf/project/plastimatch/scmsvn/?action=browse&path=%2Fplastimatch%2Ftrunk%2Fextra%2Fpython%2Fpypla%2F).
The main file is "plastimatch.py" that must be copied into a folder belonging to the python path.
In "pypla_test.py" there are some examples.

Note that in this case Plastimatch is not invoked as a library but only "hiddenly" executed as a shell command.

If some problem raises (also due to a changed way to call an executable) I am here to help to fix it.

Best.
Paolo
Reply all
Reply to author
Forward
0 new messages