CryoNeFEN is a neural network based algorithm for cryo-EM reconstruction. In particular, the method models an isotropic representation of 3D structures using neural fields in the spatial domain.
# clone the repo.
git clone https://github.com/yuehuang2023/cryoNeFEN.git
cd CryoNeFEN
# Make a conda environment.
conda create -n cryonefen python=3.9 pytorch==1.13.0 torchvision==0.14.0 pytorch-cuda=11.6 -c pytorch -c nvidia
conda activate cryonefen
# Install required packages
conda install matplotlib
pip install starfile mrcfile scipy
Note: Please ensure that you have met the prerequisites for PyTorch, the code is tested with pytorch version 1.13, 2.0, and 2.1.
Perform a homogeneous refinement in cryoSPARC software. We will use the poses and CTF parameters from this "consensus reconstruction".
.cs
file directly. Copy the path of cryoSPARC's metadata file (.cs
file) that contains particle poses and CTF parameters.When the input image stack (.cs
file) has been prepared, a cryoNeFEN model can be trained with python train.py
:
python train.py -h
The required arguments are:
particles
, an input image stack (.cs
or other listed file types)-o
, a clean output directory for storing resultsAdditional parameters that are typically set include:
-n
, Number of epochs to train-b
, Batchsize of the image stack during the training--lazy
, Lazy loading if the full dataset is too large--mask
, Mask for accelerating the training--symmetry
, Enforce symmetry during training--split
, Split the image stack randomlyNeural network architecture settings
--layers
, Number of hidden layers--dim
, Number of hidden dims--pe-dim
, Number of sinusoid features in positional encodingIf the golden standard Fourier shell correlation (GSFSC) is required in further benchmarking, run commands:
python train.py {cryoSPARC directory}/xxx_particles.cs --mask {cryoSPARC directory}/xxx_volume_mask_refine.mrc --lazy --outdir ./tutorial/ --split 1
python train.py {cryoSPARC directory}/xxx_particles.cs --mask {cryoSPARC directory}/xxx_volume_mask_refine.mrc --lazy --outdir ./tutorial/ --split 2
Notes:
{cryoSPARC directory}/xxx_particles.cs
is the .cs
file processed in step 1.{cryoSPARC directory}/xxx_volume_mask_refine.mrc
is the mask refined by cryoSPARC.We strongly recommend using a mask to accelerate the training. In cryoSPARC, the refined mask can be found from the web interface as the "mask_refine" output.
Once the model has finished training, the generated density maps are saved in outdir
for further visualization, and analysis.
GSFSC of final results can be computed with python analysis.py
:
python analysis.py -h
Example usage:
python analysis.py ./tutorial/ --mask {cryoSPARC directory}/xxx_volume_mask_refine.mrc
Masked FSC curves and reconstructed maps will be plotted.
Heterogeneous reconstruction can be trained with python train_heter.py
:
Example usage:
python train_heter.py {cryoSPARC directory}/xxx_particles.cs --mask mask.mrc --zdim 8 --lazy --outdir ./tutorial/
Notes:
After the training, the heterogeneous density maps can be generated with commands in the file analysis_heter.ipynb
.
Trained models and reconstructed maps for EMPIAR-10005, EMPIAR-10049, EMPIAR-10076, EMPIAR-10492 are deposited here.
Huang, Y., Zhu, C., Yang, X. et al. High-resolution real-space reconstruction of cryo-EM structures using a neural field network. Nat Mach Intell (2024). https://doi.org/10.1038/s42256-024-00870-2