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

Hi all,

I have written torchio, 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 torchio.transforms API is similar to torchvision.transforms. All the processing is done using PyTorch, NumPy and ITK.

The library is still very immature, so contributions and feedback are very welcome :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.


Thanks for sharing your work here! :tada:

1 Like

Thank you guys for sharing on Twitter!

As the library has been getting some attention, I wrote a paper:

I’d be very thankful if you could share it as well :slight_smile:

Dear @fepegar, 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?
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.

Hi, @soumickmj. 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!

Hi @fepegar, Sure. Do you have any tips regarding where it should be implemented?
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.

I’ve created an issue in the repo. Shall we discuss this there?