# Dillation of a specific label, and pushing other label?

**URL:** https://discourse.slicer.org/t/dillation-of-a-specific-label-and-pushing-other-label/31808
**Category:** Support
**Created:** [September 20, 2023, 3:57pm UTC](https://discourse.slicer.org/t/dillation-of-a-specific-label-and-pushing-other-label/31808 "2023-09-20T15:57:55Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)
#### Post date: [September 26, 2023, 6:48pm UTC](https://discourse.slicer.org/t/dillation-of-a-specific-label-and-pushing-other-label/31808/11 "2023-09-26T18:48:35Z")

</div>

> [@Romain\_Valabregue](#):
>
> The only question I have is about the points format. I guess it should be a python list, of (3D) coordinate but what is the unit ? Should I express those coordinate in the pixel space (integer grid from the original data) or in mm space (ie taking into account the affine of the 3D data.

The points should be in mm space

> [@Romain\_Valabregue](#):
>
> Finally the more unclear part to me is how to finish the job once the Two set of point has been construct. (1) build the nonlinear transform, and 2) applied it to the image. I am not familiar with C++ module, how do I call them from python ? Probably if someone can point me the corresponding python code that Slicer use to implement it I should be able to copy paste the code I need. if it is not to big.  
> Probably, I would also need other example of python script using 3D Slicer tool, so that I understand, which import (lib) I need to have access to those C++ binding (may be not, if the Slicer python code is enough to build a similar function but standalone …)

I looked into the Fiducial Registration Wizard code a bit more, and I think the key function being used is provided by `vtkThinPlateSplineTransform` ([VTK: vtkThinPlateSplineTransform Class Reference](https://vtk.org/doc/nightly/html/classvtkThinPlateSplineTransform.html)). I do pretty much all of my work within the Slicer environment, so I am not very familiar with this, but I believe you can use VTK from python outside of Slicer without any problems ([Getting Started - VTK documentation](https://docs.vtk.org/en/latest/getting_started/index.html)). It looks like you would create a vtkThinPlateSplineTransform, set the source and target landmarks, set the basis to R (because you’re in 3D), and then `Update()` to calculate the transform. I’m sure there are other VTK functions which would allow you to apply that transform to a base image to generate a warped image. This might be the best approach for you if you are looking to set up a pipeline which can run automatically outside of Slicer. However, if it turns out you want to use Slicer functionality, you might also like to be aware that it is possible to access Slicer code without running the full GUI in a few different ways, and looking at this discussion might help orient and get you started: [Using Slicer and Slicer Modules from Command-Line](https://discourse.slicer.org/t/using-slicer-and-slicer-modules-from-command-line/8162)

---

_[View the full topic](https://discourse.slicer.org/t/dillation-of-a-specific-label-and-pushing-other-label/31808)._
