TorchIO: new library for efficient 3D data augmentation and patch-based training

fepegar: <p>Hi all,</p>
<p>I have written <a href="https://github.com/fepegar/torchio" rel="nofollow noopener"><code>torchio</code></a>, a Python package with tools for patch-based training and inference of 3D medical images and multiple transforms for data augmentation typically used in the field. The <a href="https://github.com/fepegar/torchio#transforms" rel="nofollow noopener"><code>torchio.transforms</code></a> API is similar to <code>torchvision.transforms</code>. All the processing is done using PyTorch, NumPy and <a href="https://itk.org/" rel="nofollow noopener">ITK</a>.</p>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicon.ico" class="site-icon" width="32" height="32">
      <a href="https://github.com/fepegar/torchio" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars1.githubusercontent.com/u/12688084?s=400&amp;v=4" class="thumbnail onebox-avatar" width="400" height="400">

<h3><a href="https://github.com/fepegar/torchio" target="_blank" rel="nofollow noopener">fepegar/torchio</a></h3>

<p>Tools for loading, augmenting and writing 3D medical images on PyTorch. - fepegar/torchio</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>The library is still very immature, so contributions and feedback are very welcome <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"> If you have the opportunity to try it out, please let me know what you think and report any issues on GitHub or here.</p>

ptrblck: <p>Thanks for sharing your work here! <img src="https://discuss.pytorch.org/images/emoji/apple/tada.png?v=9" title=":tada:" class="emoji" alt=":tada:"></p>

fepegar: <p>Thank you guys for sharing on Twitter! <a href="https://twitter.com/PyTorch/status/1214229265639559168" rel="nofollow noopener">https://twitter.com/PyTorch/status/1214229265639559168</a></p>

fepegar: <p>As the library has been getting some attention, I wrote a paper: <a href="https://arxiv.org/abs/2003.04696" rel="nofollow noopener">https://arxiv.org/abs/2003.04696</a></p>
<p>I’d be very thankful if you could share it as well <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

soumickmj: <p>Dear <a class="mention" href="/u/fepegar">@fepegar</a>, thanks for creating the nice TorchIO library. I have a question regarding the inference part of the Path-based pipeline. If I have understood it correctly, if we set patch overlap, during add batch of grid aggregator, it crops the patch and put it in. Now I wouldn’t like it to be chopped off, rather, the overlap part of the patch to be averaged. Is there already some way to do it with TorchIO?<br>
If not, do you have some tips for doing so? I would write the code by making it compatible with TorchIO and also share the code with you if you would like to integrate it. Thanks.</p>

fepegar: <p>Hi, <a class="mention" href="/u/soumickmj">@soumickmj</a>. We haven’t implemented this feature yet. I agree it would be useful, so it’d be great if you could contribute with that code!</p>

soumickmj: <p>Hi <a class="mention" href="/u/fepegar">@fepegar</a>, Sure. Do you have any tips regarding where it should be implemented?<br>
I will do the implementation and share it with you. I also wrote a wrapper for the Image class, which works with H5 datasets, can also be used for lazy loading of patches. If you want, I can share it with you.</p>

fepegar: <p>I’ve created <a href="https://github.com/fepegar/torchio/issues/304" rel="nofollow noopener">an issue in the repo</a>. Shall we discuss this there?</p>