Many groups have developed MRI distortion correction using 3D Slicer, but I’m not sure if they made their source code available - a few examples:
- Phantom study to correct geometric distortion in MRI imaging (Moving image) based on CT imaging (Fixed image)
- http://www.cirsinc.com/wp-content/uploads/2018/12/COMP-Poster-2018-Chelsea-v5.pdf
- https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5539340/ (and thesis)
You can contact the authors to see if they are willing to share their software. Keep us updated about what you ended up achieving (or let us know if you need more help).