Automated Removal of Corrupted Tilts in Cryo-ET
📄 Published in Journal of Structural Biology: X
- Get ARCTiC source codes
git clone https://github.com/turonova/ARCTiC
cd ARCTiC
- Create ARCTiC conda environment using .yml file
conda env create -f environment.yml
The environment is based on Python 3.10 and uses Conda (conda-forge channel) with additional pip packages. CUDA-Enabled PyTorch: The environment uses torch==2.5.0+cu118 (CUDA 11.8).
- The code has the following dependencies:
torch– PyTorch for deep learning.torchvision– Computer vision utilities (datasets, transforms, models).timm– Pretrained models fromrwightman/pytorch-image-models.cryocat– Includescryomapfor handling cryo-ET images.numpy– Numerical computing.matplotlib– Visualization library for plots.tqdm– Progress bars.scikit-learn– Machine learning utilities, including classification reports and confusion matrices.pillow– Image processing (PIL.Image).
- Create a directory with fine-tuned models.
mkdir -p <models>
- Download fine-tuned binary and multiclass models from
ownCloud
and put them into
<models>.
- To run the script from the command line, use the following syntax:
python run_TS_cleaning.py \
--input_ts 'input_TS.mrc' \
--cleaned_ts 'cleaned_TS.mrc' \
--angle_start -50 \
--angle_step 2 \
--confidence_threshold 0.5 \
--batch_size 16 \
--pdf_output 'output_visualization.pdf' \
--model 'models/swin_tiny_fine-tuned.pth' \
--csv_output 'classification_results.csv' \
--mdoc_input 'input_series.mdoc' \
--mdoc_output 'cleaned_series.mdoc'
-
--input_ts<path to input .mrc file>(Required)- Description: Path to the input
.mrcfile, which contains the tilt series data to be processed. - Example:
'input_TS.mrc'
- Description: Path to the input
-
--cleaned_ts<path to output .mrc file>(Required)- Description: Path to the output
.mrcfile where the cleaned tilt series will be saved. - Example:
'cleaned_TS.mrc'
- Description: Path to the output
-
--angle_start<float>(Required)- Description: The starting tilt angle for visualizing tilt images.
- Example:
-50
-
--angle_step<float>(Required)- Description: The increment (step size) for the tilt angles between consecutive tilts.
- Example:
2
-
--confidence_threshold<float>(Optional, default:0.5)- Description: The maximum allowable corruption probability before a tilt is excluded. This allows for simple, dual-direction control over cleaning aggressiveness:
- Higher thresholds (e.g.,
0.8): Very lenient. Slices are only thrown away if the model is at least 80% certain they are corrupted (Excludes FEWER tilts). - Lower thresholds (e.g.,
0.2): Very strict. Slices with even a 20% chance of being corrupted are thrown away (Excludes MORE tilts).
- Higher thresholds (e.g.,
- Example:
0.5
- Description: The maximum allowable corruption probability before a tilt is excluded. This allows for simple, dual-direction control over cleaning aggressiveness:
-
--batch_size<int>(Optional, default:1)- Description: The number of tilt images stacked and passed to the GPU simultaneously during evaluation. Increasing this accelerates processing significantly depending on your available VRAM.
- Example:
16
-
--pdf_output<path to output PDF file>(Optional, default: 'output_visualization.pdf')- Description: Path to the PDF file where the visualizations (tilt angles and excluded images with probability bars) will be saved.
- Example:
'output_visualization.pdf'
-
--model<path to model file>(Required)- Description: Path to the pre-trained model file (e.g., a Swin transformer model) that will be used for classifying images. The model should be compatible with the network architecture specified in the script.
- Example:
'models/swin_tiny_fine-tuned.pth'
-
--csv_output<path to output CSV file>(Optional)- Description: Path where the classification results CSV file will be saved. This CSV lists each slice with flags indicating if it should be removed. Providing this option enables export of slice classification results.
- Example:
'classification_results.csv'
-
--mdoc_input<path to input .mdoc file>(Optional)
- Description: Path to the .mdoc metadata file associated with the tilt series. Used for removing metadata entries corresponding to corrupted tilts (as determined by the model).
- Example:
'input_series.mdoc'
--mdoc_output<path to output .mdoc file>(Optional)
- Description: Output path for saving the cleaned .mdoc file. Must be used together with --mdoc_input and --csv_output.
- Example:
'cleaned_series.mdoc'
- Load the input tilt series data from
input_TS.mrc. - Pack frames into optimized inference batches of
16to leverage high-performance GPU acceleration. - Use the
swin_tiny_fine_tuned.pthmodel to clean TS and visualize tilt angles. - Apply your custom Corruption Threshold criteria limit to split good tilts from distorted ones.
- Start tilt visualization at
-50degrees with a step of2degrees. - Generate and save the visualizations (tilt angle and classification probability scale bars) into
output_visualization.pdf. - Save the cleaned tilt series to
cleaned_TS.mrc. - Export classification results (indices and probabilities) to a CSV file
classification_results.csv. - If a corresponding
input_series.mdocfile is provided, generate a cleaned versioncleaned_series.mdocby removing entries of excluded tilts.
- Ensure that the model file (
.pth) is compatible with the architecture defined in the script (e.g.,swin_tinyorswin_large).
- In the
notebooksdirectory, there are additional Jupyter Notebooks that were used for augmentation (augmentation.ipynb), data split (split_train_val_test.ipynb), and examples of training and evaluation scripts.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Majtner, T., et al. (2025). Automated removal of corrupted tilts in cryo-electron tomography. Journal of Structural Biology: X, 12, 100130. Elsevier. https://doi.org/10.1016/j.yjsbx.2025.100130
@article{Majtner2025,
author = {Majtner, T. and Turoňová, B.},
title = {Automated removal of corrupted tilts in cryo-electron tomography},
journal = {Journal of Structural Biology: X},
year = {2025},
volume = {12},
pages = {100130},
doi = {10.1016/j.yjsbx.2025.100130},
publisher = {Elsevier}
}