Skip to main content

HLSVDPRO provides code to fit a model function (sum of lorentzians) to time-domain data via a 'black box' state space approach. This is often used in clinical MRS to remove residual water from time domain signals.

Project description

HLSVDPRO

Overview - Black box fitting of Time Domain Signals

The HLSVDPRO package provides code to fit a model function (sum of lorentzians) to time-domain data via a 'black box' state space approach (see references below). One frequent use for this is by the clinical MRS community for residual water removal from MRS signals in the time domain.

Internally, we use the PROPACK library which contains a set of functions for computing the singular value decomposition (SVD) of large and sparse matrices. The SVD routines are based on the Lanczos bidiagonalization algorithm with partial reorthogonalization (BPRO).

The calculated singular values and column vectors are subsequently processed into lists of parameters that describe the sum of lorentzians that approximate the data based on the paper by Laudadio (see below). Parameters are numpy arrays of: frequencies, damping factors, amplitudes, and phases.

Example:

import hlsvdpro
import numpy as np
import matplotlib.pyplot as plt

data = hlsvdpro.get_testdata()
npts = len(data)
indat = hlsvdpro.TESTDATA   		# this is a built-in dict with test data 
dwell = float(indat['step_size'])
nsv_sought = indat['n_singular_values']

result = hlsvdpro.hlsvd(data, nsv_sought, dwell)

nsv_found, singvals, freq, damp, ampl, phas = result

print("np.allclose(freq, indat['freq0']) = ", np.allclose(freq, np.array(indat['freq0'])) )

fid = hlsvdpro.create_hlsvd_fids(result, npts, dwell, sum_results=True, convert=False)

chop = ((((np.arange(len(fid)) + 1) % 2) * 2) - 1)
dat = data * chop
fit = fid * chop
dat[0] *= 0.5
fit[0] *= 0.5

plt.plot(np.fft.fft(dat).real, color='r') 
plt.plot(np.fft.fft(fit).real, color='b') 
plt.plot(np.fft.fft(dat-fit).real, color='g')
plt.show()

HLSVDPRO Methods

  • hlsvdpro.hlsvdpro(data, nsv_sought, m=None, sparse=True) - the main method for running the hlsvdpro algorithm. It does not require the dwell time of the time domain data, but it also does not convert the results to standard units. It does allow the user to specify the dimensions of the Hankel matrix, and whether a sparse SVD is performed or not.

  • hlsvdpro.hlsvd(data, nsv_sought, dwell_time) - provides backwards compatibility to the API for HLSVDPRO version 1.x. It calls the hlsvdpro() method with default values corresponding to the algorithm used in version 1.x. See docstring for more information on the default values used.

HLSVDPRO Utility Methods

  • hlsvdpro.create_hlsvd_fids(result, npts, dwell, sum_results=False, convert=True) - can be used to create FIDs from the results tuple from either the hlsvd() or the hlsvdpro() methods. It can return either individual FIDs or a sum of all FIDs as a result.

  • hlsvdpro.convert_hlsvd_result(result, dwell) - uses the dwell time to convert the hlsvdpro() result tuple to more standard units. Frequencies convert to [kHz], and damping factors to [ms]. Phases convert to [degrees]. Singular values, amplitudes and row and column matrices are maintained at their same values and output tuple locations. Note - the hlsvd() method automatically calls this internally, so you don't have to convert values if you use that method.

  • hlsvdpro.get_testdata() - returns a numpy array of 1024 complex data points that represents a real world short TE single voxel PRESS data set. This function converts the base64 encoded string saved in the TESTDATA dict into a numpy array for you. Additional information about the data and the known values for fitting it via the hlsvd() method can be retrieved from the TESTDATA dict. See 'Example' for more usage information.

Additional Functionality

As of version 2.0.0, HLSVDPRO also provides access to internal PROPACK SVD functions via the 'propack' module. These have been compiled from PROPACK version 2.1, and include:

  • hlsvdpro.propack.lansvd() - matrix-vector product via user defined Python callback vector/matrix multiplication
  • hlsvdpro.propack.lansvd_irl() - matrix-vector product via user defined Python callback
  • hlsvdpro.propack.lansvd_aprod() - matrix-vector product via fixed internal Fortran call
  • hlsvdpro.propack.lansvd_irl_aprod() - matrix-vector product via fixed internal Fortran call

Technical Overview and References

The PROPACK SVD Fortran code was written by Rasmus Munk Larsen. Teresa Laudadio and Diana Sima adapted it into HLSVDPRO algorithm. Brian J Soher adapted the algorithm for PROPACK v2.1 use and the python wrappers used to access the code.

For complete copyright and license information, see the LICENSE file.

The Python wrapper is compatible with Python 2.7 and 3.x. The binaries that the Python wrapper calls are 64-bit, so this code is not compatible with 32-bit Python.

The state space approach is described in: S.Y. Kung, K.S. Arun and D.V. Bhaskar Rao, J. Opt. Soc. Am. 73, 1799 (1983).

HLSVDPRO version 1.0.x made use of code from PROPACK version 1.x and was implemented based on the paper by: W.W.F. Pijnappel, A. van den Boogaart, R. de Beer, D. van Ormondt, J. Magn. Reson. 97, 122 (1992).

HLSVDPRO version 2.0.0 was adaptated to use PROPACK library version 2.1 to implement the HLSVDPRO algorithm as described in: T. Laudadio, N. Mastronardi L. Vanhamme, P. Van Hecke and S. Van Huffel, "Improved Lanczos algorithms for blackbox MRS data quantitation", Journal of Magnetic Resonance, Volume 157, pages 292-297, 2002.

The Python wrapper used to access the PROPACK library was adapted from the pypropack repository create by Jake van der Plas on Github: https://github.com/jakevdp/pypropack with extensions by Brian J Soher to include the matrix-vector product calculation within the Fortran code.

Acknowlegements and Kudos

We (the HLSVDPRO team) have made some minor modifications to this version of HLSVDPRO. Most significantly, we have updated the PROPACK library to version 2.1, added Makefiles and Python wrappers for both the HLSVDPRO and PROPACK methods. We are very grateful to all of the above scientists for sharing their work and agreeing to release it under a BSD license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

hlsvdpro-2.0.0-py38-none-win_amd64.whl (1.5 MB view details)

Uploaded Python 3.8 Windows x86-64

hlsvdpro-2.0.0-py38-none-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded Python 3.8

hlsvdpro-2.0.0-py38-none-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded Python 3.8 macOS 10.9+ x86-64

hlsvdpro-2.0.0-py37-none-win_amd64.whl (1.5 MB view details)

Uploaded Python 3.7 Windows x86-64

hlsvdpro-2.0.0-py37-none-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded Python 3.7

hlsvdpro-2.0.0-py37-none-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded Python 3.7 macOS 10.9+ x86-64

hlsvdpro-2.0.0-py36-none-win_amd64.whl (1.5 MB view details)

Uploaded Python 3.6 Windows x86-64

hlsvdpro-2.0.0-py36-none-manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded Python 3.6

hlsvdpro-2.0.0-py36-none-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded Python 3.6 macOS 10.9+ x86-64

hlsvdpro-2.0.0-py27-none-win_amd64.whl (1.5 MB view details)

Uploaded Python 2.7 Windows x86-64

hlsvdpro-2.0.0-py27-none-manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded Python 2.7

hlsvdpro-2.0.0-py27-none-macosx_10_9_x86_64.whl (1.3 MB view details)

Uploaded Python 2.7 macOS 10.9+ x86-64

File details

Details for the file hlsvdpro-2.0.0-py38-none-win_amd64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py38-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hlsvdpro-2.0.0-py38-none-win_amd64.whl
Algorithm Hash digest
SHA256 34519b9c7a4748097f2d40925cbae852d487fbfb1eb79830916e64acba3f721b
MD5 1da97c6d429e47945bff9110b55ef637
BLAKE2b-256 86405f594f543837375d7183cda82c6eb79a4b7039cd66c5e975efa2a7b8dc1e

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py38-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py38-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py38-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7189e7e6206005049ecade801cf11b1a647bea6b1c210d28057abd0848e81d46
MD5 1b4185207dea9479ad63139d2d4fe1a5
BLAKE2b-256 5a29bb69bc87140341111737ec03e0ef2a524a6b79000f1ba67d4a4ee5314d4d

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py38-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py38-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py38-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c242a2aaabe8d0cca46c8c87ca311fea141428ebc345720134032a9e50c45530
MD5 fd7edbc1fc8c419056d47aeb38937cf1
BLAKE2b-256 af7725ac60681e5678cd2ceff0d641de69354838f54fcef0becdecec27e3bb4f

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py37-none-win_amd64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py37-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hlsvdpro-2.0.0-py37-none-win_amd64.whl
Algorithm Hash digest
SHA256 1115b9b7d5b0dc0ae4973d843264bad3d3a3a53c7b3e49b739a8104dbe17bef8
MD5 868f9d3a5a346aefaabdef794261e088
BLAKE2b-256 f30b7197677b79abee88e70bfa9c4ef3404bf3a9a9f6baa81a857d274f02377f

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py37-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py37-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py37-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 16ee00a0fd0104da761cfa1fd55515271b8fc00a51d7fb8a3e81505dd064b20c
MD5 3ee476fdcc0f98ae48e165d7e2dd8981
BLAKE2b-256 4b70d1ef6877afe65558f7e04e9d707a769bf25ebfd0616b7ba88fdf6797ec0e

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py37-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py37-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3.7, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py37-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 177fe7ecd2c07f3fb91dac81685c02e9538babc1c08152c810cbed647ea8bc0c
MD5 d32260f7464eded167874f17d072fdeb
BLAKE2b-256 78aef1df89f258bf4abd8face5683ddda567493d474811e352aaefd5db29777d

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py36-none-win_amd64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py36-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hlsvdpro-2.0.0-py36-none-win_amd64.whl
Algorithm Hash digest
SHA256 064a943f6ea797418a7152b476ac262e3ddd515dd7319b36bdd7f8809826e45d
MD5 9c19964dcc7aafa50cf8c19157e36843
BLAKE2b-256 1c59b38a01bf81132cbac14a8c2f52fe3f83cbbd8213bc3451ce7e0f4cdde2d8

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py36-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py36-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py36-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 737f74c1b7a22e9a7815710ae4cc12e208bcbc7324b71330d35239191b3b3a66
MD5 f377348372b45cd5a97d9db5d263688c
BLAKE2b-256 dca862f5d998c8da8c129ca253d53a53be076abe105af9956a3475df863eda3d

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py36-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py36-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3.6, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py36-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c976edcf07e074ffaef96bba4c798f597598995e6da3b2c4d28feeb4cda487e5
MD5 df8bb01b28047fe451b8ea4282cb99e3
BLAKE2b-256 8ab28cf779155a37bfa394f79589610be85f6b86362d5c95dfe815973682e034

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py27-none-win_amd64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py27-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 2.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for hlsvdpro-2.0.0-py27-none-win_amd64.whl
Algorithm Hash digest
SHA256 dadeb1db762dd3cca5025fd0ddb34c896934d19acd2f816da1048a064e244b96
MD5 89a8e9525befdfb947e4dc6c6709c9a3
BLAKE2b-256 2e91bbe694a70ebe4952b38654c38c75b165a0676830778d1fbfe28f2a8950c5

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py27-none-manylinux2014_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py27-none-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 2.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py27-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 095ae59c706639d995fc7d49ad255d3d4a81677b66eb5d60fec2722a9da41e4c
MD5 a45b40e7586891ccb9547e4132351215
BLAKE2b-256 84743daa81f60eb5f5929519975b7e1370194d4a9e3232f057ffc7da0619fec0

See more details on using hashes here.

File details

Details for the file hlsvdpro-2.0.0-py27-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: hlsvdpro-2.0.0-py27-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 2.7, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for hlsvdpro-2.0.0-py27-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b83ab61607455eab66da2cdfb9a77088bd76647715045a48b9f62eb6c4c58205
MD5 ab103b7389045945e3c2e6811b5a35ce
BLAKE2b-256 967d9115e74741766ab1795eab1d2d7655a15cf80a8e43d59b765cac0a1bb8b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page