MRITwixTools.jl
Native Julia package for reading Siemens MRI raw data (twix .dat files).
A port of the Python packages twixtools and pymapVBVD, and the Matlab package mapVBVD, supporting both VB and VD/VE/XA software versions.
Installation
using Pkg
Pkg.add("MRITwixTools")Or in development mode:
Pkg.develop("MRITwixTools")Quick Start
using MRITwixTools
# Read a twix file (returns raw data by default — no processing)
twixObj = read_twix("meas_MID00305.dat")
# For multi-raid files (VD/VE/XA), twixObj is a Vector{TwixObj}
# For single-raid files (VB), it is a single TwixObj
# Read image data
data = getdata(twixObj.image)
# Or with slicing (1-based Julia indexing)
data = twixObj.image[1:128, :, :]
# Check available scan types
MDH_flags(twixObj) # e.g. ["image", "noise", "refscan"]Comparison with Other Twix Readers
Several tools exist for reading Siemens twix (.dat) files:
- mapVBVD — the original MATLAB tool by Philipp Ehses
- pymapVBVD — Python port by Will Clarke
- twixtools — Python reader/writer with low-level mdb access by Philipp Ehses
Defaults
| mapVBVD (MATLAB) | pymapVBVD (Python) | twixtools (Python) | MRITwixTools.jl | |
|---|---|---|---|---|
| Indexing | 1-based | 0-based | 0-based | 1-based |
removeOS | false | True | False | false |
regrid | false | True | False | false |
Syntax
| mapVBVD | pymapVBVD | twixtools | MRITwixTools.jl | |
|---|---|---|---|---|
| Read data | twix.image() | twix.image[''] | loop over mdb list | getdata(twix.image) |
| Slice data | twix.image(:,:,1) | twix.image[:,:,0] | — | twix.image[:,:,1] |
| Squeeze | twix.image{''} | .squeeze = True | manual | .squeeze = true |
| Set flag | .flagRemoveOS = 1 | .flagRemoveOS = True | .flags['remove_os'] | .removeOS = true |
| Header | hdr.MeasYaps (struct) | hdr.MeasYaps[tuple] | hdr['MeasYaps'] | hdr.MeasYaps.sKSpace... |
| Search | — | search_header_for_keys | — | search(hdr, terms...) |
Feature Support
| mapVBVD | pymapVBVD | twixtools | MRITwixTools.jl | |
|---|---|---|---|---|
| Tab completion | first level | first level | first level | every level |
| Write support | — | — | ✓ | — |
| Low-level mdb access | — | — | ✓ | — |
| Multi-raid (VD/VE/XA) | ✓ | ✓ | ✓ | ✓ |
Package Overview
read_twix("file.dat")
│
├── TwixObj
│ ├── .hdr → TwixHdr (nested header tree with tab-completion)
│ ├── .image → RawData (image acquisitions)
│ ├── .noise → RawData (noise adjustments)
│ ├── .refscan → RawData (GRAPPA reference lines)
│ ├── ... → RawData (other scan types)
│ └── .syncdata → Vector{Vector{UInt8}} (raw MDH_SYNCDATA payloads,
│ only if present in file)
│
└── Vector{TwixObj} (for multi-raid VD/VE/XA files)User Guide
- Installation — Prerequisites and install methods
- Header Access — Navigating header trees with tab-completion
- Data Access — Reading, slicing, and processing scan data
- SYNCDATA Payloads — Accessing PMU / physio / custom binary blobs
- API Reference — Complete exported function listing
Developer Guide
- Contributing — Development setup and PR guidelines
- Architecture — Codebase walkthrough and design notes
- Tab-Completion Internals — How deep REPL completion works
- Internal API — Non-exported functions reference