-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
102 lines (68 loc) · 4.39 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
output: rmarkdown::github_document
always_allow_html: true
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
# NTU automatic stomata image detection in python
* [install miniconda](https://docs.anaconda.com/free/miniconda/miniconda-install/)
* [install visual code studio](https://code.visualstudio.com/download)
* open `miniconda`, create conda virtual environment `stomaenv`
```{r, eval=FALSE}
conda create --name stomaenv python=3.10.0 jupyter pandas
# after the first line has done
conda activate stomaenv
conda install conda-forge::ultralytics
conda install anaconda::dill
conda install anaconda::ipykernel
##optional: when you have GPU
#conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
#conda install nvidia/label/cuda-12.1.0::cuda
```
* open `NTU_detect_v8.ipynb` with `visual code studio`, select virtual environment `stomaenv`
* run all the cell, select the folder where you store your stomata images, results would be generated in the folder `runs`
# Manual image labelling & comparison with detection in R
## preparation
please clone this repository to your local directory.
1. open `Stomata.RProj`
2. open [`run.R`](https://github.com/Illustratien/Stomata/blob/main/src/run.R) in folder "`src`"
3. run [`set_up.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/set_up.R) to install necessary packages.
4. create two folders named `data` and `results` from line 6-7.
5. create **sub-folder(s)** under directory **"data"** (`data/sub-folder`)
For example: folder `data/T16L600` contains all `.xml` files from experiment T16L600.
***!!! .xml files can't directly put in `data`, your need to put them under a folder inside `data`!!!***
## read ground truth (manual labelling)
6. run [`read_xml.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/read_xml.R) from line 11-13 to read the files and generate basic results for each batch
7. run [`stat_analysis.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/stat_analysis.R) line 18-20 to read the files and generate statistics for each stomata rows.
8. run [`summarize_and_merge.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/summarize_and_merge.R) line 23-25 to generate summarize statistics for each picture.
## Quality control of `NTU` automatic stomata image detection
To tackle the issues of same detected position of a stomata have different class from the `NTU` pipeline.
### 9. Remove the duplicated.
1. run line 29 to create the folder "result/Ntu"
2. then placed the *no ground truth's pictures* in "result/Ntu"
3. run [`clean_ntu.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/check_ntu.R) from line 33-35 to remove the duplicated detected stomata that has lower confidence.
4. merge.RDS will be the output removing the duplicated coordinates.
### 10. Compare the ground truth with the detection
For those picture that is both manually labelled and detected by the `NTU`
1. run [`check_ntu.R`](https://github.com/Illustratien/Stomata/blob/main/src/modules/clean_ntu.R) from line 38-40 to validate the detected data with ground truth
* note that only picture with the same picture name as ground truth when the detected stomata center is 3.2 microm to the ground truth.
# unit and names of stomata object
![Stomata](pic/Stomata_object.png)
# Pull request
Want to contribute to the code? Very welcome!
1. copy the script that you want to modified in 'src/test'
2. modified the code
3. test if there is error
4. move it to the original folder and overwrite
5. make a pull request
# ❓ Issues/Problems/Errors
Please raise your question in [Issues](https://github.com/HU-IGPS/Photosynthesis-Yichen-Model/issues) and set a request in [Project](https://github.com/orgs/HU-IGPS/projects/3)!
### Guideline for reporting error
> 1. *Make sure your code is up to date (pull from github)*
2. Describe the issue/problem/error clearly.
3. identify the error: Is it an error? (Do you received error message?)
* If yes, Which code, which line, which error
* If it is inside a loop, can you identify the index inside the loop?
* see here more for [debug](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)
4. Interpretation of the message: `Google` the error/ `Chatgpt`
5. Reproduce the error: make sure it is [reproducible](https://stackoverflow.com/help/minimal-reproducible-example)
6. Post on github/slack for help