Published September 19, 2013 | Version 2017-06-05
Software Open

An efficient C code for diffusion tensor denoising with total generalised variation


Written 2012-2014 by Tuomo Valkonen, University of Graz & University of Cambridge.

This repository includes code for TGV^2 and TV denoising and reconstruction from sparse k-space data. For problems with linear operators, the Chambolle-Pock [3] modified primal dual hybrid gradient method (PDHGM) is used. For problems with non-linear, the non-linear PHDHGM of [5] and the Gauss-Newton method are supported. Optional Bregman iterations may be applied to many problems. The code is parallelised using OpenMP. There is also OpenACC GPU support, but at the moment it is not actively maintained.

The included programs and cases covered are the following.

  • denoise: basic colour or grayscale image denoising.

  • tensorreg: Diffusion tensor denoising per [2]. This solves the optionally positivity-constrained problem

    min_{u >= 0} FID(f-Au) + REG(u)

    for tensor fields u and f. For u, tensors of order 0 (scalar functions), 1 (vector fields), and 2 are supported. A is a pointwise operator, and FID either the L1 fidelity or the squared L2 fidelity. The regulariser REG is one of TGV^2, TD (TGV^1), or TV.

    Small sub-problems in the positivity-constrained case with A!=I are solved with the primal-dual interior point method of [4].

  • ksreg: Sparse reconstruction from K-space data. This solves the problem

    min_u |f-SFu|^2 + REG(u)

    for complex image u, and sparse K-space data f. Here S is the sparse sampling operator and F the (discrete) Fourier transform.

  • ksreg-nl: The same as ksreg, but with individual regularisation of the phase and magnitude of u, and non-linear reconstruction of u from these.


doc/            Documentation, include a user guide to the 
                tensorreg program, and quick developer
                introduction to the C code.

examples/       Multiple use-case examples, and miscellaneous
                Matlab code.

src/            Source code.

matlab/         Auxiliary Matlab code. 
                (Plotting, NIFTI import, ...)
                See README.matlab for information.

mex/            Auxiliary Mex routines for Matlab.
                Necessary for the plotting routine!


GNU make

                Other variants of make may not work.


                Or any other OpenACC compiler for the
                GPU implementation.


                For Fast Fourier Transform.


                Non-uniform Fast Fourier Transform.


To compile the code, follow the following steps

  1. Download install the libtu utility library available from this same Zenodo page.

  2. Copy as

  3. Edit to suit your system and choices.

  4. Run make

Third-party code

This package includes NIFTI code by Jimmy Shen (matlab/NIFTI_code), and Rice distribution code by Ged Ridgway (matlab/rician).


This work is published under GNU GPLv3. See the attached LICENSE.txt.


  1. K. Bredies and K. Kunisch and T. Pock, Total generalised variation, SIAM Journal on Imaging Sciences 3 (2011), 492--526.

  2. T. Valkonen, K. Bredies, and F. Knoll, Total generalised variation in diffusion tensor imaging, SIAM Journal on Imaging Sciences 6 (2013), 487–525.,>

  3. A. Chambolle and T. Pock, A first-order primal-dual algorithm for convex problems with applications to imaging, Journal of Mathematical Imaging and Vision 40 (2011), 120-145.

  4. T. Valkonen, A method for weighted projections to the positive definite cone, Optimization 64 (2015), 2253–2275.,

  5. T. Valkonen, A primal-dual hybrid gradient method for non-linear operators with applications to MRI (2013), Inverse Problems 30 (2014),055012,,


Files (1.2 MB)

Name Size Download all
1.0 MB Preview Download
116.2 kB Preview Download

Additional details

Related works

Is documented by
Journal article: 10.1137/120867172 (DOI)
Journal article: 10.1007/s00607-012-0277-x (DOI)
Journal article: 10.1515/jip-2013-0005 (DOI)


  • Valkonen, Bredies and Knoll, Total generalised variation in diffusion tensor imaging, SIAM Journal on Imaging Sciences 6 (2013), 487–525, doi:10.1137/120867172
  • Valkonen and Liebmann, GPU-accelerated regularisation of large diffusion tensor volumes, Computing 95 (2013), 771–784, doi:10.1007/s00607-012-0277-x, Special issue for ESCO 2012, Pilsen, Czech Republic