SciLifeLab workshop: pre-processing and particle picking

In this session you will turn raw tilt-series of HIV-1 virus-like particles into tomograms, pick particles in three different ways, and launch denoising and segmentation of a second dataset so it runs over lunch.

🔎 What is pre-processing?

A tilt-series is a set of 2D images of the same area recorded at different tilt angles (here −60° to +60° in 3° steps). Before we can compute a 3D tomogram we need to:

  1. Align the movie frames of each tilt to undo beam-induced motion (each tilt is recorded as a short movie).

  2. Estimate the CTF (the microscope’s contrast transfer function), which depends on defocus and changes across a tilted image.

  3. Align the tilt-series: find how the images are shifted and rotated relative to each other. Here, we will demonstrate alignment using gold fiducials.

  4. Reconstruct the tomogram: back-project the aligned images into a 3D volume.

nextPYP runs all four steps in a single Pre-processing block.

Data import and pre-processing (30 min)

The HIV-1 dataset (EMPIAR-10164) was collected on a 300 kV Titan Krios with a Gatan K2 detector at 1.35 Å per pixel. Each tilt-series has 41 images between −60° and 60°, spaced by 3°; each tilt was recorded as 8–10 frames.

Step 1: Create a project
  • Click on Create new project, give the project a name, and select Create

  • Select the new project from the Projects page and click Open (or double-click the project to open it)

Step 2: Import raw tilt-series
  • Go to Import Data and select the Tomography tab, then Raw Data

  • On the Sources tab:

    • Set the Location of the raw data by clicking on the icon and browse to /fastrs/bartesaghi/nextpyp/workshop/10164/

    • Type *.tif into the filter box (lower right), click the icon, then click Choose File Pattern

  • On the Grouping tab, leave No movie frames unchecked (this dataset has movie frames)

  • On the Microscope Parameters tab, set the values below

Parameter

Value

Why

For your own data

Pixel size (A) critical

1.35

Every distance and resolution downstream is computed from it.

Use the calibrated pixel size from your microscope facility, not the nominal one.

Acceleration voltage (kV) critical

300

Sets the electron wavelength used in CTF estimation.

300 for Krios/Titan, 200 for Glacios/Talos.

Tilt-axis angle (degrees) critical

85.3

Initial guess of the tilt-axis direction in the images; alignment refines it.

Read it from the acquisition software metadata (e.g., SerialEM/Tomo5).

  • Click Run on the block status bar. Click the thumbnail inside the block to see one tilt image.

Step 3: Pre-processing
  • Click on Tilt-series (output of the Tomography (from Raw Data) block) and select Pre-processing

  • On the Frame alignment tab, keep unblur as the Alignment method

  • On the Tilt-series alignment tab, keep IMOD (fiducials) as the Alignment method (the default)

  • On the CTF determination tab, set Max resolution (see below)

  • On the Tomogram reconstruction tab, keep IMOD as the Reconstruction method and enable Erase fiducials

  • On the Resources tab, set Split, Threads

Parameter

Value

Why

For your own data

Alignment method critical

IMOD (fiducials)

This sample has gold beads, which give the most accurate alignment.

Without fiducials (most lamellae), use IMOD patch tracking or AreTomo.

Max resolution (CTF) forgiving

5

Highest resolution used to fit the CTF. Going too far includes noise; too low makes the defocus less accurate.

Start around 5–6 Å for good data; use a lower resolution (e.g., 8–10 Å) for thick samples such as lamellae.

Erase fiducials forgiving

on

Gold beads have high contrast and create streaks in the tomogram.

Turn on whenever your sample has gold beads.

Split, Threads forgiving

11

Several tilts are processed in parallel, which speeds up pre-processing of each tilt-series.

A moderate number (around 10) works well. Using one thread per tilt doesn’t scale well: it uses many more resources without a matching speed-up.

  • Click Run and follow the run in the Jobs panel

  • You don’t need to wait for the run to finish: open the block and look at the Tilt-series, Plots, Table and Gallery tabs as results come in

  • Timing: on the workshop test instance, importing the 123 files took less than a minute and pre-processing the three tilt-series took about 9 minutes. Allow 10–20 minutes for pre-processing on the shared workshop instance, depending on the cluster load

🔎 What should I look at?
  • Plots: the defocus distribution should be between 2.5–5.0 μm and the estimated resolution between 5–10 Å.

  • Tilt-series: the aligned tilts should not jump around when you scroll through them and features should move in a horizontal line.

  • Logs: the residual error of the fiducial alignment is reported in the logs of the run and should be small (a few pixels).

  • Tomogram: virions should look round in all three views.

⚙️ Expert note: CTF handedness

The sign of the defocus gradient across a tilted image tells you the handedness of the tilt geometry. A wrong handedness produces mirrored maps and limits resolution in CTF-corrected refinement. nextPYP checks it during CTF estimation and reports the result in the logs of the run.

Checkpoint 1

You should now have reconstructed tomograms of HIV-1 VLPs.

If pre-processing is still running, continue with the filtering demonstration while results appear. If it failed or you fell behind, click Import Blocks, choose Archive, and import /fastrs/bartesaghi/nextpyp/workshop/checkpoints/stockholm2026_s2_checkpoint1_preprocessing.nextpyp.tbz. The archive contains the raw-data and completed pre-processing blocks, so you can catch up.

To rebuild this stage and continue through geometry-based picking, click Import Workflow and choose Stockholm 2026 S2 - HIV-1 preprocessing and geometry picking, then run it.

Filtering (10 min)

Filtering tilt-series
  • Open a block’s Table view. Click Add filter to see the numeric columns that this block supports for filtering, such as CTF score, defocus and motion in a pre-processing block. The available properties depend on the block and its results.

  • Create a filter by giving it a name and clicking Save, or combine conditions on several supported columns. To exclude a tilt-series manually, select its row and use the Include/Exclude action in the row details or Status controls.

  • Downstream blocks can then process only the tilt-series in a filter (Filter tomograms dropdown), which saves time and removes bad data early.

  • Bad tilts within a tilt-series can also be removed: ignore them one at a time from the tilt navigation bar of the Tilt-series view, or in batch across all tilt-series in the block by image index or tilt angle (e.g. all tilts above 54°). Ignored tilts are left out of alignment and reconstruction until you include them again.

Particle picking (45 min)

🔎 Which picking method?

nextPYP has several particle-picking methods because no single method works for every sample:

  • Geometry-based: particles sit on a known surface (here, the virion membrane).

  • Size-based: particles are blobs of a known size.

  • Neural-network-based and MiLoPYP: learn what the particles look like from a few examples, or discover them without labels (Session 3).

  • Template matching: search with a known 3D reference.

  • Manual: add, remove or edit particles by hand.

Geometry-based picking (EMPIAR-10164)

Three blocks: virions → membranes → Gag
  • Block 1: virion detection. Click on Tomograms (output of the Pre-processing block) and select Particle picking. On the Particle detection tab, set Detection method to virions and Virion radius (A) to 500

  • Block 2: virion segmentation. Click on Particles (output of the Particle picking block) and select Segmentation (closed surfaces)

  • Block 3: Gag detection. Click on Segmentation (closed) and select Particle picking (closed surfaces). On the Particle detection tab, set Method to uniform and set the values below

Parameter

Value

Why

For your own data

Particle radius (A) critical

50

Spacing between picked positions on the surface; about the size of one Gag hexamer.

Use about the radius of your particle.

Size of equatorial band to restrict search (A) forgiving

800

The top and bottom of each virion are blurred by the missing wedge, so we pick only around the equator.

Larger bands give more particles of lower quality.

  • Open the Run tab and click Start Run for 3 blocks

  • Timing: virion detection took 5.5 minutes, closed-surface segmentation 6 minutes, and Gag picking 5 minutes for the three test tilt-series. Allow 15–20 minutes for the three-block chain; you can continue to size-based picking while it runs

Checkpoint 2

You should now have Gag particles on the virion surfaces.

If picking failed or you fell behind, click Import Blocks, choose Archive, and import /fastrs/bartesaghi/nextpyp/workshop/checkpoints/stockholm2026_s2_checkpoint2_geometry_picking.nextpyp.tbz. The archive contains the five blocks from raw-data import through Gag picking, so you can catch up.

To rebuild that pipeline instead, click Import Workflow and choose Stockholm 2026 S2 - HIV-1 preprocessing and geometry picking, then run it.

Back to the on-the-fly session (demo)

The EMPIAR-10164 session from Session 1 has been pre-processing tilt-series without picking particles. We now add the same geometry-based picking to the running session:

  • In the session’s Virion detection tab, set Virion radius to 500, Virion detection method to auto, Spike detection method to uniform and Size of equatorial band to restrict spike picking to 800

  • On the Particle detection tab, set Particle radius (A) to 50

  • On the 2D classification tab, turn Run 2D classification on. Set Minimum number of particles to 5000, Incremental number of particles to 2500, Box size (pixels) to 94, and Mask radius (A) to 300. In the advanced settings, set Fraction of particles to use to 1, Starting high-resolution to 80, and Max resolution (A) to 22

  • On the Resources tab, set Processing Threads to 128. Geometry-based picking produces a lot of particles, and the higher thread count keeps that step moving.

  • Click Save. While the form differs from the saved parameters, Unsaved changes shows next to the button. After the save, a note says that the running daemons still use the previous parameters.

  • On Daemons → Data pre-processing, click Restart. Restart re-runs only what is needed after a parameter change, so picking is added without starting over (Clear would start everything from scratch).

  • Later in the day we’ll come back to the session to look at the 2D classes of the picked Gag particles, which are updated as particles accumulate.

Size-based picking (EMPIAR-11306)

Import a session and pick by size
  • Click Import Data, go to the Tomography tab and click From nextPYP. A Tomography (from nextPYP) block appears on the Graph

  • Open the block’s Parameters tab. On the Sources tab, set Search in to Sessions, type EMPIAR-11306 in the Search sessions... box, then click Add next to the result to put it under Selected sources

  • Click Run

  • Click on Tomograms and select Particle picking. On the Particle detection tab:

    • Set Detection method to size-based

    • Set Particle radius (A) to 100

    • Set Minimum distance between particles to 1

    • Check Local refinement

    • Set Z-axis detection range (binned slices) to 80

    • Set Particle detection threshold to 1.1

    • Check Filter positions by relative contrast

    If a parameter is not visible, turn off Non-default only at the top of the parameters form. This setting remains active when you move between blocks.

  • Click Run, then open the block to inspect the picked ribosomes

Parameter

Value

Why

For your own data

Particle radius (A) critical

100

80S ribosomes are about 250–300 Å across; size-based picking looks for blobs of this size.

Measure a few particles in your tomograms with the measure tool and use about half the diameter.

Z-axis detection range (binned slices) critical

80

Restricts picking to the slab occupied by the lamella, so nothing is picked in the empty space above and below it.

Look at a side view of your tomograms and match the thickness of your sample.

Particle detection threshold forgiving

1.1

Higher values keep fewer, stronger detections; lower values pick more, including false positives.

Adjust it by checking the picks on a few tomograms.

Checkpoint 3

You should now have ribosomes picked in the lamella tomograms.

If picking failed or you fell behind, click Import Blocks, choose Archive, and import /fastrs/bartesaghi/nextpyp/workshop/checkpoints/stockholm2026_s2_checkpoint3_ribosome_picking.nextpyp.tbz.

To rebuild it instead, click Import Workflow and choose Stockholm 2026 S2 - EMPIAR-11306 size-based picking, then run it.

Manual editing, template matching, and IMOD coordinates
  • Manual editing: from a Particle picking block menu, choose Copy, check Copy files and data and Make automatically-picked particles editable, then open the new block’s Particles tab. Left-click adds a particle, right-click removes one. Navigate to other tilt-series to add or remove particles on those as well.

  • Template matching is also available; see 3D particle picking.

  • Particle coordinates can be exported to and imported from IMOD; see Import/export functionality.

Denoising and segmentation setup (15 min)

We will import a workflow that denoises and segments the SARS-CoV-2 tomograms (EMPIAR-10453). Launch it before lunch so it is finished for Session 3.

The workflow takes only a few minutes to import and start. Budget approximately 45–90 minutes of compute time for ten tilt-series, depending on GPU availability and cluster load; it is intended to run unattended over lunch.

Import and run the workflow
  • Click Import Workflow and choose Stockholm 2026 S2 - EMPIAR-10453 denoising and segmentation. The parameters are pre-set and saved automatically

  • Open the Run tab and start all blocks

The workflow contains:

Block

Key setting

Why

For your own data

Segmentation (pre-trained models)

MemBrain-Seg pre-trained model

Membrane segmentation generalizes well across datasets, so no training is needed.

Usually works as is; adjust Pixel size rescaling and Components to keep.

Denoising (eval)

IsoNet2, pre-trained on this dataset

Denoising makes particles easier to see and helps MiLoPYP-2 in Session 3.

Denoising models usually need re-training on your own data (see Denoising).

nextPYP also supports Topaz-Denoise, IsoNet1, Noise2Map, cryoCARE and easymode for denoising, and TARDIS and easymode for segmentation.

Stretch goals

  • Re-run pre-processing with a fiducial-free alignment method (IMOD patch tracking or AreTomo3) and compare the tomograms and alignment errors.

  • Train an IsoNet2 model on the half-tomograms from pre-processing and compare the result with the pre-trained denoising.

  • Clean up the segmentations with Filter connected components to remove carbon edges and small false positives.

Applying this to your own data

  • Calibrated pixel size, voltage and tilt-axis angle: get these right first; everything else depends on them. If .mdoc files are available, pixel size and voltage can be imported from them. The mdoc tilt-axis angle is shown for reference only, since SerialEM measures it from a different axis (the offset is often, but not always, 90°).

  • Fiducials or not: this decides the tilt-series alignment method.

  • Sample thickness: thick samples need a lower CTF fit resolution and a thicker tomogram.

  • Particle size and geometry: decide which picking method fits your sample, and measure sizes in your own tomograms.

  • Filter early: remove bad tilt-series before running expensive steps.

Next: Session 3.