This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pipeline:window:cryolo [2018/12/24 11:16] twagner [Configuration] |
pipeline:window:cryolo [2021/02/19 10:00] twagner |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{ : | + | {{ : |
===== Overview ===== | ===== Overview ===== | ||
- | CrYOLO is a fast and accurate particle picking procedure. It's based on convolutional neural networks and utilizes the popular [[https:// | + | <note warning> |
- | * crYOLO makes picking **fast** -- On a modern GPU it will pick your particles at up to 6 micrographs per second. | + | |
- | * crYOLO makes picking **smart** -- The network learns the context of particles (e.g. not to pick particles on carbon or within ice contamination ) | + | |
- | * crYOLO makes training **easy** -- You might use a general network model and skip training completely. However, if the general model doesn' | + | |
- | In this tutorial we explain our recommended configurations for single particle and filament projects. You can find more information about supported networks and about the config file in the following articles: | + | **NEW DOCUMENTATION** |
- | | + | |
- | | + | |
- | ===== Installation ===== | + | |
- | You can find the download and installation instructions here: [[howto:download_latest_cryolo|Download and Installation]] | + | The documentation has moved to [[https:// |
- | ===== Picking - Using a model trained for your data ===== | + | </ |
+ | CrYOLO is a fast and accurate particle picking procedure. It's based on convolutional neural networks and utilizes the popular [[https:// | ||
- | ==== Data preparation ==== | + | * crYOLO makes picking **fast** |
- | CrYOLO supports MRC, TIF and JPG files. It can work with 32 bit data, 8 bit data and 16 bit data. | + | * crYOLO |
- | It will work on original MRC files, but it will probably improve when the data are filtered. Therefore you should low-pass filter them to a reasonable level. Since Version 1.2 crYOLO | + | * crYOLO makes training **easy** |
- | < | + | * crYOLO makes training **tolerant** |
- | " | + | |
- | </ | + | |
- | to the model section in your config file to filter your images down to an absolute frequency | + | |
- | If you followed the installation instructions, | + | In this tutorial we explain our recommended configurations for single particle and filament projects. You can find more information how to use crYOLO, about supported networks and about the config file in the following articles: |
- | < | + | * [[https:// |
- | source activate cryolo | + | * [[: |
- | </ | + | * [[: |
- | In the following I will assume that your image data is in the folder '' | + | < |
- | The next step is to create training data. To do so, we have to pick single particles manually | + | You can find more technical details |
- | * A very heterogenous background could make it necessary to pick more micrographs. | + | |
- | * If your micrograph is only sparsely decorated, you may need to pick more micrographs. | + | |
- | We recommend that you start with 10 micrographs, | + | |
+ | [[https:// | ||
- | {{: | + | ---- |
- | To create your training data, crYOLO is shipped with a tool called " | + | |
- | Start the box manager with the following command: | + | We are also proud that crYOLO was recommended by F1000: |
- | < | + | |
- | cryolo_boxmanager.py | + | |
- | </ | + | |
- | Now press //File -> Open image folder// and the select the '' | + | //" |
- | * LEFT MOUSE BUTTON: Place a box | + | ===== Installation ===== |
- | * HOLD LEFT MOUSE BUTTON: Move a box | + | |
- | * CONTROL + LEFT MOUSE BUTTON: Remove a box | + | |
- | You can change | + | You can find the download and installation instructions here: [[: |
- | If you finished picking from your micrographs, | + | {{page>pipeline: |
- | Create a new directory called '' | + | |
- | Now create a third folder with the name '' | + | ===== Release notes ===== |
- | ==== Configuration ==== | + | {{page>pipeline: |
- | You now have to create a config file your picking project. To do this type: | + | |
- | < | + | |
- | touch config.json | + | |
- | </code> | + | |
- | To use the [[: | + | ===== Tutorials ===== |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | Depending what you want to do, you can follow one of these self-contained Tutorials: |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | - [[:pipeline:window:cryolo:picking_general|I would like to pick particles without training using a general model]] |
- | " | + | - [[:pipeline:window: |
- | " | + | - [[:pipeline: |
- | " | + | - [[: |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | The **first, second |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Please set the value in the //" | + | |
- | < | + | |
- | " | + | |
- | </ | + | |
- | crYOLO will automatically check if an image in full_data is available in the '' | + | |
- | + | ||
- | Please note the wiki entry about the [[: | + | |
- | + | ||
- | + | ||
- | + | ||
- | ==== 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 config.json file, train_image folder, etc. | + | |
- | + | ||
- | **1. Warm up your network** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 3 -g 0 | + | |
- | </ | + | |
- | + | ||
- | **2. Train your network** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 0 -g 0 | + | |
- | </ | + | |
- | + | ||
- | The final model will be called '' | + | |
- | + | ||
- | The training stops when the " | + | |
- | < | + | |
- | cryolo_train.py -c config.json -w 0 -g 0 -e 10 | + | |
- | </ | + | |
- | to the training command. | + | |
- | ==== Picking ==== | + | |
- | You can now use the model weights saved in '' | + | |
- | < | + | |
- | cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ | + | |
- | </ | + | |
- | + | ||
- | You will find the picked particles in the directory '' | + | |
- | + | ||
- | If you want to pick less conservatively or more conservatively you might want to change the selection threshold from the default of 0.3 to a less conservative value like 0.2 or more conservative value like 0.4 using the //-t// parameter: | + | |
- | < | + | |
- | cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ -t 0.2 | + | |
- | </ | + | |
- | + | ||
- | ==== Visualize the results ==== | + | |
- | + | ||
- | To visualize your results you can use the box manager: | + | |
- | < | + | |
- | cryolo_boxmanager.py | + | |
- | </ | + | |
- | Now press //File -> Open image// folder | + | |
- | + | ||
- | + | ||
- | + | ||
- | ===== Picking - Without training using a general model ===== | + | |
- | + | ||
- | The general model can be found here: [[howto: | + | |
- | ==== Configuration==== | + | |
- | The next step is to create a configuration file. Type: | + | |
- | < | + | |
- | touch config.json | + | |
- | </ | + | |
- | + | ||
- | Open the file with your preferred editor. | + | |
- | + | ||
- | For the general | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Please set the value in the //" | + | |
- | + | ||
- | ==== Picking ==== | + | |
- | Just follow the description given [[pipeline: | + | |
- | + | ||
- | As for a direct trained model, you might want to play around with the -t parameter to make picking less or more conservative. | + | |
- | + | ||
- | ===== 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 ==== | + | |
- | {{ : | + | |
- | + | ||
- | After this is done, you have to prepare training data for your model. | + | |
- | Right now, you have to use the e2helixboxer.py to generate the training data: | + | |
- | < | + | |
- | e2helixboxer.py --gui my_images/ | + | |
- | </ | + | |
- | + | ||
- | After tracing your training data in e2helixboxer, | + | |
- | + | ||
- | ==== Configuration ==== | + | |
- | You can configure it the same way as for a " | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | Just adapt the anchors accordingly to your box size. | + | |
- | + | ||
- | ==== Training ==== | + | |
- | + | ||
- | In principle, there is not much difference in training crYOLO for filament picking | + | |
- | + | ||
- | **1. Warm up your network** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 10 -g 0 | + | |
- | </ | + | |
- | + | ||
- | **2. Train your network** | + | |
- | + | ||
- | < | + | |
- | cryolo_train.py -c config.json -w 0 -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 ==== | + | |
- | You can use the boxmanager as described [[pipeline: | + | |
- | + | ||
- | ===== Evaluate your results ===== | + | |
- | + | ||
- | The evaluation tool allows you, based on your validation data, to get statistics about your training. Unfortunately, | + | |
- | 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/ | + | |
- | < | + | |
- | 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** (// | + | |
- | * // | + | |
- | + | ||
- | During **picking** (// | + | |
- | * //-t confidence_threshold//: | + | |
- | * //-d distance_in_pixel//: | + | |
- | * //-pbs prediction_batch_size//: | + | |
===== Help ===== | ===== Help ===== | ||
Line 344: | Line 62: | ||
Find help at our [[https:// | Find help at our [[https:// | ||
+ | |||
+ |