CCPEM Pipeliner
Guide

RELION Jobs: Classification and Refinement

RELION 2D and 3D classification, initial model, refinement, polishing and particle subtraction


Overview

This page documents every RELION classification and refinement job type registered in ccpem-pipeliner: 2D classification (EM and VDAM algorithms, including helical variants), 3D classification (standard, helical, and multi-reference variants), de novo initial model generation, 3D auto-refinement (standard and helical), multi-body refinement and flexibility analysis, CTF refinement, Bayesian polishing (training and polishing), particle subtraction and reversion, symmetry expansion, and DynaMight continuous heterogeneity analysis. Understanding these job types lets you build automated pipelines that chain particle picking outputs through to publication-ready reconstructions, and lets you continue, overwrite, or branch any step programmatically.


Usage

All jobs on this page follow the same lifecycle: schedule or run the job using a parameters dict or a run.job file, wait for it to finish, then optionally continue it from the latest optimiser file. The sections below describe each registered job type, its process name, key option keys, inputs, outputs, and continuation behaviour.

Job-type reference table

Process nameClassOutput dircan_continueProgram
relion.class2d.emRelionClass2DEMClass2D/✓relion_refine
relion.class2d.em.helicalRelionClass2DHelicalEMClass2D/✓relion_refine
relion.class2d.vdamRelionClass2DVDAMClass2D/✓relion_refine
relion.class2d.vdam.helicalRelionClass2DHelicalVDAMClass2D/✓relion_refine
relion.class3dRelionClass3DClass3D/✓relion_refine
relion.class3d.helicalRelionClass3DHelicalClass3D/✓relion_refine
relion.class3d.multirefRelionClass3DMultiClass3D/✓relion_refine
relion.class3d.helical.multirefRelionClass3DHelicalMultiClass3D/✓relion_refine
relion.initialmodelInimodelJobInitialModel/✓relion_refine, relion_align_symmetry
relion.refine3dRelionRefine3DRefine3D/✓relion_refine
relion.refine3d.helicalRelionRefine3DHelicalRefine3D/✓relion_refine
relion.multibody.refineRelionMultiBodyRefineMultiBody/✓relion_refine
relion.multibody.flexanalysisRelionMultiBodyFlexAnalysisMultiBody/✗relion_flex_analyse
relion.ctfrefineRelionCtfRefineCtfRefine/✓relion_ctf_refine
relion.polishRelionPolishParticlesPolish/✓relion_motion_refine
relion.polish.trainRelionPolishTrainPolish/✓relion_motion_refine
relion.subtractRelionSubtractSubtract/✗relion_particle_subtract
relion.subtract.revertRelionSubtractRevertSubtract/✗relion_particle_subtract
dynamightDynamightContinuousHeterogeneityDynaMight/✗DynaMight executable
relion.image_analysis.symmetry_expansionRelionSymmetryExpansionSymmetryExpansion/✗relion_particle_symmetry_expand

2D classification (relion.class2d.em and relion.class2d.vdam)

Category: 2D Classification

Both EM and VDAM variants classify particles into 2D averages and share the same Class2D/ output directory. The key difference is the optimisation algorithm: EM uses the expectation-maximisation algorithm (option key nr_iter_em), while VDAM uses Variable-metric Gradient Descent with Adaptive Moments (option key nr_iter_grad). Neither VDAM variant has an nr_mpi option; adding nr_mpi to a VDAM parameters dict raises ValueError.

Primary input: fn_img — particles STAR file (NODE_PARTICLEGROUPMETADATA)

Continuation input: fn_cont — an *_optimiser.star file (NODE_OPTIMISERDATA); only active in continue mode (only_in_continue=True)

Key option keys (shared between EM and VDAM variants):

KeyLabelDefault
fn_imgInput images STAR file:"" (required)
fn_contContinue from here:"" (continue only)
nr_classesNumber of classes:1
tau_fudgeRegularisation parameter T:2
particle_diameterMask diameter (A):200
do_ctf_correctionDo CTF-correction?True
ctf_intact_first_peakIgnore CTFs until first peak?False
do_zero_maskMask individual particles with zeros?True
highres_limitLimit resolution E-step to (A):None
do_centerCenter class averages?True
dont_skip_alignPerform image alignment?True
psi_samplingIn-plane angular sampling:6.0
offset_rangeOffset search range (pix):5
offset_stepOffset search step (pix):1
allow_coarserAllow coarser sampling?False

Outputs: Class average images (.mrcs) and per-iteration data/optimiser STAR files in Class2D/jobNNN/.

Continuation: can_continue=True. When get_continuation_job() is called, continuation_joboption_updates() automatically sets fn_cont to the most recently completed *_optimiser.star file found in the job directory and advances the iteration default. For optimiser-based jobs you must ensure fn_cont is set in continue_job.star before calling continue_job(); get_continuation_job() populates this automatically.

Helical variants (relion.class2d.em.helical, relion.class2d.vdam.helical) add:

KeyLabelDefault
do_bimodal_psiDo bimodal angular searches?True
range_psiAngular search range - psi (deg):6.0
helical_tube_outer_diameterTube diameter (A):200.0
do_restrict_xoffRestrict helical offsets to rise:True
helical_riseHelical rise (A):4.75

The 19-key helical refinement set (including helical_nr_asu, helical_rise_initial) applies only to 3D helical jobs, not 2D.


3D classification (relion.class3d and variants)

Category: 3D Classification

All 3D classification variants output into Class3D/ and share can_continue=True.

Primary inputs:

KeyDescription
fn_imgParticles STAR file (required)
fn_refReference map (required, NODE_DENSITYMAP); the multiref variants take several maps (Reference maps:)
fn_maskReference mask (optional, NODE_MASK3D)
fn_contOptimiser STAR file (continue only, NODE_OPTIMISERDATA)

Key option keys:

KeyLabelDefault
fn_imgInput images STAR file:"" (required)
fn_contContinue from here:"" (continue only)
fn_maskReference mask (optional):""
ref_correct_greyscaleRef. map is on absolute greyscale?False
ini_highInitial low-pass filter (A):60
sym_nameSymmetry:"C1" (required)
nr_classesNumber of classes:1
tau_fudgeRegularisation parameter T:4
nr_iterNumber of iterations:25
do_ctf_correctionDo CTF-correction?True
do_fast_subsetsUse fast subsets (for large data sets)?False
particle_diameterMask diameter (A):200
do_zero_maskMask individual particles with zeros?True

Note: relion.class3d does not register do_solvent_fsc; that option belongs to relion.refine3d only.

Multiref variants (relion.class3d.multiref, relion.class3d.helical.multiref) accept multiple initial reference maps.

Helical variants (relion.class3d.helical, relion.class3d.helical.multiref) add the full 19-key helical refinement option set, including:

KeyLabelDefault
helical_tube_outer_diameterTube diameter - outer (A):0
helical_tube_inner_diameterTube diameter - inner (A):None
helical_nr_asuNumber of unique asymmetrical units:1
helical_z_percentageCentral Z length (%):30.0
helical_twist_initialInitial helical twist (deg):0
helical_rise_initialInitial helical rise (A):0
do_apply_helical_symmetryApply helical symmetry?True
do_local_search_helical_symmetryDo local searches of symmetry?False
range_rotAngular search range - rot (deg):15
range_tiltAngular search range - tilt (deg):15
range_psiAngular search range - psi (deg):15
helical_range_distanceRange factor of local averaging:-1.0
keep_tilt_prior_fixedKeep tilt-prior fixed:True

Initial model generation (relion.initialmodel)

Category: Initial Model Generation
Output dir: InitialModel/
Programs: relion_refine, relion_align_symmetry
can_continue: True

This job uses a gradient-driven VDAM algorithm to generate a de novo 3D model. Because it uses VDAM, it has no nr_mpi option.

Key option keys:

KeyLabelDefault
fn_imgInput images STAR file:"" (required)
fn_contContinue from here:"" (continue only)
nr_iterNumber of VDAM mini-batches:200
tau_fudgeRegularisation parameter T:4
nr_classesNumber of classes:1
sym_nameSymmetry:"C1" (required)
do_run_C1Run in C1 and apply symmetry later?True
particle_diameterMask diameter (A):200
do_solventFlatten and enforce non-negative solvent?True
do_ctf_correctionDo CTF-correction?True
samplingInitial angular sampling:"15 degrees" (index 1)
offset_rangeOffset search range (pix):6
offset_stepOffset search step (pix):2

Outputs: run_it<NNN>_optimiser.star (NODE_OPTIMISERDATA), run_it<NNN>_data.star (NODE_PARTICLEGROUPMETADATA), one .mrc per class (NODE_DENSITYMAP) and initial_model.mrc (NODE_DENSITYMAP), all in InitialModel/jobNNN/.


3D auto-refinement (relion.refine3d and relion.refine3d.helical)

Category: 3D Refinement
Output dir: Refine3D/
Program: relion_refine
can_continue: True

relion.refine3d uses the gold-standard FSC approach. It does not register nr_iter; that option belongs to classification jobs only.

Key option keys:

KeyLabelDefault
fn_imgInput images STAR file:"" (required)
fn_refReference map:"" (required)
fn_maskReference mask (optional):""
fn_contContinue from here:"" (continue only)
ref_correct_greyscaleRef. map is on absolute greyscale?False
ini_highInitial low-pass filter (A):60
sym_nameSymmetry:"C1" (required)
do_ctf_correctionDo CTF-correction?True
particle_diameterMask diameter (A):200 (required)
do_zero_maskMask individual particles with zeros?True
do_solvent_fscUse solvent-flattened FSCs?False

Continuation: Sets fn_cont via find_current_opt_name() to the latest *_optimiser.star in the job directory. For relion.refine3d, continuation sets fn_cont (not in_optimiser) to the current optimiser file.

relion.refine3d.helical adds the full 19-key helical option set. Its helical-specific options use the labels Initial helical rise (A): and Initial helical twist (deg):, both defaulting to 0.0.


Multi-body refinement (relion.multibody.refine)

Category: Multi-body Refinement
Output dir: MultiBody/
Program: relion_refine
can_continue: True

Key option keys:

KeyLabelDefault
fn_inConsensus refinement optimiser.star:"" (required)
fn_bodiesBody STAR file:"" (required)
fn_contContinue from here:"" (continue only)
do_subtracted_bodiesReconstruct subtracted bodies?True
do_blushUse Blush regularisation?False
samplingInitial angular sampling:index 4
offset_rangeInitial offset range (pix):3
offset_stepInitial offset step (pix):0.75

Outputs: Half-maps per body — run_half1_body<NNN>_unfil.mrc — registered as NODE_DENSITYMAP. The final optimiser STAR file is added as a post-run output node.

Continuation: For continuation, fn_cont must point to a valid *_optimiser.star file. Unlike the classification, initial-model and refinement jobs, this job does not override continuation_joboption_updates(), so get_continuation_job() does not populate fn_cont; set it yourself.


Flexibility analysis (relion.multibody.flexanalysis)

Category: Multi-body Refinement
Output dir: MultiBody/
Program: relion_flex_analyse
can_continue: False

This job analyses the principal motions of a completed multi-body refinement. It cannot be continued.

Key option keys:

KeyLabelDefault
input_modelInput model file"" (required)
fn_bodiesBody STAR file:"" (required)
nr_moviesNumber of eigenvector movies:3
do_selectSelect particles based on eigenvalues?False
select_eigenvalSelect on eigenvalue:1
eigenval_minMinimum eigenvalue:-999
eigenval_maxMaximum eigenvalue:999

CTF refinement (relion.ctfrefine)

Category: CTF Refinement
Output dir: CtfRefine/
Program: relion_ctf_refine
can_continue: True

Key option keys:

KeyLabelDefault
fn_dataParticles (from Refine3D):"" (required)
fn_postPostprocess STAR file:"" (required)
minresMinimum resolution for fits (A):30
do_ctfPerform CTF parameter fitting?True
do_defocusFit defocus?"No"
do_astigFit astigmatism?"No"
do_bfactorFit B-factor?"No"
do_phaseFit phase-shift?"No"
do_tiltEstimate beamtilt?False
do_trefoilAlso estimate trefoil?False
do_4thorderEstimate 4th order aberrations?False
do_aniso_magEstimate (anisotropic) magnification?False

The do_defocus and do_astig options accept 'No', 'Per-micrograph', or 'Per-particle' (capitalised).

Output: particles_ctf_refine.star (NODE_PARTICLEGROUPMETADATA), logfile.pdf (NODE_LOGFILE).


Bayesian Polishing — polishing (relion.polish)

Category: Particle Polishing
Output dir: Polish/
Program: relion_motion_refine
can_continue: True

Key option keys:

KeyLabelDefault
fn_micMicrographs (from MotionCorr):"" (required)
fn_dataParticles (from Refine3D or CtfRefine):"" (required)
fn_postPostprocess STAR file:"" (required)
first_frameFirst movie frame:1
last_frameLast movie frame:None
extract_sizeExtraction size (pix in unbinned movie):None
rescaleRe-scaled size (pixels):None
opt_paramsOptimised parameter file:""
do_own_paramsOR use your own parameters?False
sigma_velSigma for velocity (A/dose):0.2
sigma_divSigma for divergence (A):5000
sigma_accSigma for acceleration (A/dose):2
minresMinimum resolution for B-factor fit (A):20
maxresMaximum resolution for B-factor fit (A):None

Outputs: shiny.star (NODE_PARTICLEGROUPMETADATA), logfile.pdf (NODE_LOGFILE).

Note: The training job (relion.polish.train) outputs opt_params_all_groups.txt (not opt_params.txt).


Particle subtraction (relion.subtract)

Category: Particle Subtraction
Output dir: Subtract/
Program: relion_particle_subtract
can_continue: False

This job requires at least 2 MPI processes (nr_mpi minimum is 2).

Key option keys:

KeyLabelDefault
fn_optInput optimiser.star:""
fn_maskMask of the signal to keep:"" (required)
fn_dataInput particle STAR file:""
do_dataUse different particles?False
do_center_maskDo center subtracted images on mask?True
do_center_xyzDo center on my coordinates?False
center_xCenter coordinate (pix) - X:0
center_yCenter coordinate (pix) - Y:0
center_zCenter coordinate (pix) - Z:0
new_boxNew box size:None

Output: particles_subtracted.star (NODE_PARTICLEGROUPMETADATA).


Revert subtraction (relion.subtract.revert)

Category: Particle Subtraction
Output dir: Subtract/
Program: relion_particle_subtract
can_continue: False

KeyLabel
fn_fliplabelrevert this particle STAR file:

Output: original.star (NODE_PARTICLEGROUPMETADATA).


DynaMight continuous heterogeneity (dynamight)

Category: Continuous Heterogeneity
Output dir: DynaMight/
Program: DynaMight executable (resolved via PIPELINER_DYNAMIGHT_EXECUTABLE or RELION_DYNAMIGHT_EXECUTABLE; defaults to relion_python_dynamight if on PATH, else dynamight)
can_continue: False

DynaMight cannot be continued via the pipeliner's continue_job mechanism. To extend training, run a new dynamight job using the checkpoint from a previous job.

Key option keys:

KeyLabelDefault
do_est_motionEstimate heterogeneous motions?False
fn_checkpointOR: Use motion estimation from a previous DynaMight job""
fn_starInput images STAR file:""
fn_mapConsensus map:""
nr_gaussiansNumber of Gaussians:10000
initial_thresholdInitial map threshold (optional):None
reg_factorRegularization factor:1
do_inverseDo inverse-deformation estimation?False
nr_epochsNumber of epochs to perform:200
do_reconstructDo deformed backprojection?False
backproject_batchsizeBackprojection batchsize:10
do_store_deformStore deformations in RAM?False
gpu_idWhich (single) GPU to use:"0"
do_preloadPreload images in RAM?False

Symmetry expansion (relion.image_analysis.symmetry_expansion)

Category: (Image Analysis)
Output dir: SymmetryExpansion/
Program: relion_particle_symmetry_expand
can_continue: False

KeyLabelDefault
input_particlesInput particles file:"" (required)
symmetrySymmetry:"C2" (required, must be C2 or higher)
do_helixDo helical symmetry expansion?False
twistHelical twist (degrees):0
riseHelical Rise (Å):0
asuNumber of asymmetric units to expand:1

Output: expanded.star (NODE_PARTICLEGROUPMETADATA).


Continuation behaviour summary

For all optimiser-based jobs (relion.class2d.*, relion.class3d.*, relion.initialmodel, relion.refine3d.*, relion.multibody.refine), the fn_cont option must point to a valid *_optimiser.star file before a continuation is launched. The safest path is:

  1. Call PipelinerProject.get_continuation_job(job_name) — this auto-populates fn_cont via continuation_joboption_updates() (except for relion.multibody.refine, where you must set fn_cont on the returned job yourself).
  2. Pass the returned job to PipelinerProject.run_job(). PipelinerProject.schedule_job() accepts only a dict or a job file and refuses continuation jobs.

If you call PipelinerProject.continue_job(job_name) directly, you must manually set fn_cont in continue_job.star first; continue_job() does not check can_continue and does not auto-populate fn_cont.

Jobs with can_continue=False (relion.subtract, relion.subtract.revert, relion.multibody.flexanalysis, dynamight, relion.image_analysis.symmetry_expansion, all relion.select.*) must be rerun as new jobs if inputs or parameters change.


Examples

Example 1 — Run a 2D classification job from a parameters dict

This example schedules and runs an EM-algorithm 2D classification from the Python API. Job options are set via the .value property on each JobOption in job.joboptions.

import os
os.chdir("/path/to/my/project")

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

params = {
    "_rlnJobTypeLabel": "relion.class2d.em",
    "fn_img": "Extract/job003/particles.star",
    "nr_classes": "50",
    "tau_fudge": "2",
    "particle_diameter": "180",
    "do_ctf_correction": "Yes",
    "nr_mpi": "4",
    "nr_threads": "6",
}

job = proj.run_job(params, run_in_foreground=True)
print(job.output_dir)  # e.g. Class2D/job004/

Example 2 — Continue a 3D classification job with modified regularisation

After a relion.class3d job completes, you can continue it from its last iteration with an updated tau_fudge. continue_job() reads continue_job.star in the job directory (written when the job was scheduled) and does not fill in fn_cont for you: for optimiser-based jobs it raises ValueError unless fn_cont names an _optimiser.star file, and also unless nr_iter is larger than the iteration you continue from. Set both with edit_jobstar() before calling continue_job().

import os
os.chdir("/path/to/my/project")

from pipeliner.api.manage_project import PipelinerProject
from pipeliner.api.api_utils import edit_jobstar

proj = PipelinerProject()

# Suppose Class3D/job005/ has Succeeded after 25 iterations
job_name = "Class3D/job005/"
template = "Class3D/job005/continue_job.star"

# Point fn_cont at the last optimiser file, raise nr_iter above 25,
# and change tau_fudge; write the edited file back in place.
edit_jobstar(
    template,
    {
        "fn_cont": "Class3D/job005/run_it025_optimiser.star",
        "nr_iter": "35",
        "tau_fudge": "6",
    },
    template,
)

cont_job = proj.continue_job(job_name, run_in_foreground=True)
print(cont_job.output_dir)

Example 3 — Generate and run an initial model job from a run.job file

Use pipeliner --default_runjob to generate a template, edit it, then submit it.

# Generate the template run.job file
pipeliner --default_runjob relion.initialmodel
# Produces: relion_initialmodel_run.job

# Edit the file — labels must match exactly as printed by --default_runjob
# Example: set the input STAR file and number of mini-batches
sed -i.bak 's|Input images STAR file: == .*|Input images STAR file: == Select/job004/particles.star|' relion_initialmodel_run.job
sed -i.bak 's|Number of VDAM mini-batches: == .*|Number of VDAM mini-batches: == 300|' relion_initialmodel_run.job

# Run the job (creates InitialModel/job006/)
pipeliner --run_job relion_initialmodel_run.job

Example 4 — Run 3D auto-refinement and wait for completion before continuing

When building an automated pipeline, use run_in_foreground=True or wait_for_job_to_finish() to sequence dependent jobs.

import os
os.chdir("/path/to/my/project")

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

refine_params = {
    "_rlnJobTypeLabel": "relion.refine3d",
    "fn_img": "Select/job005/particles.star",
    "fn_ref": "InitialModel/job006/run_it200_class001.mrc",
    "sym_name": "C1",
    "particle_diameter": "180",
    "ini_high": "60",
    "nr_mpi": "5",
    "nr_threads": "8",
}

# Launch without blocking
refine_job = proj.run_job(refine_params)

# Block until the job finishes (or times out after 24 hours by default)
final_status = proj.wait_for_job_to_finish(
    refine_job, error_on_fail=True
)
print(final_status)  # 'Succeeded' or 'Aborted'; with error_on_fail=True a failed job raises RuntimeError

Example 5 — Bayesian polishing using the Python API

import os
os.chdir("/path/to/my/project")

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

polish_params = {
    "_rlnJobTypeLabel": "relion.polish",
    "fn_mic": "MotionCorr/job002/corrected_micrographs.star",
    "fn_data": "CtfRefine/job009/particles_ctf_refine.star",
    "fn_post": "PostProcess/job010/postprocess.star",
    "first_frame": "1",
    "do_own_params": "Yes",
    "sigma_vel": "0.2",
    "sigma_div": "5000",
    "sigma_acc": "2",
    "minres": "20",
    "nr_mpi": "4",
    "nr_threads": "6",
}

polish_job = proj.run_job(polish_params, run_in_foreground=True)
print(polish_job.output_dir)  # e.g. Polish/job011/

Example 6 — Inspect job availability before scheduling

Before scheduling a job that requires RELION, check that the executables are available.

from pipeliner.job_factory import get_job_types

jobs = get_job_types(search_term="relion.refine3d")
for job in jobs:
    print(job.PROCESS_NAME, job.jobinfo.is_available)
    if not job.jobinfo.is_available:
        print(" Reason:", job.jobinfo.unavailable_message)