Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
open mat files

A MAT file (.mat) is MATLAB’s workspace container: named variables, arrays, and (in later versions) objects, written by save and read by load. This page is how you open one — in MATLAB, in Python, or in GNU Octave — without dumping a 10 GB cube into RAM. It is not a NIfTI ↔ DICOM conversion. It is not the HDF5 format explainer. It is not a PYCAD product.

If you meant HDF / HDF5 as a containerHDF file format. If you meant DICOM → NIfTIhow to convert DICOM to NIfTI. If you meant VTK / ParaView datasetsVTK data format. If you meant how to read a DICOMhow to read DICOM files.

v7.3 .mat files are HDF5 under the hood. That does not make this page 390. 390 is the container. This page is the MATLAB workspace you are trying to unpack.

What is in the file

Level 4 is the old format. Level 5 is the usual default through MATLAB 7.2. v7.3 (R2006b onward, save -v7.3) switched the payload to HDF5 so a variable could be larger than 2 GB. None of them is a CSV. Variable names, types, and array shape travel with the numbers — that is why a colleague can load the file and keep working.

The on-disk spec is MathWorks’ document if you need bytes. You do not need it to open the file.

In MATLAB: do not load the whole cube

Double-clicking a small .mat dumps every variable into the workspace. That is fine for a 20 MB script output. It is how you run out of RAM on a research MRI or a long simulation.

Use a matfile object (R2011b+). It lets you list what is inside and pull one variable — or a slice of one array — without mapping the rest.

m = matfile('large_dataset.mat');
whos('-file', 'large_dataset.mat');
patientData = m.patientInfo;
% one slab of a 3-D array, if you know the size:
% slab = m.volume(1:64, 1:64, 10);

whos -file is the inventory. m.patientInfo is a property-style read. Write access needs matfile(..., 'Writable', true) and is easy to get wrong on a shared file — prefer a new file if you are not sure.

In Python: SciPy, then h5py for v7.3

You do not need a MATLAB license. scipy.io.loadmat turns a Level 4 / Level 5 file into a dict: MATLAB names as keys, NumPy arrays as values.

from scipy.io import loadmat

mat_data = loadmat('sensor_data.mat', squeeze_me=True)
time = mat_data['time_vector']
temperature = mat_data['temp_readings']
print(time.shape, temperature.shape)

MATLAB treats a scalar as a 1×1 matrix, so without squeeze_me=True a number arrives as [[5]]. Structs and cell arrays become nested object arrays; walk them, do not assume a flat dict of floats.

v7.3 needs h5py. loadmat will use it if it is installed; if you get a “please install h5py” error, that is the fix (pip install h5py), not a corrupt file. You can also open the same file as HDF5 and walk groups — that is the 390 skill, pointed, not copied.

import h5py

with h5py.File('large_v73.mat', 'r') as f:
    print(list(f.keys()))
    # MATLAB v7.3 stores arrays as HDF5 datasets; a slice is a slice
    # data = f['volume'][:64, :64, 10]

In GNU Octave

GNU Octave is the free MATLAB-shaped environment. load / whos / save work the way you expect for ordinary arrays. Toolboxes and newer MATLAB objects are the usual gaps — not the basic workspace dump.

load('experiment_data.mat');
whos
disp(size(my_matrix));

Which tool

Tool Use it when Do not use it when
MATLAB + matfile You already have a license, or the file holds MATLAB objects SciPy will mangle You only needed one array and you do not want to pay for the IDE
Python (scipy.io / h5py) The next step is a NumPy / ML pipeline The file is a thicket of custom MATLAB classes
GNU Octave You want a MATLAB-like GUI and a free load You need a toolbox Octave does not have
HDFView / h5ls A v7.3 file, and you only need to see the tree A Level 4 / 5 file (not HDF5)

What this page is not

  • Not 390. HDF5 is the container under v7.3, and the format explainer already exists.
  • Not 685. DICOM / NIfTI / STL conversion is a different job. A .mat volume is not a DICOM series.
  • Not 6058. Reading a .dcm is its own how-to.
  • Not a PYCAD MAT product. Outrank stills and the homepage-as-CTA are gone. The three snippets stayed.

If a MATLAB cube has to sit next to a DICOM study in a clinic app, that is the imaging piece. Case studies.

Keep Reading

Related Articles

Explore the full DICOM HubAll services, tools, and guides on this topic — in one place.

Visit Hub →

We build custom medical imaging platforms — advanced DICOM viewers, AI segmentation, and the clinical systems around them.

Get in Touch

Copyright © 2026 PYCAD. All Rights Reserved.