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
Indexing1-based0-based0-based1-based
removeOSfalseTrueFalsefalse
regridfalseTrueFalsefalse

Syntax

mapVBVDpymapVBVDtwixtoolsMRITwixTools.jl
Read datatwix.image()twix.image['']loop over mdb listgetdata(twix.image)
Slice datatwix.image(:,:,1)twix.image[:,:,0]—twix.image[:,:,1]
Squeezetwix.image{''}.squeeze = Truemanual.squeeze = true
Set flag.flagRemoveOS = 1.flagRemoveOS = True.flags['remove_os'].removeOS = true
Headerhdr.MeasYaps (struct)hdr.MeasYaps[tuple]hdr['MeasYaps']hdr.MeasYaps.sKSpace...
Search—search_header_for_keys—search(hdr, terms...)

Feature Support

mapVBVDpymapVBVDtwixtoolsMRITwixTools.jl
Tab completionfirst levelfirst levelfirst levelevery 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

Developer Guide