smappy HDF5

File › Save · version 1

Write the current table, its history and its ROIs.

What it does

Writes the localizations to an HDF5 file (.hdf5 or .h5), together with the record of what was done to them, so that the file can be opened again here – by File > Open or Load from path – and still says how it was made. HDF5 is an open format; any language can read the attributes (in Python with h5py, in MATLAB with h5read).

It is the only format this program writes localizations in. Saving is also File > Save and File > Save as.

How it works

1. The table. Every attribute of the current table is written as it is – or those ticked under attributes – one dataset per attribute under /locs, with its own type, compressed. It is the single localizations: the merged blinks – merge blinks, also called grouping or linking, combines the localizations in consecutive frames that come from one blinking event into one – are made again when the file is opened. If blinks have been merged, group_id and n_in_group are among the attributes.

2. The record. The table's metadata goes into one attribute of the file, as JSON: the history (every change made to the table, with its settings), the recipes of derived attributes, the bounds a plugin asked to keep with the table, a drift correction's summary, the camera and the fit settings of a table that came from a fit, the simulation's settings for a simulated one, the ROI (region of interest) that is drawn, and the ROI manager's project if it was used. Two parts of a fitted table's metadata are too large for an attribute and go beside it: the image tags (what the microscope recorded per frame, such as the piezo position) into /frame_tags, and the acquisition's Micro-Manager summary and device properties into /acquisition. Both are read back into the metadata when the file is opened. So do the numbers the ROI manager's per-region steps measured: an HDF5 group per step under /regions, a dataset per column and a row per ROI, so a thousand ROIs cost what their numbers do rather than a megabyte of text in the attribute.

3. What the tools kept. Some plugins keep what they worked out – a drift curve, say – so that its figure can be drawn again later. That goes into /results/saved.

4. The session, optionally. With save the GUI state too, the tabs, their plugins and their settings are written into /gui/state, and the rest of the session into /gui/session: the layers (their filters, files, merging of blinks, colours and display, the image layers and which image each shows), the settings blinks are merged with, the 2D view's range, the 3D view's angle and its box, which windows were open – the 3D view, the ROI manager, plugins opened from the Plugins menu with their settings – and where every window was. None of it is put back when the file is opened with File > Open. File > Open and restore opens the file and puts all of it back, and File > Restore saved session does the same for the file that is open; File > Workspace > From data file takes the tabs alone. The windows come back on the screens there are: a window saved on a monitor that is not connected now is moved onto the nearest one and shrunk to fit it. A script's save, with no windows, writes the layers and the 3D view.

What a saved file holds: a simulated table after one Math Parser run, with an ROI drawn.

In detail

The history is capped at the last 500 entries, since all of the metadata is one attribute. An entry is a few hundred bytes.

Writing over a file. The file is written from scratch: whatever was in it before is gone, including tool results and a GUI state the session no longer has.

What is not saved. Without save the GUI state too the layers – their filters, whether they merge blinks, their colours – are not saved; only the bounds a plugin asked to keep with the table (Remove Localizations' hide flag, for instance) come back. The merged blinks are never saved: they are merged again when the file is opened. An image opened and then not shown in a layer is not saved.

How big the file is. Before compression, a table of localizations takes

bytes, the bytes per value of attribute : 4 for most attributes, 8 for frame. A fitted 3D table with a dozen or so attributes is some 60 bytes per localization, 600 MB for ten million; the compression takes part of that off.

Compression is lzf, which is about five times faster than gzip for about 15 % more space. The writer is the one the fitters use to write their results block by block while they run.

Parameters

settingdefaultwhat it does
file
path
–An .hdf5 or .h5 file; empty saves over the open file.

Empty works only when the open file is itself .hdf5 or .h5: after opening a _sml.mat or a csv, give the new file a name.

save the GUI state too
gui_state
onThe tabs and their settings, the layers, the views and the windows, for File > Open and restore to put back.

Useful for a file that is a record of how it was analysed, and for coming back to a piece of work where it was left; it costs a few kB. Nothing is restored unless someone asks for it (File > Open and restore), so it does no harm in a file that is shared.

save the ROI results
region_results
onThe numbers measured in the ROIs; off keeps the ROIs and drops their results.

Off, the ROIs are kept – their places, shapes, use flags and comments – and what was measured in them is not; the ROI manager shows them as not measured when the file is opened again. Worth it only when the results are large, many steps over many ROIs, and can be measured again.

save the ROI figures' data
region_figures
onWhat each ROI kept to draw its figures again; off keeps the numbers, and a figure is drawn by measuring again.

What an ROI keeps for its figures is binned – a few kB per ROI and step (Localization Statistics' histograms: about 2 kB) – so it is usually worth keeping. Off, every number is saved, and an ROI's figure is drawn by running its step again, which for most plugins takes milliseconds and for a slow one is the reason to keep it.

attributes (more)
columns
The attributes to save; all ticked saves every attribute. Positions and the file number are always saved.

Untick what nobody will read again – a simulation's truth attributes, the four bg* attributes of a MINFLUX file – for a smaller file that opens faster. The positions (x_nm, y_nm, z_nm) and filenumber are saved whatever is ticked, or the file would not open as the same files. A derived attribute left out takes its recipe with it, and so does one whose expression reads an attribute left out; a filter bound the table keeps on an attribute left out goes too. The session keeps every attribute: it stays marked unsaved, and File > Save goes on saving to the file it had. To take attributes out of the session itself, use Edit attributes.

Output

The file. The text says how many localizations went where.

With save the ROI results or save the ROI figures' data off, a line under the settings says what the session has that the save will leave out – "The results measured in 40 ROIs and 2000 regions of id attributes will not be saved" – as soon as there is any, and the text after the save says it again, so it reaches the history. The regions of id attributes are the clusters a block measured in; ROIs and clusters are both regions, sets of localizations measured together. The save is written into the session's history, so that the log says where the table went.

Differences from SMAP

SMAP saves _sml.mat files, which this program reads but does not write. The localizations here go to HDF5 instead, which is not tied to MATLAB and can be read while it is being written.

References