Skip to main content

pyMapVBVD

PyPI PyPI - Python Version DOI

Python port of the Matlab mapVBVD tool for reading Siemens raw data 'twix' (.dat) files.

Installation

conda install -c conda-forge pymapvbvd or pip install pymapvbvd

Development

Install Pixi, then run pixi install to create the development environment.

pixi run lint
pixi run test
pixi run build

Run the test suite with a specific supported development Python version using pixi run -e py313 test or pixi run -e py314 test.

Use

I have attempted to replicate the syntax of the original matlab code, but there are a few differences due to differing variable types.

This package contains a demo Jupyter notebook 'Demo.ipynb' which can be run on the demo data found in tests/test_data. There is unsuppressed water SVS MRS, from both a 7T VB scanner and a VE Prisma. There is also imaging data (3D GRE and EPI) from the ISMRMRD test dataset.

Run using the following:

import mapvbvd
twixObj = mapvbvd.mapVBVD(filename)

For multi raid files (VD+) twixObj is a list, for single files it is a AttrDict containing data with keys relating to the MDH flags and a header object. The MDH flags present can be retrieved as a list using twixObj.MDH_flags(), whilst the header is found at twixObj.hdr.

Data

Data can be accessed using e.g. for image MDH

data = twixObj.image['']
data = twixObj.image[:,:,:]
data = twixObj.image[0::2,0,:]

To remove singleton dimensions twixObj.image.squeeze = True.

To retrieve the data in an unsorted format (i.e. Col,Cha,NAcq) use twixObj.image.unsorted().

Headers

Header information is contained in a dict twixObj.hdr twixObj.hdr.keys() provides a list of the data containers. Access them manually using e.g. twixObj.hdr['MeasYaps'] or twixObj.hdr.MeasYaps. These objects are in turn a final level of dictionaries. The actual data values can be accessed either manually using tuples of key values e.g.

twixObj.hdr.MeasYaps[('sTXSPEC','asNucleusInfo','0','tNucleus')]

or you can search for keys and values by custom methods.

matching_keys = twixObj.search_header_for_keys(('sTXSPEC', 'asNucleusInfo'))
key_value = twixObj.search_header_for_val('MeasYaps',('sTXSPEC', 'asNucleusInfo', '0', 'tNucleus'))

search_header_for_keys takes the keyword argument regex (default True) to either search via case insensitive regular expressions or via exact matches only. Specify top_lvl to restrict to just some parameter sets.

Other info

Thanks to Mo Shahdloo the latest version now implements OS removal, ramp sample regridding, averaging and line reflection.

Set the appropriate flags to enable these features

twixObj.image.flagRemoveOS = True
twixObj.image.flagRampSampRegrid = True
twixObj.refscanPC.flagIgnoreSeg = True
twixObj.refscanPC.flagDoAverage = True

Some of the auxiliary parts of mapVBVD remain unimplemented. Please feel free to contribute these parts! As this is a port the code is intended to resemble the original matlab code, it is not "good" python code.

Credit where credit is due

This code is a port of Philipp Ehses' original Matlab code. I am incredibly grateful to him for releasing this code to the MR community. There are a number of other names in the original code comments and log, these are: Felix Breuer, Wolf Blecher, Stephen Yutzy, Zhitao Li, Michael VÃlker, Jonas Bause and Chris Mirke.

More recent thanks to Mo Shahdloo and Aaron Hess for edits, and Alex Craven for performance enhancements.

This port is released under the MIT licence and no credit is sought for its use.

Metadata

Release files for pyMapVBVD 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyMapVBVD 0.7.0
File Size Uploaded
pymapvbvd-0.7.0.tar.gz 72.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyMapVBVD 0.7.0
File Interpreter ABI Platform
pymapvbvd-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 101.0 kB

Release files / pymapvbvd-0.7.0.tar.gz

Download URL pymapvbvd-0.7.0.tar.gz
Size 72.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0968e50e334f0a79271e80e65559abd9559772789a810427b7119ef6e961c356
BLAKE2b-256 checksum
How to use checksums
9212835aab5795d0d63958774b83a86eaa0dcbb4c92d92641b18c3a7abdcbb7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pymapvbvd-0.7.0-py3-none-any.whl

Download URL pymapvbvd-0.7.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d93c02376bbafdd87f84b7de1e26b577c73c8ff4e840871efad6ee76140a0c95
BLAKE2b-256 checksum
How to use checksums
7ea9e5556103d03b04dda94c97de85b860494b6cf2220b64bb18bcf0dd7dd473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page