3D Augmentation on CBCT image and segmentation maps

Dhruv_Jain: <p>Hi,</p>
<p>I am trying to implement 3d augmentation on CBCT and the same augmentations on the 3d segmentation map. I am using the torchio library.</p>
<blockquote>
<p><a href="https://torchio.readthedocs.io/transforms/preprocessing.html" class="inline-onebox" rel="noopener nofollow ugc">Preprocessing - TorchIO</a></p>
</blockquote>
<pre><code class="lang-auto">spatial = tio.OneOf({
       tio.RandomElasticDeformation(): 0.4,
       tio.RandomAffine( degrees=10,  translation = 5): 0.6
  },
   p=0.80,
  )
</code></pre>
<p>Can someone please help me out to apply the same transformation to the segmentation map too…<br>
Thanks</p>
<p>PS: Hi <a class="mention" href="/u/fepegar">@fepegar</a> , Thanks for a wonderful library for 3d augmentations and preprocessing. Can you please help me out with this?</p>

fepegar: <p>Hi, <a class="mention" href="/u/dhruv_jain">@Dhruv_Jain</a>. As this is not a PyTorch question, you can just ask on the TorchIO GitHub Discussions next time: <a href="https://github.com/fepegar/torchio/discussions" class="inline-onebox" rel="noopener nofollow ugc">fepegar/torchio · Discussions · GitHub</a></p>
<p>There are many examples in the documentation showing how to do that. Here’s a snippet:</p>
<pre data-code-wrap="python"><code class="lang-python">In [1]: import torchio as tio

In [2]: t1 = tio.ScalarImage('colin27_t1_tal_lin.nii.gz')

In [3]: brain = tio.LabelMap('colin27_t1_tal_lin_mask.nii.gz')

In [4]: subject = tio.Subject(t1=t1, seg=brain)

In [5]: transform = tio.RandomAffine()

In [6]: transformed = transform(subject)

In [7]: subject.plot()

In [8]: transformed.plot()
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/4/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c" title="Figure_1"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c_2_666x500.jpeg" alt="Figure_1" data-base62-sha1="9NVZYG1LE3LnpllUeJGMMMVgHog" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/4/4/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/4/4/44b89cf1c3b883ea04513f0c2561c35bfdc21c9c.jpeg 2x" data-dominant-color="C4C4C4"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Figure_1</span><span class="informations">1280×960 122 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/a/8ac1b9a5797e9faad491fffc8acc090a3708cd98.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/8ac1b9a5797e9faad491fffc8acc090a3708cd98" title="Figure_2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/a/8ac1b9a5797e9faad491fffc8acc090a3708cd98_2_666x500.jpeg" alt="Figure_2" data-base62-sha1="jNuWBnDQ1sZQPwHlzvXrcM0DJna" width="666" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/a/8ac1b9a5797e9faad491fffc8acc090a3708cd98_2_666x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/8/a/8ac1b9a5797e9faad491fffc8acc090a3708cd98_2_999x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/8/a/8ac1b9a5797e9faad491fffc8acc090a3708cd98.jpeg 2x" data-dominant-color="C3C3C3"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Figure_2</span><span class="informations">1280×960 119 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>As you see, the same transformation is applied to both images. Linear and nearest neighbor interpolation are used by default for the MRI and the label map, respectively.</p>

Dhruv_Jain: <p>Thanks <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:"> I’ll take care for next time…</p>