Porting Matlab Applications to High-Performance C++ Codes: CPU/GPU-Accelerated Spherical Deconvolution of Diffusion MRI Data

  • Javier Garcia BlasEmail author
  • Manuel F. Dolz
  • J. Daniel Garcia
  • Jesus Carretero
  • Alessandro Daducci
  • Yasser Aleman
  • Erick Jorge Canales-Rodriguez
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10048)


In many scientific research fields, Matlab has been established as de facto tool for application design. This approach offers multiple advantages such as rapid deployment prototyping and the use of high performance linear algebra, among others. However, the applications developed are highly dependent of the Matlab runtime, limiting the deployment in heterogeneous platforms. In this paper we present the migration of a Matlab-implemented application to the C++ programming language, allowing the parallelization in GPUs. In particular, we have chosen RUMBA-SD, a spherical deconvolution algorithm, which estimates the intravoxel white-matter fiber orientations from diffusion MRI data. We describe the methodology used along with the tools and libraries leveraged during the translation task of such application. To demonstrate the benefits of the migration process, we perform a series of experiments using different high performance computing heterogeneous platforms and linear algebra libraries. This work aims to be a guide for future developments that are implemented out of Matlab. The results show that the C++ version attains, on average, a speedup of 8\(\times \) over the Matlab one.


Matlab Magnetic resonance imaging Linear algebra 


  1. 1.
    Descoteaux, M., Angelino, E., Fitzgibbons, S., Deriche, R.: Regularized, fast, and robust analytical Q-ball imaging. Magn. Reson. Med. 58, 497–510 (2007)CrossRefGoogle Scholar
  2. 2.
    Aganj, I., Lenglet, C., Sapiro, G., Yacoub, E., Ugurbil, K., Harel, N.: Reconstruction of the orientation distribution function in single- and multiple-shell q-ball imaging within constant solid angle. Magn. Reson. Med. 64, 554–566 (2010)Google Scholar
  3. 3.
  4. 4.
    Canales-Rodríguez, E.J., Melie-García, L., Iturria-Medina, Y.: Mathematical description of q-space in spherical coordinates: exact q-ball imaging. Magn. Reson. Med. 61(6), 1350–1367 (2009)CrossRefGoogle Scholar
  5. 5.
    Canales-Rodríguez, E.J., Daducci, A., Sotiropoulos, S.N., Caruyer, E., Aja-Fernández, S., Radua, J., Mendizabal, J.M.Y., Iturria-Medina, Y., Melie-García, L., Alemán-Gómez, Y., et al.: Spherical deconvolution of multichannel diffusion MRI data with non-Gaussian noise models and spatial regularization. PloS ONE 10(10), e0138910 (2015)CrossRefGoogle Scholar
  6. 6.
    Canales-Rodríguez, E.J., Iturria-Medina, Y., Alemán-Gómez, Y., Melie-García, L.: Deconvolution in diffusion spectrum imaging. NeuroImage 50(1), 136–149 (2010)CrossRefGoogle Scholar
  7. 7.
    Canales-Rodríguez, E.J., Lin, C.P., Iturria-Medina, Y., Yeh, C.H., Cho, K.H., Melie-García, L.: Diffusion orientation transform revisited. NeuroImage 49(2), 1326–1339 (2010)CrossRefGoogle Scholar
  8. 8.
    Daducci, A., Canales-Rodriguez, E.J., Descoteaux, M., Garyfallidis, E., Gur, Y., Lin, Y.C., Mani, M., Merlet, S., Paquette, M., Ramirez-Manzanares, A., Reisert, M., Rodrigues, P.R., Sepehrband, F., Caruyer, E., Choupan, J., Deriche, R., Jacob, M., Menegaz, G., Prckovska, V., Rivera, M., Wiaux, Y., Thiran, J.P.: Quantitative comparison of reconstruction methods for intra-voxel fiber recovery from diffusion MRI. IEEE Trans. Med. Imaging 33, 384–399 (2014)CrossRefGoogle Scholar
  9. 9.
    De Rose, L., Padua, D.: Techniques for the translation of MATLAB programs into Fortran 90. ACM Trans. Program. Lang. Syst. 21(2), 286–323 (1999). doi: 10.1145/316686.316693 CrossRefGoogle Scholar
  10. 10.
    Drakenberg, P., Jacobson, P., Kgstrm, B.: A CONLAB compiler for a distributed memory multicomputer. In: PPSC, pp. 814–821 (1993).
  11. 11.
    Gough, B.: GNU Scientific Library Reference Manual, 3rd edn. Network Theory Ltd., Cambridge (2009)Google Scholar
  12. 12.
    Guennebaud, G., Jacob, B., et al.: Eigen v3 (2010).
  13. 13.
    IBM: Engineering Scientific Subroutine LibraryGoogle Scholar
  14. 14.
    Johnson, H.J., McCormick, M.M., Ibanez, L.: The ITK Software Guide Book 1: Introduction and Development Guidelines, vol. 1. Kitware, Inc., Clifton Park (2015)Google Scholar
  15. 15.
    Kuck and Associates, Inc.: KAP for IBM Fortran and C. Accessed 5 May 2016
  16. 16.
    Malcolm, J., Yalamanchili, P., McClanahan, C., Venugopalakrishnan, V., Patel, K., Melonakos, J.: ArrayFire: a GPU acceleration platform. In: SPIE Defense, Security, and Sensing, p. 84030A. International Society for Optics and Photonics (2012)Google Scholar
  17. 17.
    Markoff, J.: Writing the fastest code, by hand, for fun: a human computer keeps speeding up chips. New York Times 53, 28 (2005)Google Scholar
  18. 18.
    Intel Math Kernel Library (MKL).
  19. 19.
    nVidia: cuBLAS Library User Guide (2012). accedido el 18 de Mayo de 2016
  20. 20.
    NVidia: CUDA Toolkit documentation: NVBLAS (2016).
  21. 21.
    Ozarslan, E., Shepherd, T.M., Vemuri, B.C., Blackband, S.J., Mareci, T.H.: Resolution of complex tissue microarchitecture using the diffusion orientation transform (DOT). Neuroimage 31(3), 1086–1103 (2006)CrossRefGoogle Scholar
  22. 22.
    Quinn, M.J., Malishevsky, A., Seelam, N.: Otter: bridging the gap between MATLAB and ScaLAPACK. In: Proceedings of the Seventh International Symposium on High Performance Distributed Computing 1998, pp. 114–121. IEEE (1998)Google Scholar
  23. 23.
    Rupp, K., Rudolf, F., Weinbub, J.: ViennaCL - a high level linear algebra library for GPUs and multi-core CPUs. In: International Workshop on GPUs and Scientific Applications, pp. 51–56 (2010)Google Scholar
  24. 24.
    Sanderson, C.: Armadillo: an open source C++ linear algebra library for fast prototyping and computationally intensive experiments (2010)Google Scholar
  25. 25.
    The Mathworks, Inc.: C/C++ Compiler Suite. Accessed 5 May 2016
  26. 26.
    The Mathworks, Inc.: Multicore-Capable Code Generation Using OpenMP (2016). accedido el 18 de Mayo de
  27. 27.
    The Mathworks, Inc.: Parallel Computing Toolbox (2016). accedido el 18 de Mayo de
  28. 28.
    Tournier, J.D., Yeh, C.H., Calamante, F., Cho, K.H., Connelly, A., Lin, C.P.: Resolving crossing fibres using constrained spherical deconvolution: validation using diffusion-weighted imaging phantom data. NeuroImage 42, 617–625 (2008)CrossRefGoogle Scholar
  29. 29.
    Tristan-Vega, A., Aja-Fernandez, S., Westin, C.F.: On the blurring of the funk-radon transform in Q-ball imaging. Med. Image Comput. Comput. Assist. Interv. 12(Pt. 2), 415–422 (2009)Google Scholar
  30. 30.
    Tuch, D.S.: Q-ball imaging. Magn. Reson. Med. 52, 1358–1372 (2004)CrossRefGoogle Scholar
  31. 31.
    Wedeen, V.J., Hagmann, P., Tseng, W.Y., Reese, T.G., Weisskoff, R.M.: Mapping complex tissue architecture with diffusion spectrum magnetic resonance imaging. Magn. Reson. Med. 54(6), 11377–11386 (2005)CrossRefGoogle Scholar
  32. 32.
    Whaley, R.C., Dongarra, J.J.: Automatically tuned linear algebra software. In: International Conference on Supercomputing (ICS) (1998)Google Scholar

Copyright information

© Springer International Publishing AG 2016

Authors and Affiliations

  • Javier Garcia Blas
    • 1
    Email author
  • Manuel F. Dolz
    • 1
  • J. Daniel Garcia
    • 1
  • Jesus Carretero
    • 1
  • Alessandro Daducci
    • 2
  • Yasser Aleman
    • 3
    • 4
  • Erick Jorge Canales-Rodriguez
    • 4
    • 5
  1. 1.Dpto. de InformáticaUniversidad Carlos III de MadridLeganésSpain
  2. 2.Signal Processing LabÉcole Polytechnique Fédérale de LausanneLausanneSwitzerland
  3. 3.Instituto de Investigación Sanitaria Gregorio MarañónMadridSpain
  4. 4.Centro de Investigación Biomédica en Red de Salud Mental (CIBERSAM)OviedoSpain
  5. 5.FIDMAG Germanes HospitalàriesBarcelonaSpain

Personalised recommendations