# Linear transforms to displacement field

**URL:** https://discourse.itk.org/t/linear-transforms-to-displacement-field/2992
**Category:** Beginner Questions
**Tags:** python
**Created:** [April 22, 2020, 3:08pm UTC](https://discourse.itk.org/t/linear-transforms-to-displacement-field/2992 "2020-04-22T15:08:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alixchcl](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/d6d6ee/32.png) [@alixchcl](https://discourse.itk.org/u/alixchcl)
#### Post date: [April 22, 2020, 3:08pm UTC](https://discourse.itk.org/t/linear-transforms-to-displacement-field/2992/1 "2020-04-22T15:08:33Z")

</div>

Hi!

I would like to create a deformation field from 2 linear transforms, which are defined on different regions of my image.

So, I have two different linear transforms (one for the right hemisphere, and one for the left hemisphere of the brain). I also have 2 masks, corresponding to the two hemispheres. And I would like to create a deformation field where I get the left linear transform applied over the left hemisphere mask, and the right linear transform applied over the right mask.  
I get that this should lead to some discontinuities at the jonction, but I don’t think that this should be a problem for my further calculation.

I am just starting with ITK, so any help will probably be a lot to me,

Thanks in advance !! 🤗

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 22, 2020, 6:27pm UTC](https://discourse.itk.org/t/linear-transforms-to-displacement-field/2992/2 "2020-04-22T18:27:32Z")

</div>

You could [iterate](https://itk.org/ITKExamples/src/Core/Common/IterateRegionWithAccessToIndexWithWriteAccess/Documentation.html) through your desired deformation field image, and for each pixel check whether it belongs to one of the masks, and if so calculate displacement for it using [TransformContinuousIndexToPhysicalPoint and TransformPhysicalPointToIndex from image](https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031/10) and [TransformPoint](https://itk.org/Doxygen/html/classitk_1_1Transform.html#a4e2ff88e9abbf728d7320be5df203de0) from the corresponding linear transform. Pay attention to the direction of transform (moving to registered). Good luck!
