This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
pipeline:window:cryolo [2019/09/15 09:57] twagner [Picking particles - Using the general model refined for your data] |
pipeline:window:cryolo [2020/05/25 10:12] twagner [Overview] |
||
---|---|---|---|
Line 2: | Line 2: | ||
===== Overview ===== | ===== Overview ===== | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | **NEW DOCUMENTATION** | ||
+ | |||
+ | The documentation has moved to https:// | ||
+ | |||
+ | </ | ||
CrYOLO is a fast and accurate particle picking procedure. It's based on convolutional neural networks and utilizes the popular [[https:// | CrYOLO is a fast and accurate particle picking procedure. It's based on convolutional neural networks and utilizes the popular [[https:// | ||
Line 17: | Line 25: | ||
< | < | ||
+ | |||
You can find more technical details in our paper: | You can find more technical details in our paper: | ||
Line 28: | Line 37: | ||
< | < | ||
< | < | ||
- | <a href=" | + | <a href=" |
</ | </ | ||
</ | </ | ||
Line 36: | Line 45: | ||
You can find the download and installation instructions here: [[howto: | You can find the download and installation instructions here: [[howto: | ||
+ | {{page> | ||
+ | ===== Release notes ===== | ||
+ | {{page> | ||
===== Tutorials ===== | ===== Tutorials ===== | ||
Depending what you want to do, you can follow one of these self-contained Tutorials: | Depending what you want to do, you can follow one of these self-contained Tutorials: | ||
- | - I would like to train a model from scratch for picking my particles | + | - [[pipeline: |
- | - I would like to train a model from scratch for picking filaments. | + | - [[pipeline: |
- | - I would like to refine a general model for my particles. | + | - [[pipeline: |
+ | - [[pipeline: | ||
- | The **first | + | The **first, second |
- | + | ||
- | + | ||
- | + | ||
- | ===== Picking particles - Using a model trained for your data ===== | + | |
- | + | ||
- | + | ||
- | ==== Data preparation ==== | + | |
- | {{page> | + | |
- | + | ||
- | ==== Start crYOLO ==== | + | |
- | {{page> | + | |
- | + | ||
- | ==== Configuration ==== | + | |
- | {{page> | + | |
- | ==== Training ==== | + | |
- | + | ||
- | Now you are ready to train the model. In case you have multiple GPUs, you should first select a free GPU. The following command will show the status of all GPUs: | + | |
- | < | + | |
- | nvidia-smi | + | |
- | </ | + | |
- | For this tutorial, we assume that you have either a single GPU or want to use GPU 0. Therefore we add '-g 0' after each command below. However, if you have multiple (e.g GPU 0 and GPU 1) you could also use both by adding '-g 0 1' after each command. | + | |
- | + | ||
- | Navigate to the folder with '' | + | |
- | + | ||
- | **Train your network with 3 warmup epochs:** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 3 -g 0 | + | |
- | </ | + | |
- | + | ||
- | The final model will be called '' | + | |
- | + | ||
- | The training stops when the " | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 3 -g 0 -e 15 | + | |
- | </ | + | |
- | + | ||
- | to the training command. | + | |
- | ==== Picking ==== | + | |
- | {{page> | + | |
- | + | ||
- | + | ||
- | ==== Visualize the results ==== | + | |
- | {{page> | + | |
- | ===== Picking particles - Without training using a general model ===== | + | |
- | Here you can find how to apply the general models we trained for you. If you would like to train your own general model, please see our extra wiki page: [[: | + | |
- | + | ||
- | Our general models can be found and downloaded here: [[howto: | + | |
- | + | ||
- | ==== Start crYOLO ==== | + | |
- | {{page> | + | |
- | + | ||
- | ==== Configuration==== | + | |
- | The next step is to create a configuration file. Type: | + | |
- | < | + | |
- | touch config.json | + | |
- | </ | + | |
- | + | ||
- | Open the file with your preferred editor. | + | |
- | + | ||
- | There are two general **[[: | + | |
- | === CryoEM images === | + | |
- | For the general **[[: | + | |
- | <hidden **config.json for low-pass filtered cryo-images**> | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | < | + | |
- | For the general model trained with **neural-network denoised cryo images** (with JANNI' | + | |
- | <hidden **config.json for neural-network denoised cryo-images**> | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | You can download the file '' | + | |
- | </ | + | |
- | < | + | |
- | In all cases please set the value in the //" | + | |
- | + | ||
- | === Negative stain images === | + | |
- | For the general model for **negative stain data** please use: | + | |
- | <hidden **config.json for negative stain images**> | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | Please set the value in the //" | + | |
- | + | ||
- | ==== Picking ==== | + | |
- | {{page> | + | |
- | + | ||
- | ==== Visualize the results ==== | + | |
- | {{page> | + | |
- | ===== Picking particles - Using the general model refined for your data ===== | + | |
- | + | ||
- | + | ||
- | Since crYOLO 1.3 you can train a model for your data by // | + | |
- | + | ||
- | What does // | + | |
- | + | ||
- | The general model was trained on a lot of particles with a variety of shapes and therefore learned a very good set of generic features. The last layers, however, learn a pretty abstract representation of the particles and it might be that they do not perfectly fit for your particle at hand. Fine-tuning only traines the last two convolutional layers, but keep the others fixed. This adjusts the more abstract representation for your specific problem. | + | |
- | + | ||
- | Why should I // | + | |
- | - From theory, using fine-tuning should reduce the risk of overfitting ((Overfitting means, that the model works good on the training micrographs, | + | |
- | - The training is much faster, as not all layers have to be trained. | + | |
- | - The training will need less GPU memory ((We are testing crYOLO with its default configuration on graphic cards with >= 8 GB memory. Using the fine tune mode, it should also work with GPUs with 4 GB memory)) and therefore is usable with NVIDIA cards with less memory. | + | |
- | + | ||
- | However, the fine tune mode is still somewhat experimental and we will update this section if see more advantages or disadvantages. | + | |
- | + | ||
- | ==== Data preparation ==== | + | |
- | {{page> | + | |
- | + | ||
- | ==== Start crYOLO ==== | + | |
- | + | ||
- | {{page> | + | |
- | ==== Configuration ==== | + | |
- | + | ||
- | You can use almost the same configuration as used when [[pipeline: | + | |
- | + | ||
- | < | + | |
- | " | + | |
- | [...] | + | |
- | " | + | |
- | [...] | + | |
- | " | + | |
- | [...] | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ==== Training ==== | + | |
- | In comparison to the training from scratch, you can skip the warm up training ( -w 0 ). Moreover you have to add the // | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 0 -g 0 --fine_tune -lft 2 | + | |
- | </ | + | |
- | + | ||
- | <note tip> | + | |
- | + | ||
- | **Training on CPU** | + | |
- | + | ||
- | The fine tune mode is especially useful if you want to [[downloads: | + | |
- | </ | + | |
- | ==== Picking ==== | + | |
- | {{page> | + | |
- | + | ||
- | + | ||
- | ===== Picking filaments - Using a model trained for your data ===== | + | |
- | Since version 1.1.0 crYOLO supports picking filaments. | + | |
- | + | ||
- | Filament mode on Actin: | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | Filament mode on MAVS (EMPIAR-10031) : | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | ==== Data preparation ==== | + | |
- | {{ : | + | |
- | + | ||
- | The first step is to create the training data for your model. Right now, you have to use the e2helixboxer.py for this: | + | |
- | < | + | |
- | e2helixboxer.py --gui my_images/ | + | |
- | </ | + | |
- | + | ||
- | After tracing your training data in e2helixboxer, | + | |
- | ==== Configuration ==== | + | |
- | {{page> | + | |
- | ==== Training ==== | + | |
- | + | ||
- | In principle, there is not much difference in training crYOLO for filament picking and particle picking. For project with roughly 20 filaments per image we successfully trained on 40 images (=> 800 filaments). However, in our experience the warm-up phase and training need a little bit more time: | + | |
- | + | ||
- | **Train your network with 10 warm up epochs:** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 10 -g 0 -e 10 | + | |
- | </ | + | |
- | + | ||
- | The final model will be called '' | + | |
- | ==== Picking ==== | + | |
- | + | ||
- | The biggest difference in picking filaments with crYOLO is during prediction. However, there are just three additional parameters needed: | + | |
- | + | ||
- | * //- -filament//: | + | |
- | * //-fw//: Filament width (pixels) | + | |
- | * //-bd//: Inter-Box distance (pixels). | + | |
- | + | ||
- | Let's assume you want to pick a filament with a width of 100 pixels (-fw 100). The box size is 200x200 and you want a 90% overlap (-bd 20). Moreover, you wish that each filament has at least 6 boxes (-mn 6). The micrographs are in the '' | + | |
- | < | + | |
- | cryolo_predict.py -c config.json -w model.h5 -i full_data --filament -fw 100 -bd 20 -o boxes/ -g 0 -mn 6 | + | |
- | </ | + | |
- | + | ||
- | The directory '' | + | |
- | + | ||
- | ==== Visualize the results ==== | + | |
- | {{page> | + | |
- | + | ||
- | ===== Evaluate your results ===== | + | |
- | <note warning> | + | |
- | Unfortunately, | + | |
- | </ | + | |
- | The evaluation tool allows you, based on your validation data, to get statistics about your training. | + | |
- | If you followed the tutorial, the validation data are selected randomly. With crYOLO 1.1.0 a run file for each training is created and saved into the folder runfiles/ in your project directory. This run file contains which files were selected for validation, and you can run your evaluation as follows: | + | |
- | < | + | |
- | cryolo_evaluation.py -c config.json -w model.h5 -r runfiles/ | + | |
- | </ | + | |
- | The result looks like this: | ||
- | {{: | ||
- | The table contains several statistics: | ||
- | * AUC: Area under curve of the precision-recall curve. Overall summary statistics. Perfect classifier = 1, Worst classifier = 0 | ||
- | * Topt: Optimal confidence threshold with respect to the F1 score. It might not be ideal for your picking, as the F1 score weighs recall and precision equally. However in SPA, recall is often more important than the precision. | ||
- | * R (Topt): Recall using the optimal confidence threshold. | ||
- | * R (0.3): Recall using a confidence threshold of 0.3. | ||
- | * R (0.2): Recall using a confidence threshold of 0.2. | ||
- | * P (Topt): Precision using the optimal confidence threshold. | ||
- | * P (0.3): Precision using a confidence threshold of 0.3. | ||
- | * P (0.2): Precision using a confidence threshold of 0.2. | ||
- | * F1 (Topt): Harmonic mean of precision and recall using the optimal confidence threshold. | ||
- | * F1 (0.3): Harmonic mean of precision and recall using a confidence threshold of 0.3. | ||
- | * F1 (0.2): Harmonic mean of precision and recall using a confidence threshold of 0.2. | ||
- | * IOU (Topt): Intersection over union of the auto-picked particles and the corresponding ground-truth boxes. The higher, the better -- evaluated with the optimal confidence threshold. | ||
- | * IOU (0.3): Intersection over union of the auto-picked particles and the corresponding ground-truth boxes. The higher, the better -- evaluated with a confidence threshold of 0.3. | ||
- | * IOU (0.2): Intersection over union of the auto-picked particles and the corresponding ground-truth boxes. The higher, the better -- evaluated with a confidence threshold of 0.2. | ||
- | If the training data consists of multiple folders, then evaluation will be done for each folder separately. | ||
- | Furthermore, | ||
- | ===== Advanced parameters ===== | ||
- | During **training** (// | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | * //%%-%%lft NUM_LAYER_FINETUNE//: | ||
- | During **picking** (// | ||
- | * //-t CONFIDENCE_THRESHOLD//: | ||
- | * //-d DISTANCE_IN_PIXEL//: | ||
- | * //-pbs PREDICTION_BATCH_SIZE//: | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | * // | ||
- | * //-sr SEARCH_RANGE_FACTOR//: | ||
- | |||
===== Help ===== | ===== Help ===== |