Load from path

File › Load · version 8

Read a localization file of any known format into the session.

What it does

Opens a localization file of any format this program reads, choosing the reader from the file's name and, where the name is not enough, from what is inside. It is what File > Open does. The formats:

Every reader keeps every column of the file as an attribute: the ones this program has a name for get that name, and the rest keep their own, so whatever the other program wrote can still be filtered on, coloured by or exported again.

A file whose name does not say what it is – a SMAP file not called _sml.mat – is read by choosing its format by hand (under more).

The file's layer shows its blinks merged, the same whichever reader was used: merge blinks (also called grouping or linking) combines the localizations in consecutive frames that come from one blinking event into one localization. The file does not wait for that to open: a large one opens at once and is merged in the background.

How it works

1. By the name. The readers whose endings match the file's name are the candidates, in the order smappy HDF5, SMAP, MINFLUX, Abberior MSR, csv, Picasso, DECODE. Upper and lower case do not matter.

2. By the contents, where one ending could be more than one thing:

The first candidate that passes is used. A file that none will take is refused with the list of formats that are known.

3. Merging blinks. The localizations of the same blink in consecutive frames are merged into one, with the session's merge settings (within 50 nm and 1 dark frame by default; merge settings... in the Render tab). The merged blinks are what a layer shows when merge blinks is ticked, which is how it opens. The merge is not part of reading: a small file is merged when it is first drawn, and a large one (300,000 localizations or more) opens at once and is merged in the background, the picture and the status bar saying so; the blinks are drawn when they are there, and a plugin run started meanwhile waits for them. Headless – in a script, a chain or a batch – the blinks are merged when something first reads them. An added file is merged together with the files already open. A table with a trace id (tid, as a MINFLUX export has) is merged by trace instead, one row per trace. To look at every localization, untick merge blinks on the layer: the single localizations are always kept.

Which reader Auto chose for a set of files: by the ending, and by what is inside where the ending is ambiguous. Grey: refused.

In detail

The choice is made before reading, so a file that is chosen and then turns out not to be what its name says fails with the reader's own error. Every .npy, .zip and .json file is taken for a MINFLUX export, and every .csv, .txt or .tsv for a table of localizations. With a format chosen, that reader is used whatever the file is called.

What opening costs. Every reader holds the whole table in memory: bytes for localizations, the bytes per value of attribute – 4 for most attributes, 8 for frame – so some 60 bytes per localization for a fitted 3D table, plus the merged blinks. Reading is done off the window's thread, so the window stays usable and says what it is doing. Merging the blinks – a few seconds for a few million localizations, some 25 s for 57 million – follows in the background, after the file has opened.

smappy HDF5. The attributes are read from /locs, one dataset each, with the types they were saved with, and the file's metadata comes back with them: the history (the session's log continues from the file's own; an entry this version does not understand is dropped, and at most the last 500 are kept), the derived attributes' recipes (an attribute made with Math Parser is still recomputed or reduced by its rule when blinks are merged), the kept bounds, which open on every layer, the drawn ROI and the ROI manager's project, the camera, the fit settings, and what a tool kept with the file – a drift curve, say (/results/saved) – so its figure can be shown again. A table is opened as it was saved: a fit writes nanometres and the pixel size, and a file from an earlier version that also has camera-pixel attributes (x_pix, ...) keeps them. The session that may be saved with the file (/gui: tabs, layers, views, windows) is left alone: File > Open and restore puts it back on request, File > Workspace > From data file the tabs alone. An HDF5 file from Picasso or DECODE is read by its own reader, below.

SMAP. SMAP keeps its table in saveloc.loc, one field per attribute. Each becomes an attribute, renamed to this program's name where there is one (SML_COLUMNS) and kept under its own name where there is not:

SMAP here SMAP here
xnm, ynm, znmx_nm, y_nm, z_nmLLrellogl_rel
photphotonslogLikelihoodlogl
bgbackgroundxnmerr, ynmerrx_err_nm, y_err_nm
locprecnmxy_err_nmzerr, locprecznmz_err_nm
PSFxnm, PSFynmsigma_nm, sigma_y_nmphoterrphotons_err
xpix, ypixx_pix, y_pixPSFxpixsigma_pix

Left behind are the attributes nothing here reads: xnmf, ynmf, xpixf and ypixf, where the peak finder put a spot before it was fitted, and xpixerr, ypixerr and PSFypix, which are attributes in nm given again in pixels. SMAP's numberInGroup comes across under its own name: it is not this program's n_in_group, which merging blinks writes. MATLAB counts from 1, so , as a 64-bit integer; channel and iterations become 32-bit integers and every other attribute single precision. Each file's info gives its pixel size (cam_pixelsize_um), frame count, conversion, offset, EM gain, chip region, exposure and frame time, kept in its metadata under smap and, as this program keeps a camera, under camera. A .mat without saveloc is refused.

SMAP saves every file it has open in one _sml.mat: the positions of an experiment loaded together, and the image of averaged sites, which SMAP adds as a file of its own. Each opens as a file of its own, as the files of a session saved together do, holding the localizations SMAP's filenumber gives it. It is named by the last part of the path SMAP loaded it from, and keeps its own camera and frame time. The positions of an experiment share the camera's coordinates, so read as one table they would lie on top of each other. A localization whose filenumber names none of the files is left out: SMAP shows it nowhere, and those found were all zeros, the leftovers of a SMAP step.

The sites of SMAP's ROI manager come along as the ROI manager's ROIs, from a -v7.3 file (SMAP's default) – a -v7 one keeps them where they are not read. Each site is an ROI on its own file, at its position, numbered by its SMAP ID, with its use and its comment. Its lines become the ROI's named lines: the orientation line (rotationpos, the one the site image is turned along) is direction, and line1 and line2 keep their names. The shape drawn by hand inside a site (line3) becomes the ROI's own outline: a polygon or a free-hand shape as drawn, a rectangle by its corners, an ellipse as 64 points round it; a polyline, not being a shape, is left out. SMAP drew that shape on the site image, which it turns along the orientation line when its rotate is on, so for such a site the outline is turned by that angle. The keyword lists (list1 to list4) become annotation lists with SMAP's keywords, and each site's choice its annotation. The ROI size is not in the file – SMAP keeps it in its settings – so the ROI manager's own is used.

MINFLUX. MINFLUX (Balzarotti et al. 2017) takes no camera frames: it homes in on a molecule in a few iterations, each with a smaller beam pattern, and records every one. Imspector has written the records in two ways. Up to version m2205 a row is one attempt at a localization, with its iterations inside it; from m2410 a row is one iteration, and the last iteration of a localization is marked final (fnl). Either way, only the final iteration – the most precise – is read, and only where the instrument marked it valid (vld) and it has a position. Positions go from metres to nanometres and are not shifted to start at zero; z is multiplied by the z scale. There are no frames, so the localizations are sorted by their time (tim, kept as time_s) and frame is the rank in that order; the trace – the localizations of one molecule while it was on – is tid.

Every iteration. With every iteration ticked (under Abberior MSR, which also serves the exports, or in File > Open's dialog), every iteration of every attempt is read instead, valid or not: the scouting iteration that found a molecule or not, the catching iterations that closed in on it, the final ones, and the iterations that ended an attempt. That is what the sequence's quality is read from (Sequence QC). A row says which iteration it was (iteration), whether it is a localization (final: a valid final iteration), whether it was valid (vld) and why it ended (sta); an attempt that failed has no position. trace_index is the number of the localization a row is or leads to, so a filter trace_index > 20 means the same as without it. The localizations themselves are exactly those read without the tick. The layers start with a filter final = 1, so the picture and every plugin see the localizations until the filter is changed, and merging a trace merges its localizations only (group_use). A real 2D measurement had 7369 rows for 3817 localizations; a scouting-heavy one can have ten times as many rows. An m2205 record is unnested into its iterations.

Threads. A measurement can run several sequences at once, one per thread – two colours, each with its own laser and sequence – and every row says which (thi). Every thread's sequence is kept, and each row's precision is computed with its own thread's pattern size and laser. Where the file names each thread's MINFLUX laser, a row's colour is channel: its laser's place among the lasers of the file's measurements, the longest wavelength first – 0 the 640 nm laser and 1 the 560 nm one in a file with both. The colour is the laser and not the thread, because the order of the threads is not fixed: in one pair of measurements looked at, the bead measurement ran 560 nm first and the tracking measurement 640 nm first. What each channel is – its laser, threads and detectors – is kept with the measurement. A file whose threads name no laser has no channel.

The final iteration's efo, efc, ecc, fbg, the iteration number (iteration), why the iteration ended (sta), the grid point, thread and sequence (gri, thi, sqi) come across where the records have them. dcr, the fraction of photons on the first detector, is m2410's first of two ratios; the second, the fraction on the second detector, is dcr2. cfr, the centre-frequency ratio that tells a single molecule from two, is not measured in the final iteration: Imspector measures it in one earlier iteration – found as the last one whose cfr varies – and writes 0 into the others. A localization's cfr is that iteration's of the same localization. How often it is measured depends on the sequence: before every localization in the 3D sequences looked at, once at the start of a trace in the 2D ones – so in a 2D measurement only the first localization of each trace has a cfr, and the others have none (NaN, not a number). They are not given their trace's: a value they were not measured with would read as if they had been. Statistics, histograms and filters leave NaN out, so a mean of cfr is the mean over the localizations that have one. The position Imspector corrected with its beam monitoring (MBM, beads followed during the acquisition) is x_nm, y_nm, z_nm; where the uncorrected one differs it is kept beside it as x_nc_nm, y_nc_nm, z_nc_nm.

The photons are the final iteration's eco. The records give no localization precision (also called the CRLB, the Cramér-Rao lower bound: the best precision any estimator can reach with these photons), so xy_err_nm is that bound worked out from the photons, as a camera fitter's is. It is not the scatter of the localizations, which the precision plugins measure. MINFLUX probes a molecule with the zero of a doughnut placed at K points on a circle of diameter L (the pattern size) and counts the photons there: from the molecule and from background. Near the zero the intensity grows as the square of the distance, and for a molecule at the centre of the pattern the bound per axis is

Without background it is the bound of Balzarotti et al. 2017; with it, the 2D form of Marin & Ries 2024's equation for out-of-focus background. It does not depend on K – a triangle, a square or a hexagon – nor on an exposure at the centre, which adds no information there. A molecule away from the centre is localized worse than this, and the records do not say where it was. L is the sequence's last lateral iteration's, patGeoFactor × 360 nm × λ / 642 nm: the pattern scales with the excitation wavelength λ, 642 nm being the reference (abberior's definition). λ is the iteration's excitation laser, else the measurement's MINFLUX laser, else 642 nm when the file names none (an .npy or .json export). For the common 2D sequence (patGeoFactor 0.28) L is 101 nm at 642 nm and 88 nm at 561 nm; 25 photons without background give 7 nm at 642 nm.

The background is Imspector's: eco is split into and in the ratio fbg/efo, its background rate over its photon rate. This assumes that efo includes the background and that fbg is a rate at the same positions in the same units – Abberior does not document either. When Imspector's background sensing is off, fbg is 0 and so is ; that was so in every file looked at. At most 90 % of the photons are taken as background.

In 3D, z gets the bound of a line of two offsets, with the last axial (zline) iteration's L, times the z scale, as z_err_nm. A 3D sequence alternates lateral and axial iterations, so xy_err_nm uses the photons of the localization's own last lateral iteration, not of the final one (which photons shows). An export without its sequence (.npy, .json, .zip) gets L = 100 nm and no z_err_nm. sigma_nm is 150 nm for all. Merging blinks goes by trace: one row per tid (its mean position, summed photons, first frame, and n_in_group), rather than by distance and frame. The .npy, the .json and a .zip holding either are read; MINFLUX data saved as a MATLAB .mat is not.

Abberior MSR. An .msr is a container of stacks: images, and a stack of bytes per MINFLUX measurement, which holds the measurement's records and settings as Imspector's export to ZARR writes them. Listing the file reads the stacks' headers and unpacks each measurement's settings, a tenth of a second for a file of ten; the records are decoded only for the measurements opened. A measurement is read as above, and keeps with it, in the file's metadata: its label, date, version and dimension, the counts, its sequence (every iteration's parameters: pattern, laser and power, photon limit, dwell time, ...), the lasers and detectors, the region it was taken in, and its MBM beads – which were used, their positions as recorded, and Imspector's precision for each. The measurements chosen are a file each; with merge into one file they are one table, one after another in time: each one's time_s is moved by when it started after the first one did (to the second, from its date), its traces are numbered after the last one's so that every tid is one trace, and a measurement attribute says which it was. Images – confocal and STED channels – are read and kept in the session's list of images, placed in nanometres by the stack's own offset and pixel size, in the frame the localizations are in: no registration is needed to lay one on the other. They get no layer of their own – an .msr holds a dozen – so add an image layer and choose the image in it. Like any image, one is saved with the session only once a layer shows it. What Imspector drew of a measurement (its density and trace renders) is listed, and not opened unless ticked: the localizations draw it again.

MBM beads. MBM – beam-line monitoring – tracks a few fixed beads during the measurement, a point every couple of seconds, and Imspector subtracts the beads' mean displacement from every localization (x_nm is corrected, x_nc_nm is not). With MBM beads as a file the beads' tracks become a file of their own beside the measurement, on the same clock (time_s, moved with the measurement when merged), so that they can be drawn in a layer, measured like any tracks, and used to correct the drift again without a bead that went wrong. The file has no attribute the localizations do not have: a bead's id is tid, its brightness photons, Imspector's precision for it xy_err_nm; z is scaled by z scale like the localizations'. A bead keeps one id within its measurement and a new one in the next, even under the same name, since Imspector reuses its slots (R0, R1, ...) for whichever beads it finds. Its name, whether Imspector used it and how often it lost it are kept with the file. The bead file knows which measurement it belongs to by the .msr's path and the measurements' ids, which survive saving the session and opening it again. Some files keep the beads only from before the measurement starts; their bead file has just those few points. A two-colour measurement can measure its beads in both colours, a grid of beads per colour each corrected thread by thread: every bead is then in the bead file once per colour, an id each, named after its colour (R0@638, R0@560), with the colour as channel – a bead seen in two colours is two tracks, apart by a bias of their own, which in the file looked at differed between beads by tens of nanometres. Stacks Imspector writes in chunks, for very large acquisitions, are not read yet, and say so.

Picasso. Picasso keeps its table as one dataset of records, /locs, where this program keeps an attribute per dataset; that is how the two are told apart. Positions, widths and precisions (x, y, sx, sy, lpx, lpy) are in camera pixels and become nanometres with the file's Pixelsize; z and lpz are in nanometres already:

Picasso here Picasso here
x, yx_nm, y_nmbgbackground
lpx, lpyx_err_nm, y_err_nmz, lpzz_nm, z_err_nm
sx, sysigma_nm, sigma_y_nmgrouppick_id

xy_err_nm is worked out from x_err_nm and y_err_nm, and the pixel attributes are kept beside the nanometre ones. group is Picasso's pick, read as pick_id so it is not taken for merged blinks (group_id); like any id attribute it can be measured per region. Everything else (photons, frame, net_gradient, ellipticity, a linked table's len and n, ...) keeps its name; frames count from 0 in both programs. The metadata is read from the /metadata dataset recent Picasso versions embed, or else from the .yaml file beside the .hdf5. It is a list, an entry per step that made the file; the pixel size is taken from the last entry that gives one, as Picasso reads it. Without a pixel size there, the default one is assumed and the table says so. The list is kept with the table, and Save localizations writes it back into a Picasso file with this program's steps appended. A file whose /locs declares its rows but was never written – a converter that stopped before its data – is refused with the number it declares, rather than read as that many localizations at frame 0 and (0, 0).

DECODE. DECODE writes /data: xyz, phot, bg, frame_ix, prob, id, and where it predicted them the uncertainties xyz_sig, phot_sig, bg_sig and the Cramér-Rao bounds xyz_cr, phot_cr, bg_cr; /meta says whether x and y are in pixels or nanometres (xy_unit) and the pixel size (px_size, x and y). z is in nanometres either way. xyz_sig becomes x_err_nm, y_err_nm, z_err_nm – the precision DECODE reports for each localization – and the bounds are kept beside it as standard deviations (x_crlb_nm, ...; DECODE stores variances). phot is photons, bg background, frame_ix frame (from 0 in both), and prob, the probability DECODE gives a detection, is kept under its name: it is the attribute to filter DECODE's localizations by. A quantity DECODE did not predict is an empty dataset in the file and becomes no attribute.

csv. The first line is the header if any of its cells is not a number; otherwise the columns are called column 1, column 2, ... Cells are split by tabs, semicolons or commas, whichever the first line has most of. Every column with a number in it is read. Those that mean something to this program are found by their header – cleaned to lower case, the unit in square brackets taken off, spaces made underscores, and looked up (CSV_NAMES):

attribute headers
x_nm, y_nm, z_nmx, y, z; xnm, ...; x_nm, ...
frameframe, t
photonsintensity, photons, phot, n
xy_err_nmuncertainty, uncertainty_xy, locprecnm
z_err_nmuncertainty_z, locprecznm
sigma_nm, sigma_y_nmsigma, sigma1, psfxnm; sigma2
backgroundoffset, bg, background
background_stdbkgstd
channel, logl_rel, idchannel; llrel; id

– and every other column keeps its header as its name, cleaned the same way (chi2, cluster_id). When two headers mean the same attribute the first wins; x and y must be found. frame, channel and id are read as whole numbers, the rest as single precision, and a row whose x or y is missing is left out.

Units and the first frame. The lengths – x, y, z and their errors and widths – are read as nanometres unless the file is said to be in micrometres, millimetres (multiplied by or ) or camera pixels (x, y and their errors and widths multiplied by the pixel size , ; z is left in nanometres, as the programs that write pixels do). Frames are made to count from 0: a file whose first frame is 1, as ThunderSTORM's and SMAP's are, has 1 taken off. Only the attributes this program has a name for are converted; an attribute kept under its own name is read as it is.

Conversions. How one program's export is read – which header is which, the units, the pixel size, the first frame – can be saved under a name, as SMAP's conversion structures were, and is then found again by the headers: the saved conversion whose headers the file all has, the one with the most of them if several do. ThunderSTORM's ("x [nm]", "y [nm]", "frame": frames from 1) and SMAP's export ("xnm", "ynm", "frame": frames from 1) come with the program; a conversion saved from the File menu's dialog (save as...) goes to the configuration folder and is offered in conversion from then on.

Parameters

settingdefaultwhat it does
file
path
–The localization file to read.
add to the open files
append
offJoin the table as one more file instead of replacing everything; Add in File > Open.
format (more)
format
auto: by the file nameAuto: from the file's name and, where that is not enough, its contents.

Leave it on auto. Choose a format for a file whose name does not say what it is – a SMAP file renamed, a csv saved as .dat – or to make sure the file is read as that format and refused otherwise.

csv columns – How a delimited text file's columns are read; io.formats._load_csv.
   conversion
   csv.conversion
auto: by the headersA saved conversion; auto picks the one whose headers the file has.
   columns
   csv.mapping
–header=attribute pairs, e.g. X=x_nm, Y=y_nm, T=frame; empty means the conversion's, or a guess from the header.

Needed only when the headers are not recognised and no saved conversion fits. Each pair is header in the file = attribute in the table; the headers not named are still read, under their own names. Opening such a file from the File menu asks in a dialog instead, which can also save what was chosen as a conversion.

   lengths in
   csv.units
autoWhat x, y, z and their errors are in. Choices: auto; nm; µm; mm; camera pixels
   camera pixel
   csv.pixelsize_nm
autoFor lengths in pixels. at least 0.01 nm
   first frame
   csv.first_frame
autoThe number the file's first frame has: 1 for ThunderSTORM and SMAP, 0 for smappy.

Empty takes it from the conversion, or 0. Set it when a program that counts frames from 1 is not recognised: a frame number off by one shifts every time-resolved analysis – drift, merging blinks against another channel – by a frame.

Abberior MSR – What of an Abberior .msr is read; io.msr. The GUI's File > Open asks in a dialog instead (gui.dialogs.MsrImportDialog).
   measurements
   msr.measurements
–Empty: all; numbers from 1, labels or a pattern of the labels, separated by commas.

The GUI asks in a dialog, with every measurement and image listed and the selected one's sequence shown beside it; this field is for a chain or a batch. 2, 5 opens the second and the fifth, 150915 the one whose label has that in it.

   merge into one file
   msr.merge
offOne table for all of them, one after another in time, with a measurement attribute; otherwise a file each.

Merge measurements of one sample taken one after another – ten of 30 s each, say – to analyse them as one, keeping measurement to tell them apart. Leave it off to compare measurements, or when they were taken with different sequences.

   keep invalid
   msr.keep_invalid
offEvery final iteration, with vld and sta, not only the valid ones.
   every iteration
   msr.every_iteration
offA row per iteration, valid or not, for the sequence's quality; the layers start on the localizations (final = 1).

Tick it to look at the sequence's quality – how many attempts each iteration passed, why the rest failed, the photons and background per iteration – with Sequence QC. Leave it off otherwise: the table holds two to ten times the rows, most without a position.

   z scale
   msr.z_scale
1Multiplies z: the refractive index correction; 1 keeps Imspector's numbers.

The positions in z are those Imspector computed, which do not correct for the refractive index mismatch between the immersion oil and the sample: an axial distance in water is measured too long. Values of 0.7 to 0.8 are used for imaging in aqueous samples with oil objectives. It has no effect on 2D measurements.

0.01 to 10
   images
   msr.images
onRead the file's confocal and STED images, placed in nm, for an image layer to show.
   MBM beads as a file
   msr.mbm_beads
offEach measurement's beam-monitoring bead tracks as a file of their own beside it.

In File > Open it is a tick in the dialog, shown when a measurement has beads. The file is small – a few hundred rows – and is read from what opening the measurement already decoded. Leave it off unless you will look at the beads or correct the drift with them.

Output

The table, added to the session as a file of its own, or joined to the open ones with add to the open files (a filenumber attribute tells them apart). An .msr gives a file per measurement (or one, merged), each followed by its MBM beads' file where asked for, and its images for the image layers to choose from. Each file keeps its own metadata – its camera, its acquisition, a measurement's sequence and beads – however many are open, and a session of several files saved and opened again opens as those files. The text says how many localizations were read, and in which format. The load is written into the history with its settings, after the entries an HDF5 file brought with it.

Differences from SMAP

Based on SMAP's Loader_sml and Loader_minflux_json (Ries 2020). The main changes:

References