A CLI tool to automatically segment the lamella slab in cryo-ET volumes
Slabify is a Python command-line tool to automatically segment the lamella slab from cellular cryo-electron tomography (cryo-ET) volumes. The program analyzes the local variance around random points inside the tomogram to find where the "interesting" density is. There are three modes of operation:
- Find the lamella boundaries by fitting two planes to the top and bottom sides of the slab iteratively (default).
- Fit a single plane through the center of the lamella, then expand a slab mask of the given
--thickness
in Z. This mode is enabled by the--simple
flag, and tends to work better in "difficult" cases. - If all else fails, you can still manually define the lamella boundaries by clicking a few points (12, to be precise) in IMOD and have
slabify
fit two planes defining the top and bottom sides of the slab. See instructions for details.
The first two modes employ robust fitting through the RANSAC algorithm to prevent outliers from perturbing the boundary estimation too much.
A lamella slab mask can be useful in different scenarios when processing cellular cryo-ET data, for example:
- Removing obvious false positives outside the lamella in particle picking (e.g. by template matching)
- Speeding up template matching by avoiding searches in the void, as implemented in STOPGAP, GAPSTOP and pytom-match-pick
- Clipping segmentations
- Selecting only "interesting" subtomograms for training denoising networks, as in IsoNet and DeepDeWedge
- Assessing particle distribution within the lamella
- Create a conda environment (or use an existing one if you prefer):
conda create -n slabify python=3.12
- Activate the environment:
conda activate slabify
- Clone the repo and install Slabify using
pip
:
git clone https://github.com/CellArchLab/slabify-et.git
cd slabify-et
pip install .
Now, you should be able to run the slabify
command.
- IMOD: if you want to be able to create slab masks from IMOD models in
.mod
format directly, you should have IMOD installed and activated in your session.
Using Slabify is straightforward:
slabify --input tomogram.mrc --output tomogram_slab_mask.mrc
You may want to turn a few knobs to fine tune your results of course. Type slabify --help
to see all options. See also the FAQ below.
The following tomogram sizes have been tested:
- 1024 x 1024 x 512, 7.84 Å/px (bin4, Falcon4i detector)
- 1024 x 1440 x 256, 10.74 Å/px (bin4, K3 detector)
Anything in this range of tomogram dimensions and pixel sizes should work well. The --boxsize
and --n-samples
options might need to be adjusted if you have something very different.
While Slabify should work on any tomogram, high-contrast and "clean" tomos tend to give the best results. These can be obtained by applying a denoising tool such as cryoCARE, IsoNet or DeepDeWedge to your data before running Slabify. For a quicker alternative, the deconvolution filter from Warp also works well for our purposes. See here how to apply it using IMOD.
It is known that Slabify can be quite conservative in its estimation of the lamella boundaries. There are a few tips you can try to get thicker slab masks:
- The easiest way is to use the
--offset
option to arbitrarily grow your slab mask in the Z direction. Note that a negative value can be provided to make the slab thinner! - You can increase the number of
--iterations
. 3 to 5 iterations are usually good. - You can slightly decrease the
--percentile
of highest variance points in order to capture more information, say from 95 to 94. - Tweaking the
--n-samples
and--boxsize
values can be beneficial in some cases (needs more testing). - Finally, the
--simple
mode with an arbitrary slab--thickness
is generally a safe option.
The manual boundary masking is based on code from Will Wan for STOPGAP. Thanks to Caitie McCafferty and Philippe Van der Stappen for discussions and feature suggestions.