4d — RELION 2D Classification

Datasets scripts · 4d User Manual

← Back to the Datasets tab · Relaunching · RELION 3D Reconstruction

RELION 2D Classification core workflow

This script (dataset/tasks/30_Relion2DClassification.script, a Bash script) runs a RELION 2D classification on the particles that the single-particle step extracted from all images of the project, or from the most recent images only. If earlier runs left classes in Class2D_RealTime/, a new run builds on them instead of starting from scratch (relion_continue_from_earlierresults). It is made to follow the data collection: started with the relaunch fields set, it runs again every few minutes, each time on the images as they are then (all, or the newest) and starting from the classes of the run before, so the class averages keep up with what the microscope delivers. Every finished iteration appears at once as a tiled image of the class averages.

The Datasets tab after a run of the RELION 2D classification

After a first run with three iterations on the ten most recent images: the Images pane lists, for every iteration, the tiled class averages (important, in red), the stack of averages and the model; the File Preview shows the tiled averages of iteration 3, twenty classes of apoferritin with a 500 Å scale bar; the Output ends with the iterations done. The relaunch fields are set to a run every 60 minutes, 24 times, so the next run will start from these classes.

What it needs

Parameters

ParameterRole
dataset_dirThe dataset directory under merge/; the runs go into Class2D_RealTime/ below it.
relion_continue_from_earlierresultsy = a run builds on the classes of earlier runs in Class2D_RealTime/ (see References below); n = the first run of a launch starts from scratch, and only the relaunched runs of the series build on the run before them. Earlier runs are kept either way.
relion_work_on_ally = every image with particles takes part; n = only the last_imgs most recent ones. Images in TRASH are left out.
last_imgsWith relion_work_on_all = n: how many images take part, those whose single-particle step finished most recently, newest first (by the time of their spa_particles.star). Frozen with relion_work_on_all = y.
spa_diameterThe particle diameter of the single-particle step, in Å. Used for the mask when no mask diameter is given.
relion_kNumber of classes (--K). Each class needs a few hundred particles for a meaningful average.
relion_iterIterations (--iter), 25 by default.
relion_tau2_fudgeRegularisation parameter T (--tau2_fudge); 2 is usual for 2D.
relion_ptcl_diameterMask diameter in Å (--particle_diameter). A negative value takes 1.2 × spa_diameter; when that is unset, 0.95 × the smallest particle box. A mask that would not fit into the box is reduced to 0.95 × the box, with a warning.
relion_psi_stepIn-plane angular sampling in degrees (--psi_step).
relion_offset_range, relion_offset_stepTranslational search range and step in pixels of the stack (--offset_range, --offset_step). The boxes are centred already, so a small range suffices.
relion_ctfy adds --ctf. Leave it at n for particles from ptychographic reconstructions, whose images are not CTF-modulated.
relion_mpi, relion_nthreadsMPI processes (1 = no MPI) and threads per process (--j). Their product should not exceed the CPU cores; with MPI, one process coordinates and the others work.
relion_poolParticles per thread at a time (--pool).
relion_preready reads all particles into memory first (--preread_images).
relion_use_scratch_diry copies the particles to the FAST_DISK of the Preferences first (--scratch_dir).
relion_gpu, relion_gpu_numbers, relion_free_gpu_memoryn = CPU only; y = the GPUs of relion_gpu_numbers, a RELION device list such as 0:1 (--gpu 0:1); * = all GPUs (--gpu). A device list written into relion_gpu itself, as older projects have it, still selects those GPUs. The memory to leave free per GPU in MB. Needs a RELION built with CUDA (not available on macOS).
relion_extraFurther options passed to relion_refine as typed, e.g. --center_classes.
KV, CS, phaconVoltage, Cs and phase-contrast portion for the STAR file. A voltage or Cs left at ScriptWillPutNumberHere is replaced by the Preferences' default and written back to the project.

Algorithm

  1. Run directory. Every run writes into the next directory after the runs already in <dataset_dir>/Class2D_RealTime/: run_001/ for the first one, then run_002/, and so on, also across separate launches. Earlier runs are kept. The first run of a series (run_iteration_number 1, or a single run) clears the results list; a later run adds to the results of the runs before it.
  2. Image list. All spa_particles.star files of the project, or with relion_work_on_all = n the last_imgs newest ones, as <group>/<image>, go to all_images.txt (or last<N>.txt) in the run directory. The STAR file particles_all.star (or particles_last<N>.star) is made from them by the same generator as the dataset STAR file: one optics group per image, the stacks linked into Particles/. Both files are listed as results straight away.
  3. Mask. The mask diameter is settled as described for relion_ptcl_diameter, against the smallest particle box in the STAR file.
  4. References. With relion_continue_from_earlierresults = y and earlier runs present, the classes of the last iteration completed by the newest earlier run that completed one (its run_itNNN_model.star; an iteration is complete once RELION has written its _sampling.star) are the references (--ref) — RELION takes the number of classes from them. A run that stopped before its first iteration is passed over. If no earlier run left classes, or they are a different number than relion_k asks for, the run starts from scratch with --K relion_k, and says so. With n, the first run of a launch starts from scratch, and a relaunched run looks only at the run just before it.
  5. RELION. relion_refine (or mpirun -np relion_mpi relion_refine_mpi) runs with the parameters above and --dont_combine_weights_via_disc --flatten_solvent --zero_mask --oversampling 1 --norm --scale. The full command is printed in the log; RELION's own output goes to run_output.txt in the run directory.
  6. While it runs, the script checks every second for iterations RELION has completed. For each one it tiles the class averages into a single image (run_itNNN_classes-tiled.mrc, a square grid of √K × √K panels, by proc/4d/4d_tile_mrcs.py) and lists it as an important result, together with the stack of averages (…_classes.mrcs) and the model (…_model.star). The progress bar advances by iteration and the GUI re-reads the results, so the newest averages appear in the File Preview as soon as they exist.
  7. If RELION stops with an error, the last lines of its output are shown and the run fails.

Results

File (in run_00n/)What it is
all_images.txt or last<N>.txtThe images of this run, newest first.
particles_all.star or particles_last<N>.star, Particles/Their particles, RELION 3.1+ STAR file and links to the stacks.
run_itNNN_classes-tiled.mrcThe class averages of iteration NNN, tiled — a 2D image for the File Preview. Marked important.
run_itNNN_classes.mrcs, run_itNNN_model.star, run_itNNN_data.star, …RELION's files of the iteration. The 3D step reads the model.star and data.star of the last iteration.
run_output.txtRELION's own output.
In the Results panel the files of every run of a series follow each other, each labelled with its iteration and run number. The tiled image of the last iteration of the last run is the one to watch; the class numbers RELION uses (for the 3D step's class list) count its panels row by row from the top left.