Generated banner for Relion
Generated logo for Relion

Relion

K-DenseCommunityCreated by K-Dense Inc.

  • Skill
  • Workflow
  • Science and research
  • MIT
  • Low risk
  • Has scripts

From the author

Validates and executes RELION single-particle cryo-EM refinement and half-map postprocessing. Supports STAR optics/acquisition checks, particle-stack consistency, gold-standard half sets, soft-mask validation, diagnostic Fourier shell correlation, and restart guidance.
— the description by K-Dense Inc.

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The relion skill provides a structured Python-based workflow for managing single-particle cryo-EM refinement and postprocessing using RELION 5.0.1. It focuses on ensuring data consistency by validating STAR files, optics groups, and particle stacks before executing refinement. The workflow supports gold-standard half-set refinement and provides diagnostic tools for Fourier shell correlation (FSC) and soft-mask validation, helping researchers maintain rigorous standards throughout the reconstruction process.

What it does

  • Validates STAR file metadata, optics groups, and particle stack consistency.
  • Executes gold-standard 3D refinement using MPI-parallelized RELION processes.
  • Performs diagnostic Fourier shell correlation (FSC) analysis on independent half-maps.
  • Facilitates postprocessing with soft-masking to refine map quality.
  • Provides guidance for restarting interrupted refinement jobs.
  • Checks for common data errors like non-finite metadata or mismatched map grids.

When to use it

  • When performing single-particle cryo-EM refinement on extracted, CTF-annotated particles.
  • When you need to validate the integrity of your particle stacks and optics groups before processing.
  • When conducting gold-standard refinement requiring independent half-set splitting.
  • When performing postprocessing on converged unfiltered half-maps.
  • When you need to generate diagnostic FSC curves for map resolution assessment.

Advantages

  • Ensures data consistency through automated pre-refinement validation checks.
  • Standardizes the execution of complex RELION commands via a unified interface.
  • Prevents common errors by verifying pixel sizes, box dimensions, and coordinate conventions.
  • Supports reproducible research by recording command history and process logs.
  • Provides clear diagnostic outputs for FSC and mask validation.

Usage examples

“Validate my particle STAR file before starting refinement.”
The skill runs a series of checks on the STAR file, verifying optics membership, particle indices, and stack accessibility, reporting any inconsistencies.
“Run a 3D refinement on my particle subset.”
The skill executes the RELION refinement process with specified symmetry, diameter, and MPI ranks, ensuring gold-standard half-set splitting.
“Calculate the FSC for my refined half-maps.”
The skill performs a diagnostic FSC calculation between the two unfiltered half-maps and outputs the results to a TSV file.
“Postprocess my refined maps with a soft mask.”
The skill validates the mask and map grids before running the RELION postprocessing utility to generate the final sharpened map.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/k-dense-ai/relion/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip relion.zip -d .agents/skills

Documentation by K-Dense Inc.

RELION single-particle refinement

Use for a RELION single-particle project, especially extracted particles → homogeneous selected particle subset → gold-standard refinement → half-map validation and postprocessing. The bundled runner starts from CTF-annotated extracted particles and an initial 3D reference. It does not replace motion correction, picking, 2D/3D selection, or a biological interpretation of map quality. For tomography, helical reconstruction, Blush, or heterogeneous-state modeling, use the appropriate upstream workflow rather than forcing those data into this bounded SPA runner.

Preserve acquisition and coordinate conventions

Read references/acquisition-and-restarts.md when starting from movies or resuming jobs. Confirm pixel size in Å/pixel, voltage in kV, spherical aberration in mm, defocus in Å, amplitude contrast as a fraction, and the symmetry justified by the specimen. Do not “correct” a suspicious value by guessing its units.

data_optics describes acquisition/image groups; data_particles references them through _rlnOpticsGroup. Particle filenames use one-based [email protected]; leading zeros such as [email protected] are valid. Relative paths resolve from the RELION project directory, not the STAR file's directory. Keep optics groups when merging or subsetting STAR files. _rlnOriginXAngst/_rlnOriginYAngst are Å translations, not pixels.

Run from this skill directory with paths to the real project:

python scripts/spa_workflow.py validate-star project/particles.star --project project

This opens referenced stacks and checks optics membership, finite acquisition/CTF values, indices, box sizes, duplicate particle references and existing half-set assignments. Use --metadata-only only when stacks are genuinely unavailable; the JSON records stack_checks_performed: false. It does not scan every particle pixel for corruption or establish correct image normalization. Physical-range warnings are review prompts, not proof that unusual microscope settings are wrong.

Refine a selected particle population

Before running, inspect representative particles and class averages, defocus distributions, CTF fits, particle orientation distribution, and the initial reference. Ensure the map and particle boxes/pixel sizes agree after any downsampling. The runner deliberately supports one effective box/pixel size across optics groups; handle heterogeneous sampling with an explicit upstream resampling workflow. Use conventionally extracted, normalized particles that have not already been phase-flipped or Wiener-filtered; this runner does not configure those special input cases.

python scripts/spa_workflow.py refine \
  --star project/particles.star --reference project/initial.mrc \
  --project project --diameter 180 --symmetry C1 \
  --initial-lowpass 40 --mpi-ranks 3 --threads 2 --output project/RefinePilot

The diameter and low-pass filter above are illustrative Å values. Use specimen-appropriate values. Refinement executes mpirun -np 3 relion_refine_mpi with --auto_refine, --split_random_halves, --ctf, and a low-pass starting reference. Gold-standard splitting requires MPI; the plain sequential relion_refine executable cannot perform this split. Use odd ranks ≥3 (master plus balanced half-set workers), with a matching MPI installation. The CPU command is useful for a bounded pilot; choose a documented GPU/MPI launch for full data.

The runner keeps the command, native version and log in a new output directory, records an explicit random seed (default 1), surfaces runtime warnings, stops on process failure, and requires converged unfiltered half maps before reporting success. It does not automatically retry expensive jobs or silently discard failed-job artifacts. Keep _optimiser.star, model/sampling STAR files, and referenced particle paths for restart. Use the original job's optimiser rather than starting a new random split from a partially processed table.

Inspect independent half maps

Use the two independently refined unfiltered half maps, never two copies of the combined, sharpened map. Matching headers cannot establish statistical independence; the independent particle assignments and refinement history provide that evidence. Inspect directional anisotropy, preferred orientation and local resolution as well as a global FSC curve.

python scripts/spa_workflow.py fsc \
  project/RefinePilot/run_half1_class001_unfil.mrc \
  project/RefinePilot/run_half2_class001_unfil.mrc --output diagnostic-fsc.tsv

This checks map dimensions, finite values, pixel size, origin, axis order and duplicate maps, then writes an unmasked diagnostic FSC. The reported 0.143 crossing uses linear interpolation; null means no downward crossing was detected, not infinite resolution. Nyquist resolution is 2 × pixel size. This diagnostic is limited to even cubic maps ≤256³; use RELION's native relion_image_handler --fsc for larger maps. It does not substitute for mask-corrected FSC. The helper requires real-space maps with canonical axes, zero MRC start indices and orthogonal cell angles. Convert other grids explicitly with provenance; merely editing headers can misalign density. Matching headers and FSC cannot determine absolute handedness.

Postprocess with a soft mask

Construct the solvent mask from an appropriately low-pass-filtered density, with an expanded boundary and a smooth edge. Inspect all slices; a tight mask can inflate correlation. Avoid a mask derived from high-frequency noise shared between half maps.

python scripts/spa_workflow.py postprocess \
  --half1 project/RefinePilot/run_half1_class001_unfil.mrc \
  --half2 project/RefinePilot/run_half2_class001_unfil.mrc \
  --mask project/soft_mask.mrc --output project/PostProcessPilot

The helper checks a nonconstant mask in [0,1], soft-edge voxels and matching map grids, then runs relion_postprocess with explicit half maps, mask and pixel size. RELION performs its own mask/randomization correction and writes postprocess.star. The bounded command leaves the B-factor at zero (no automatic B-factor estimation); add automatic/manual sharpening only after choosing a defensible fit range and inspecting map quality. A valid range and some fractional mask voxels do not prove the mask is scientifically appropriate. Inspect the phase-randomized masked FSC near the reported resolution: residual correlation calls for a smoother/wider mask and another postprocessing run.

See references/runtime-and-validation.md for the tested native utilities and the distinction between pipeline execution and reconstruction validation.

Primary references

Files

references/acquisition-and-restarts.md

Acquisition, job selection, and restart decisions

Before extracted particles

Keep the project's movie/micrograph paths, optics groups, dose information, and gain/detector metadata. For movies, confirm physical and super-resolution pixel sizes separately; a factor-of-two pixel-size error propagates into defocus, extraction diameter, map scale and reported resolution. For dose weighting, confirm dose per frame and pre-exposure rather than copying another dataset's settings. Inspect drift trajectories, damaged frames and residual motion after correction.

RELION has an internal CPU motion-correction implementation and wrappers for external tools. For CTF estimation, RELION 5.0 documentation specifies CTFFIND 4.1.x, not CTFFIND 5.x. A successful wrapper launch does not validate a CTF fit: inspect Thon rings, astigmatism, fit resolution, and defocus against acquisition expectations. Rejecting all high-defocus particles can introduce a selection bias; use documented criteria appropriate to the specimen and target resolution.

Before 3D auto-refine, select a reasonably homogeneous particle population using actual 2D/3D classification results. Do not interpret class occupancy as quantitative state populations without considering selection and alignment bias. Avoid imposing high symmetry solely because it improves nominal resolution. Use C1 when symmetry is unknown and test a justified alternative separately.

Path and sampling invariants

A STAR file in Extract/job010/ often points to paths relative to the project root. Moving only the STAR file does not move its dependencies. The bundled validator takes --project to make this explicit. It checks stack indices/box dimensions; optics pixel size is the sampling authority for particle processing and still needs acquisition/re-extraction verification.

After resizing a particle box, adjust image pixel size to preserve physical field of view and resample the initial reference consistently. Do not merely edit an MRC header to make a mismatch disappear. Keep translations in their declared units (Origin*Angst versus legacy pixel fields). For RELION's centered coordinate conventions, follow the official conventions page rather than interpreting map array indices as laboratory coordinates.

_rlnCoordinateX/_rlnCoordinateY are pixels in the aligned, summed micrograph, not the movie's super-resolution grid. RELION's Euler angles rotate the reference into the observed particle; origin offsets shift the observation into the reference projection, before rotation. The actual 5.0.1 labels are _rlnOriginXAngst/_rlnOriginYAngst (the conventions page spells the suffix out as Angstrom; the label definitions are authoritative). Avoid sign changes or Å-to-pixel conversion by intuition.

When merging optics tables, reconcile group names and acquisition settings, then remap IDs; the same numeric ID in two projects need not denote the same group. The validator is read-only and does not merge tables. RELION distinguishes maps (.mrc) from particle stacks (.mrcs), and the helper supports real-valued MRC modes including float16 mode 12. Native RELION can read packed mode 101, but mrcfile cannot; convert that input with a suitable native utility first.

RELION uses right-handed coordinates, but reconstruction handedness still requires independent assessment (for example, recognizable helix chirality at sufficient resolution or tilt data). FSC alone cannot choose the hand. If a justified hand inversion is needed, transform both half maps, mask and downstream coordinates consistently, and preserve the original maps.

Restart a stopped refinement

A completed iteration's _optimiser.star points to the sampling/model/data state required for continuation. Keep those referenced files and their relative paths together. Preserve the original half-set split. An example continuation, from the same project root with the original MPI runtime:

mpirun -np 3 relion_refine_mpi \
  --continue RefinePilot/run_it005_optimiser.star \
  --o RefineContinue/run --j 2

The iteration filename is illustrative: use the last intact checkpoint actually present and a new output prefix. Inspect the failing job log before deciding whether the cause was transient I/O, insufficient memory, invalid CTF metadata, an absent external tool, or scientific nonconvergence. Change one relevant condition, preserve the old job, and resume that checkpoint. Do not repeatedly restart a deterministic invalid-input failure.

The GUI's Continue operation uses the existing job directory; refinement continuations get prefixes such as run_ct23. The illustrative direct command above instead requests a separate output prefix. It does not register a job in default_pipeline.star, so retain the command, version/build, output prefix and source checkpoint alongside the results. This helper neither submits scheduler jobs nor implements RELION's External-job marker/output-node contract. Use the native GUI or Schemes when pipeline tracking is required; no remote service, HTTP API, authentication or pagination is involved here.

Reporting resolution

Report the FSC threshold and mask correction, pixel size, particle count, imposed symmetry and processing version. Keep both original half maps, the postprocessing STAR/PDF and mask. A scalar FSC estimate can hide preferred orientation and regional flexibility; inspect local and directional resolution and map-model validation before making structural claims. A high unmasked correlation from duplicated or coupled half maps is a failure of independence, not a high-resolution result. Independent half-set histories must also survive re-extraction and restart: renumbering particles or copying stacks does not create independent observations. The helper detects repeated references, not duplicate image content stored under distinct filenames.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python

The author says: Python 3.12+ with numpy, mrcfile and starfile for bundled validation; RELION 5.0.1 CPU/MPI executables for refinement and postprocessing. Native workflows require MPI, OpenMP and an FFT library (FFTW or MKL). GPU builds require their supported accelerator stack. Network is needed for installation only.

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
K-Dense Inc.
Publisher
K-Dense (Community)
Source
K-Dense-AI/scientific-agent-skills · skills/relion · commit a25cf9e
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by K-Dense Inc. or K-Dense.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download relion.zip