Import Ranging from MATLAB Atom-Probe-Toolbox .fig
The MATLAB Atom-Probe-Toolbox saves its ranging by drawing each range as a
filled area on a mass spectrum and saving the whole figure as a .fig file.
This CLI walks one or more such figures and writes a PyCCAPT-compatible
<stem>_range.h5 (plus a .csv) next to each input — ready to be loaded
by the calibration tutorials via data_tools.read_range or picked up
automatically as a <dataset>_range.h5 sibling.
Source: pyccapt/calibration/leap_tools/matlab_fig_range.py
What gets extracted
From every range area plot in the figure:
XData(1)/XData(end)→mc_low/mc_upFaceColor(RGB 0..1) →color(#RRGGBB)UserData.chargeState→chargeDisplayName(e.g."56Fe +"or"12C 16O2 +2") →element/isotope/complex/name/raw_comp
The detection rule is structural: a range is any specgraph.areaseries
whose UserData exposes a chargeState field. The toolbox’s
UserData.plotType and UserData.ion fields are MATLAB MCOS opaque
objects and are intentionally not decoded; the same information is
available in plain text from DisplayName.
Usage
Convert a single figure (writes <stem>_range.h5 next to the input):
python -m pyccapt.calibration.leap_tools.matlab_fig_range \
"E:/datasets/A718_08676/Massspectrum.fig"
Walk a folder of datasets, converting every .fig found:
python -m pyccapt.calibration.leap_tools.matlab_fig_range \
"E:/datasets" --recursive
Restrict to a specific filename (e.g. only the “pretty” figures):
python -m pyccapt.calibration.leap_tools.matlab_fig_range \
"E:/datasets" --recursive --pattern "Massspectrum_pretty.fig"
Rename / relocate the output for a single figure so it sits next to your processed dataset:
python -m pyccapt.calibration.leap_tools.matlab_fig_range \
"E:/datasets/A718_08676/Massspectrum.fig" \
--output "E:/datasets/A718_08676/R56_08676_range.h5"
Arguments
pathPath to a single
.figfile or a folder containing them.-r, --recursiveRecurse into subdirectories when
pathis a folder.--patternGlob pattern for figures when
pathis a folder (default*.fig).-o, --outputExplicit output
.h5path. Only valid whenpathis a single.figfile. When omitted, writes<stem>_range.h5next to each input.--no-csvSkip writing the sibling
.csvcompanion.--overwriteOverwrite existing
<stem>_range.h5outputs (default: skip if present).-v, --verbosePrint full Python tracebacks for any figure that fails to convert (default: one-line error).
Limitations
Reads MATLAB
.figfiles saved with the default v5/v6/v7 (binary MAT) format. Figures saved as-v7.3(HDF5-backed) are not yet supported; if you have one, resave it from MATLAB withsaveas(gcf, 'name.fig')orsavefig('name.fig', '-v7')first.volis set to0.0(the toolbox stores0by default too); fill it in from your dataset’s range editor if you need it for concentration calculations.