PickMe-EM 🎯
A tool to incorporate into membrane segmentation-based workflows. Typical workflows involving membranes involve:
- Membrane segmentation
- Oversample the segmentation of desired objects to get particle picks
- Clean up particle picks
- Assign angles to particle picks
- Export particles
- Additional processing to push resolution
This tool looks to address the issue of parts 2 and 3 and provide some level of standardisation in this part of the workflow. At the moment individual groups write custom scripts to address the needs of the individuals analysing the data — this leads to high levels of redundancy.
This project looks to reduce that redundancy and aid in membrane oversampling, particle picking and other analysis and clean-up by being an open-source, easy-to-use and customisable tool.
Disclaimer
I am very open to contributions to this project by anyone interested. For additional tools/functionalities that you feel should be contributed, or want to contribute yourself, feel free to contact me (see pyproject.toml for contact info, and CONTRIBUTING.md for how to get started).
Additional disclaimer
This is intended as a CLI tool. However, there are some useful functions in this package which you could import and use in your own scripts.
What PickMe does
PickMe takes a membrane segmentation (for example from MemBrain-seg) and turns it into particle picks with Euler angles already assigned. It removes small, noisy objects with a volume-normalised knee filter, lets you click the membranes you want in napari, then oversamples each chosen membrane surface at a spacing you set and writes RELION-style STAR files.
segmentations + tomograms (.mrc)
| |
v |
filter_objects | drop noisy objects (knee filter)
| |
v v
choose_objects <-------+ click membranes in napari
|
v
particle_extraction sample surface, compute Euler angles
|
v
particles.star -> Warp / M / RELION, Dynamo, ...
PickMe is meant to be a highly modular tool used in conjunction with other tools. Where it fits in a cryo-ET pipeline:
Collect tilt-series
-> pre-process tilt-series
-> get tomogram reconstructions
-> run your favourite segmentation software
-> PickMe
-> your favourite downstream particle processing pipeline
(Warp/M/RELION, Dynamo, IMOD, etc.)
Example 1 — round-trip with MemBrain-seg. Take a segmentation from MemBrain-seg, filter it and pick specific membranes with PickMe, then feed those individual membranes back to MemBrain-seg to re-train. choose_objects --write-selections exists for this: it writes each object as its own uncompressed .mrc.
Example 2 — feeding a subtomogram averaging pipeline. Oversample the membrane surface to generate particle picks with Euler angles already calculated, and hand the resulting STAR file to the Warp/M/RELION pipeline.
Installation
- OS-independent
- Requires Python >= 3.12, < 3.14
Recommended: conda (PyQt6)
The repository ships a PickMe.yml conda environment file. It installs the napari/Qt6 stack from conda-forge, because installing Qt through pip tends to mix incompatible Qt libraries and break napari, which choose_objects needs.
git clone https://github.com/janti001/PickMe.git
cd PickMe
conda env create -f PickMe.yml
conda activate PickMe
PickMe -h
The environment is called PickMe — capital P, capital M. Conda environment names are case-sensitive on Linux, so conda activate pickme fails with EnvironmentNameNotFound.
The last step of PickMe.yml runs pip install --no-deps -e ., so creating the environment already installs PickMe in editable mode. git pull is enough to pick up new versions.
Clusters that require Qt5: conda (PyQt5)
Some older HPC clusters can only provide Qt5. Use the PyQt5 environment instead:
conda env create -f PickMe-pyqt5.yml
conda activate PickMe-pyqt5
It is named PickMe-pyqt5, so it can live alongside the default environment, and it sets QT_API=pyqt5 on activation so napari uses the Qt5 binding. Everything else is identical to PickMe.yml. Prefer the default PyQt6 environment everywhere else.
Alternative: pip
conda create -n pickme-pip python=3.12
conda activate pickme-pip
pip install PickMe-EM # headless: filter_objects, particle_extraction,
# decompress, convert. No napari, no Qt
pip install "PickMe-EM[gui]" # adds napari + PyQt6 for choose_objects
pip install "PickMe-EM[gui-pyqt5]" # adds napari + PyQt5 (old Linux/HPC only)
Warning: install one Qt binding, never both.
[gui]and[gui-pyqt5]are alternatives; installing both puts two competing bindings in one environment.
The GUI stack is an optional extra so that a headless cluster install does not pull in an OpenGL/Qt stack it can never use. If napari fails to launch from a pip install, use one of the conda routes or the container.
Development install
git clone https://github.com/janti001/PickMe.git
cd PickMe
pip install -e ".[gui]" # or use the conda route above
More install help
- docs/gui-setup.md — getting a napari window to open on WSL and HPC, what is pinned and why. Start here if the GUI will not open.
- container/README.md — Apptainer/Docker image that ships the whole stack. Note the image has not yet been built successfully (see Known limitations).
Quick start
A worked example on MemBrain-seg output. Your tomograms are in /data/tomograms (e.g. TS_1166_10.00Apx.mrc) and the segmentations in /data/segmentations (e.g. TS_1166_10.00Apx_MemBrain_seg_v10_beta.ckpt_segmented.mrc).
mkdir my_pickme_project && cd my_pickme_project # outputs land in ./outputs
conda activate PickMe
# 1. Drop noisy objects -> outputs/filter/job001/
PickMe filter_objects --input-dir /data/segmentations
# 2. Click the membranes you want -> outputs/choose/job002/
PickMe choose_objects --input-dir /data/tomograms
# 3. Sample the surface -> outputs/particle_extraction/job003/
PickMe particle_extraction --sample-rate 5 --cmm
Each stage finds the previous one automatically (the latest filter job, then the latest choose job). Your particles are in outputs/particle_extraction/job003/particles.star.
At the prompts, files are chosen by index (see File naming); answering n to "specific files?" takes all of them.
Job types
PickMe writes everything under an output root (default ./outputs, relative to where you run it; --output-dir moves the whole root). Each run gets <root>/<job_name>/jobNNN, numbered from one counter shared by all job types (filter/job003 is followed by choose/job004). --input-job 1 and --input-job 001 both mean job001. Full option tables are in docs/cli-reference.md; the stage-by-stage walkthrough is in docs/pipeline.md.
filter_objects
Finds every *segment* file in --input-dir, labels the objects, and keeps those past a volume-normalised knee, removing small noise.
- Key options:
--input-dir(required),--output-dir,--non-interactive. (--filteris accepted but only one filter exists.) - Outputs:
outputs/filter/jobNNN/<segmentation id>_filtered.mrc.gzand a knee diagnostic plotplots/<segmentation id>_knee.png.
choose_objects
Opens napari so you can pick membranes by clicking them, one tomogram at a time.
- Key options:
--input-dir(tomograms, required),--segmentation-dir,--input-job,--write-selections,--non-interactive. - Segmentations come from
--segmentation-dir, else--input-job, else the latest filter job. - In napari, a "PickMe objects" panel on the right has a tomogram dropdown with Previous/Next and a list of your selections. Click an object to select it, click again to deselect. Selected objects are green, unselected magenta. Dragging pans or rotates and never selects. It works in both 2D and 3D views. Selections are remembered as you switch tomograms. Close the window to write the result.
- Answering
nto "Are there any objects which you would like to select (y/n)?" cancels the job: nothing is written. - Outputs:
outputs/choose/jobNNN/<tomogram id>_chosen.mrc.gzper tomogram; with--write-selections,<tomogram id>_membranes/<tomogram id>_obj<label>.mrcper object (uncompressed, voxels set to 1).
particle_extraction
Gaussian-smooths each object, runs marching cubes, samples the surface at your spacing and computes Euler angles from the surface normals. Never prompts.
- Key options:
--sample-rate(required, pixels),--input-dir,--input-job,--cmm,--tomogram-dir. - Input:
--input-job, else--input-dir, else the latest choose job. - For segmentations not produced by PickMe, pass
--tomogram-dirso each is paired to its tomogram by name; otherwiserlnMicrographNameis derived from the segmentation name and PickMe warns you. - Outputs in
outputs/particle_extraction/jobNNN/: one<name>.starper input, an aggregateparticles.star,AnglePlots/<name>.png, and<name>.cmmChimera markers with--cmm. STAR columns includerlnCoordinateX/Y/Z,rlnAngleRot/Tilt/Psi,rlnMicrographName,rlnObjectandrlnImagePixelSize.
decompress
Converts .mrc.gz / .mrc.bz2 to plain .mrc for viewing in Chimera/ChimeraX.
- Key options:
--input-diror--input-job(give one),--non-interactive. - Output:
outputs/decompress/jobNNN/<id>_decompressed.mrc(voxel size copied).
convert
Casts tomograms to another data type for software that is fussy about it.
- Key options:
--input-dir(file or directory, required),--non-interactive.--data-typeis accepted but ignored; output is always float32. - Output:
outputs/convert/jobNNN/<id>_f32.mrc(voxel size copied from the input).
File naming
PickMe does not assume any naming scheme such as TS_<id>.
- Tomogram = any
*.mrc. Segmentation = any.mrc,.mrc.gzor.mrc.bz2whose name containssegment. - A file's id is its name minus
.mrc/.mrc.gz/.mrc.bz2:TS_1166_10.00Apx.mrchas idTS_1166_10.00Apx. - Pairing by prefix. A segmentation belongs to the tomogram whose id is the longest prefix of its file name, ending at a separator (
_,.,-). SoTS_1166_10.00Apx_MemBrain_seg_v10_beta.ckpt_segmented.mrcpairs withTS_1166_10.00Apx.mrc, andlamella_B10_segpairs withlamella_B10, neverlamella_B1. - Unmatched or ambiguous segmentations trigger a prompt asking which tomogram each belongs to (blank skips it). Under
--non-interactivethey are skipped with a warning. - Selecting files by index. Lists are numbered (
1. name); type1 3 5-8,1,3orall. You never type names. Bad input is explained and asked again. rlnMicrographNamefollows the Warp/M convention: the tomogram id with a trailing_<number>Apxremoved, plus.tomostar.TS_1166_10.00ApxbecomesTS_1166.tomostar;lamella3_recbecomeslamella3_rec.tomostar.- Duplicate outputs. If two inputs would write the same name (
a.mrcanda.mrc.gzin one folder) PickMe prints a warning and carries on; the one processed last overwrites the others. - Outputs from older PickMe versions (e.g.
TS_1166_filtered.mrc.gz) do not start with the full tomogram id, so they go to the manual pairing prompt. Re-runfilter_objectsto get new names. - Arrays are handled in
zyxorder; STAR coordinates are written asX/Y/Z.
Running on a cluster
Four subcommands prompt (filter_objects, choose_objects, decompress, convert); particle_extraction never does. Add --non-interactive to take the default answer to every prompt so a batch job does not hang:
PickMe filter_objects --input-dir /scratch/$USER/segmentations --non-interactive
choose_objects needs a display, so under --non-interactive it cancels and writes nothing. Run choose_objects interactively on a machine with a graphical session first, then run particle_extraction on the cluster. See docs/gui-setup.md for how to split the pipeline around this.
Documentation map
| File | What it covers |
|---|---|
| docs/cli-reference.md | Every subcommand and option |
| docs/pipeline.md | Stage-by-stage walkthrough of the pipeline |
| docs/gui-setup.md | Getting napari to open on WSL/HPC; Qt5 vs Qt6; pinned versions |
| docs/known-issues.md | Catalogue of bugs and their status |
| container/README.md | Building and running the Apptainer/Docker image |
| CONTRIBUTING.md | How to contribute |
Known limitations
convert --data-typeis ignored. Output is always float32.filter_objects --filteris accepted but only one filter exists (volume-normalised knee detection).- Euler angles are not reproducible.
rlnAngleRotis drawn from an unseeded random number generator, so angles differ from run to run. A--seedoption is planned. choose_objectsneeds a graphical session, and cannot run under--non-interactive.- The container image has never been built successfully. Treat
container/as untested.
Potential new features coming
Different filter algorithms/types
- Implement an Otsu-threshold based filter on log-transformed volumes
- ML/DL classifier using a feature set of the objects
Particle coordinate manipulation
- Adding a particle coordinate offset so transmembrane proteins can be picked
Alternate file type outputs for particle coordinates
- Potentially writing wrappers which can handle the conversion of STAR files to file types other software uses, such as
.motl
Contributing
Contributions of any size are welcome — bug reports, feature ideas, documentation fixes and code. See CONTRIBUTING.md for the workflow.
Licence
GPL-3.0-or-later. See LICENSE.
Metadata
Release files for PickMe-EM 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pickme_em-1.0.0.tar.gz | 86.0 kB | Without provenance | Details for pickme_em-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pickme_em-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pickme_em-1.0.0-py3-none-any.whl |
Total release size: 169.2 kB
Release files / pickme_em-1.0.0.tar.gz
| Download URL | pickme_em-1.0.0.tar.gz |
|---|---|
| Size | 86.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb2e9b91fd856ac8fedcce557d128380eca565be1c83beed9e0f7d721c474c83
|
|
BLAKE2b-256 checksum How to use checksums |
690063970162bd1e38147873e495ff6f9b30153a7a7f9b91f0c1343a1c9ed048
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pickme_em-1.0.0-py3-none-any.whl
| Download URL | pickme_em-1.0.0-py3-none-any.whl |
|---|---|
| Size | 83.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5251ddb140ce440798781c6fa88a8a00c985ce4c63c09402dd2a7ed250d4d5db
|
|
BLAKE2b-256 checksum How to use checksums |
6433a437d51d4ecee321f10cbf3fa8096a0a843347761e585d21faa229575278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for PickMe-EM 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.