|
| 1 | +## Correct segmentation and tracking results from TrackMate |
| 2 | +This tutorial gives an example on how to correct the segmentation and tracking results obtained after using TrackMate on an epithelia movie. |
| 3 | + |
| 4 | +You can follow it with your own data, or using the test data available in the github repository, selecting the movie [013_crop.tif](https://github.com/Image-Analysis-Hub/Epicure/blob/main/test_data/013_crop.tif) and the corresponding TrackMate file [013_crop_witherrrors.xml](https://github.com/Image-Analysis-Hub/Epicure/blob/main/test_data/013_crop_witherrors.xml). |
| 5 | + |
| 6 | +### 1 - Load the raw movie and TrackMate file |
| 7 | + |
| 8 | +Start Napari, and then EpiCure by going to `Plugins>Epicure>Start epicure`. |
| 9 | + |
| 10 | +A panel opens in the right side, where you can select the raw movie by clicking the `Select file` button on the top right. |
| 11 | +Chosse the raw movie (`013_crop.tif`). |
| 12 | + |
| 13 | +The movie is loaded and the metadata are read and displayed in the right panel. |
| 14 | +Check that the extracted values are correct, or change them if necessary. |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +Then to load the TrackMate results, select the `.xml` file (`013_crop_witherrrors.xml`) in the `segmentation_file` parameter of the interface and click on `Start cure`. |
| 19 | + |
| 20 | +The segmentation and tracking information will be loaded. |
| 21 | +The cells are displayed as labels (colors). |
| 22 | +Each track correspond to one label (color). |
| 23 | + |
| 24 | +### 2 - Detect potential segmentation or tracking errors |
| 25 | + |
| 26 | +You can navigate through the movie to find segmentation errors, or use the automatic function to highlight potential errors. |
| 27 | + |
| 28 | +For this, go the the `Inspect` tab of the right panel. |
| 29 | +In `Track options`, select `Flag track merging`, `Flag track appartion` and `Flag track disparition`. |
| 30 | +Select `Ignore cells on: tissue boundaries` at the top of the panel to avoid the border effect and don't check track apparition or disparition for cells at the border. |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +Pontential errors are indicated with white cross on the position of the error, which can be due to segmentation or tracking. |
| 35 | + |
| 36 | +### 3 - Check manually and correct true errors |
| 37 | + |
| 38 | +#### 3a - Navigate through the potential errors |
| 39 | +To go through all detected errors, press <kbd>Space</kbd>. |
| 40 | +It will move to the position of a first error and zoom on it. |
| 41 | +On your Terminal window, a message indicating why this point was flagged has potentially erroneous is printed. |
| 42 | +Each time you press <kbd>Space</kbd>, it will go to the next error. |
| 43 | + |
| 44 | +#### 3b - Correct true errors |
| 45 | + |
| 46 | +Go to the two errors at frame 5 toward the bottom of the movie (see figure below). |
| 47 | +You can see that the cell present at frame 4 is wrongly splitted in two cells at frame 5 and detected again as one cell in frame 6. |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +To correct this, at frame 5, press <kbd>Control</kbd> and click with the left mouse button from the first to the second cell to merge together. |
| 52 | +The two cells will be merged as one cell, labelled with the previous cell (from frame 4) number as the program tries to automatically relink the cells. |
| 53 | + |
| 54 | +It will also try to relink the cells in the next frame. |
| 55 | +Here, you can see that it didn't work and the next frame cell is not linked to the new cell and has another label (color). |
| 56 | +To correct, that press <kbd>t</kbd> and do a left click on the cell at frame 5 then a right click on the same cell at frame 6 to link them together. |
| 57 | + |
| 58 | +The error has been corrected. |
| 59 | +You can remove the flags by pressing <kbd>Control+Alt</kbd> and right clicking on the cross if you want to clean it while correcting, otherwise you can do all the corrections then inspect again to reset them all and check that all is fine. |
| 60 | + |
| 61 | +## Segment, track and measure a tissue |
| 62 | + |
| 63 | +### 1 - Load and segment the raw movie |
| 64 | + |
| 65 | +For this tutorial, you can download the raw movie `015.tif` from the [zenodo repository 7586394](https://zenodo.org/records/7586394) which contains movies of drosophila notum development. |
| 66 | +Click [here to download the movie](https://zenodo.org/records/7586394/files/015.tif?download=1) |
| 67 | + |
| 68 | +Start napari. |
| 69 | +Go to `EpiCure>Start EpiCure`. |
| 70 | +At the top of the parameter interface at the right side of the napari window, choose the movie to process by clicking `Select file` on the `image file` parameter. |
| 71 | +Browse to select the file that you downloaded. |
| 72 | + |
| 73 | +Click `Segment now with EpySeg` to segment it. |
| 74 | +!!! warning "Missing dependency" |
| 75 | + To limit EpiCure dependency on other modules, especially Epyseg that is not compatible with recent versions of python, we don't force the installation of `napari-epyseg` with Epicure. If you haven't installed it, you will get an error when trying to use it. In that case, install it (`pip install napari-epyseg`) and start again. |
| 76 | + |
| 77 | +When the segmentation is finished, a file named `015.tif_epyseg.tif` has been saved in the same folder as your movie and is directly proposed as the `segmentation file` in EpiCure interface. |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | +Click `START CURE` to start the process. |
| 82 | + |
| 83 | +### 2 - Track the cells |
| 84 | + |
| 85 | +EpiCure creates cells from the binary segmentation results from EpySeg. |
| 86 | + |
| 87 | +Press <kbd>Control-C</kbd> two times to display the cells as contours only, and not full colored cell, to see better the signal behind. |
| 88 | + |
| 89 | +!!! note "The `Segmentation` layer must always be selected in the left panel for the shortcuts to work" |
| 90 | + |
| 91 | +You can see that on the first frame, the segmentation is very bad as the signal is very noisy, but we get good results in all the other frames. |
| 92 | +Let's first delete all cells from the first frame to clean the segmenation. |
| 93 | + |
| 94 | +#### 2a - Remove cells from the first frame |
| 95 | +Go to the `Edit` panel, and select the `ROI options` interface. |
| 96 | +It will expand the interface for this option (ROI=Region Of Interest). |
| 97 | +Click `Draw/Select ROI` and select the rectangular selection in the top left panel interface that corresponds to the options linked to the `ROIs` layer. |
| 98 | +Draw a rectangle around the all image. |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +Click `Remove cells inside ROI` to delete all the cells inside the rectangle. |
| 103 | +Check that `Segmentation` layer is the currently selected layer again when all cells are removed. |
| 104 | +Save the correction by pressing <kbd>s</kbd>. |
| 105 | + |
| 106 | +#### 2b - Track the cells |
| 107 | +Select the `Track` panel in the right side interface to choose the options for tracking. |
| 108 | + |
| 109 | +Select `Laptrack-Centroids`. |
| 110 | +This option will track the cell by considering the position of their centroids and matching closest points in consecutive frames. |
| 111 | + |
| 112 | + set `Max distance` to 20, `Splitting cutoff` (division probability) to 0.3 and `Merging cutoff` to 0 (track merging, this should not happen in an epithelia). |
| 113 | + |
| 114 | +Unselect `Add feature cost`. |
| 115 | +This could be used to add constraint on the tracking algorithm to try to match cells with similar area or shape in consecutive frames. |
| 116 | +It can improve the tracking when cell shapes are close enough from one frame to another. |
| 117 | + |
| 118 | +Click `Track` to launch the tracking. |
| 119 | + |
| 120 | +!!! note "Set up tracking parameters on a subset of frames" |
| 121 | + You can check the box `Track only some frames` and set the values of `Track from frame` and `Until frame` to perform tracking only on a few frames, to set up the parameters before to track the entire movie. |
| 122 | + |
| 123 | +When the tracking is done, the cells will be colored with a unique color all along the same track. |
| 124 | +The `Track` layer shows you the track as lines accross frames. |
| 125 | +You can directly show it or hide it by pressing <kbd>r</kbd> when the `Segmentation` layer is selected. |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | +A few divisions should have been detected by the tracking algorithm, you can see them as blue dots. |
| 130 | + |
| 131 | +### 3 - Measure track properties |
| 132 | +After doing the tracking, you can inspect and correct eventual segmentation or tracking errors. |
| 133 | +When this is done or if you don't need a perfect accuracy for your analysis, you can then perform measurement on the results directly in EpiCure. |
| 134 | + |
| 135 | +To measure track properties, go to `Output` and select `Measure track features`. |
| 136 | +Select `All cells` in `Apply on` parameter to measure all tracks at once. |
| 137 | +Click `Track features table` to launch the measurement. |
| 138 | + |
| 139 | +A table with one cell/track by row will be displayed in the right-side interface. |
| 140 | +Each column is a measured feature, as eg the total length of a track or its average velocity. |
| 141 | + |
| 142 | + |
0 commit comments