# Apply a smooth dense deformation

**URL:** <https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117>\
**Category:** Support\
**Tags:** resample, deformation\
**Created:** [April 15, 2020, 1:33am UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117 "2020-04-15T01:33:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![labixin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/labixin/32/1965_2.png) [@labixin](https://discourse.slicer.org/u/labixin)\
**Post date:** [April 15, 2020, 1:33am UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117/1 "2020-04-15T01:33:03Z")

</div>

Hi all,

I need to do the data augmentation used by the 3-D Unet work ([paper link](https://arxiv.org/abs/1606.06650)): “Besides rotation, scaling and gray value augmentation, we apply a smooth dense deformation field on both data and ground truth labels. For this, we sample random vectors from a normal distribution with standard deviation of 4 in a grid with a spacing of 32 voxels in each direction and then apply a B-spline interpolation.”

Can I achieve this with any Slicer module? Hope for some advice. Thanks a lot.

Crayon

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 15, 2020, 1:44pm UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117/2 "2020-04-15T13:44:34Z")

</div>

HI -

Yes, you should be able to just create a grid transform for that. This code might help get you started.

> <https://github.com/Slicer/Slicer/blob/0560b7fffc371cbbea1bfd79586a21de3be9fb0f/Modules/Scripted/DICOMPlugins/DICOMScalarVolumePlugin.py#L580-L622>

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 16, 2020, 3:39pm UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117/3 "2020-04-16T15:39:26Z")

</div>

You may also create a thin-plate spline transform using SlicerIGT extension’s Fiducial Registration Wizard module. You just need to specify two markups fiducial point lists and the module creates a transform that transform each point to a corresponding point in the other list and smoothly interpolates between them. This way, you can very easily create a smoothly changing dense displacement field by just specifying a few displacement vectors.

---

<div class="post-metadata">

**Author:** ![labixin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/labixin/32/1965_2.png) [@labixin](https://discourse.slicer.org/u/labixin)\
**Post date:** [September 18, 2020, 9:16am UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117/4 "2020-09-18T09:16:14Z")

</div>

Thanks a lot. I have done the data augmentation with Fiducial Registration Wizard module following your advice. The deformed images are satisfactory. Now I am preparing the scientific paper. I am not sure how to describe this operation as data augmentation step. Hope for some suggestions. Your help is highly appreciated!

Sincerely,

Crayon

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 18, 2020, 2:43pm UTC](https://discourse.slicer.org/t/apply-a-smooth-dense-deformation/11117/5 "2020-09-18T14:43:58Z")

</div>

If you use SlicerIGT modules then please cite this paper:  
[Ungi T, Lasso A, Fichtinger G. Open-source platforms for navigated image-guided interventions. Med Image Anal. 2016 Oct;33:181-6. doi: 10.1016/j.media.2016.06.011.](https://www.ncbi.nlm.nih.gov/pubmed/27344106)

If possible, please also cite 3D Slicer as described [here](https://slicer.readthedocs.io/en/latest/user_guide/about.html#how-to-cite).

Internally, Fiducial registration wizard module uses VTK’s thin-plate spline transform implementation. Algorithm details are described in this paper: [https://doi.org/10.1016/S0895-6111(02)00091-5](https://doi.org/10.1016/S0895-6111(02)00091-5)
