Skip to content

Commit 6ecfe65

Browse files
author
Corentin
committed
myoquant v0.3.0 with ATP analysis
1 parent 2a2e42f commit 6ecfe65

File tree

12 files changed

+586
-133
lines changed

12 files changed

+586
-133
lines changed

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
"module": "myoquant",
2020
"justMyCode": true,
2121
"args": ["he-analysis", "sample_img/sample_he.jpg", "--stardist-path", "sample_img/sample_he_stardist_mask.tiff", "--cellpose-path", "sample_img/sample_he_cellpose_mask.tiff"],
22+
},
23+
{
24+
"name": "ATP Analysis",
25+
"type": "python",
26+
"request": "launch",
27+
"module": "myoquant",
28+
"justMyCode": true,
29+
"args": ["atp-analysis", "sample_img/sample_atp.jpg", "--cellpose-path", "sample_img/sample_atp_cellpose_mask.tiff"],
2230
}
2331
]
2432
}

CLI_Documentation.md

Lines changed: 70 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `myoquant`
22

3-
MyoQuant Analysis Command Line Interface
3+
myoquant Analysis Command Line Interface
44

55
**Usage**:
66

@@ -10,13 +10,42 @@ $ myoquant [OPTIONS] COMMAND [ARGS]...
1010

1111
**Options**:
1212

13-
* `--help`: Show this message and exit.
13+
- `--help`: Show this message and exit.
1414

1515
**Commands**:
1616

17-
* `docs`: Generate documentation
18-
* `he-analysis`: Run the HE analysis and quantification on...
19-
* `sdh-analysis`: Run the SDH analysis and quantification on...
17+
- `atp-analysis`: Run the fibre type 1 vs type 2 analysis on...
18+
- `docs`: Generate documentation
19+
- `he-analysis`: Run the nuclei position analysis on HE and...
20+
- `sdh-analysis`: Run the mitochondiral analysis and...
21+
22+
## `myoquant atp-analysis`
23+
24+
Run the fibre type 1 vs type 2 analysis on ATP images.
25+
First input arguments and option are printed in stdout and all modules are imported. Then the input image is mask with the binary mask if provided.
26+
Then depending on the presence of cellpose , Cellpose is run or not and mask accordingly if binary mask is provided.
27+
Finally the ATP analysis is run with run_atp_analysis() function and the results are saved in the output folder and some info are printed in stdout.
28+
29+
**Usage**:
30+
31+
```console
32+
$ myoquant atp-analysis [OPTIONS] IMAGE_PATH
33+
```
34+
35+
**Arguments**:
36+
37+
- `IMAGE_PATH`: The ATP image file path to analyse. [required]
38+
39+
**Options**:
40+
41+
- `--mask-path FILE`: The path to a binary mask to hide slide region during analysis. It needs to be of the same resolution as input image and only pixel marked as 1 will be analyzed.
42+
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
43+
- `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
44+
- `--intensity-threshold INTEGER RANGE`: Fiber intensity threshold to differenciate between the two fiber types. If not specified, the analysis will try to deduce it. [1<=x<=254]
45+
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
46+
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
47+
- `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
48+
- `--help`: Show this message and exit.
2049

2150
## `myoquant docs`
2251

@@ -30,11 +59,11 @@ $ myoquant docs [OPTIONS] COMMAND [ARGS]...
3059

3160
**Options**:
3261

33-
* `--help`: Show this message and exit.
62+
- `--help`: Show this message and exit.
3463

3564
**Commands**:
3665

37-
* `generate`: Generate markdown version of usage...
66+
- `generate`: Generate markdown version of usage...
3867

3968
### `myoquant docs generate`
4069

@@ -48,13 +77,16 @@ $ myoquant docs generate [OPTIONS]
4877

4978
**Options**:
5079

51-
* `--name TEXT`: The name of the CLI program to use in docs.
52-
* `--output FILE`: An output file to write docs to, like README.md.
53-
* `--help`: Show this message and exit.
80+
- `--name TEXT`: The name of the CLI program to use in docs.
81+
- `--output FILE`: An output file to write docs to, like README.md.
82+
- `--help`: Show this message and exit.
5483

5584
## `myoquant he-analysis`
5685

57-
Run the HE analysis and quantification on the image.
86+
Run the nuclei position analysis on HE and fluo images.
87+
First input arguments and option are printed in stdout and all modules are imported. Then the input image is mask with the binary mask if provided.
88+
Then depending on the presence of cellpose and stardist path, Cellpose and Stardist are run or not and mask accordingly if binary mask is provided.
89+
Finally the nuclei analysis is run with run_he_analysis() function and the results are saved in the output folder and some info are printed in stdout.
5890

5991
**Usage**:
6092

@@ -64,26 +96,30 @@ $ myoquant he-analysis [OPTIONS] IMAGE_PATH
6496

6597
**Arguments**:
6698

67-
* `IMAGE_PATH`: The HE image file path to analyse. If using single channel images, this will be used as cytoplasm image to run CellPose. Please use the --fluo-nuc option to indicate the path to the nuclei single image to run Stardist. [required]
99+
- `IMAGE_PATH`: The HE image file path to analyse. If using single channel images, this will be used as cytoplasm image to run CellPose. Please use the --fluo-nuc option to indicate the path to the nuclei single image to run Stardist. [required]
68100

69101
**Options**:
70102

71-
* `--mask-path FILE`: The path to a binary mask to hide slide region during analysis. It needs to be of the same resolution as input image and only pixel marked as 1 will be analyzed.
72-
* `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
73-
* `--stardist-path FILE`: The pre-computed Stardist mask to use for analysis. Will run Stardist if no path provided. Required as an image file.
74-
* `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
75-
* `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
76-
* `--nms-thresh FLOAT RANGE`: NMS Threshold for Stardist nuclei detection. [default: 0.4; 0<=x<=1]
77-
* `--prob-thresh FLOAT RANGE`: Probability Threshold for Stardist nuclei detection. [default: 0.5; 0.5<=x<=1]
78-
* `--eccentricity-thresh FLOAT RANGE`: Eccentricity threshold value for a nucleus to be considered as internalized during nuclei classification. When very close to 1 almost all nuclei are considered as internalized. [default: 0.75; 0<=x<=1]
79-
* `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
80-
* `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
81-
* `--fluo-nuc FILE`: The path to single channel fluo image for nuclei.
82-
* `--help`: Show this message and exit.
103+
- `--mask-path FILE`: The path to a binary mask to hide slide region during analysis. It needs to be of the same resolution as input image and only pixel marked as 1 will be analyzed.
104+
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
105+
- `--stardist-path FILE`: The pre-computed Stardist mask to use for analysis. Will run Stardist if no path provided. Required as an image file.
106+
- `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
107+
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
108+
- `--nms-thresh FLOAT RANGE`: NMS Threshold for Stardist nuclei detection. [default: 0.4; 0<=x<=1]
109+
- `--prob-thresh FLOAT RANGE`: Probability Threshold for Stardist nuclei detection. [default: 0.5; 0.5<=x<=1]
110+
- `--eccentricity-thresh FLOAT RANGE`: Eccentricity threshold value for a nucleus to be considered as internalized during nuclei classification. When very close to 1 almost all nuclei are considered as internalized. [default: 0.75; 0<=x<=1]
111+
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
112+
- `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
113+
- `--fluo-nuc FILE`: The path to single channel fluo image for nuclei.
114+
- `--help`: Show this message and exit.
83115

84116
## `myoquant sdh-analysis`
85117

86-
Run the SDH analysis and quantification on the image.
118+
Run the mitochondiral analysis and quantification on the image.
119+
First input arguments and option are printed in stdout and all modules are imported and latest SDH model is downloaded.
120+
Then the input image is mask with the binary mask if provided.
121+
Then depending on the presence of cellpose path, Cellpose is run or not and mask accordingly if binary mask is provided.
122+
Finally the mitochondiral classificaiton is run with run_sdh_analysis() function and the results are saved in the output folder and some info are printed in stdout.
87123

88124
**Usage**:
89125

@@ -93,15 +129,15 @@ $ myoquant sdh-analysis [OPTIONS] IMAGE_PATH
93129

94130
**Arguments**:
95131

96-
* `IMAGE_PATH`: The image file path to analyse. [required]
132+
- `IMAGE_PATH`: The image file path to analyse. [required]
97133

98134
**Options**:
99135

100-
* `--mask-path FILE`: The path to a binary mask to hide slide region during analysis. It needs to be of the same resolution as input image and only pixel marked as 1 will be analyzed.
101-
* `--model-path FILE`: The SDH model path to use for analysis. Will download latest one if no path provided.
102-
* `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
103-
* `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
104-
* `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
105-
* `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
106-
* `--export-stats / --no-export-stats`: Export per fiber stat table. [default: export-stats]
107-
* `--help`: Show this message and exit.
136+
- `--mask-path FILE`: The path to a binary mask to hide slide region during analysis. It needs to be of the same resolution as input image and only pixel marked as 1 will be analyzed.
137+
- `--model-path FILE`: The SDH model path to use for analysis. Will download latest one if no path provided.
138+
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
139+
- `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
140+
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
141+
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
142+
- `--export-stats / --no-export-stats`: Export per fiber stat table. [default: export-stats]
143+
- `--help`: Show this message and exit.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
black:
2-
black app
2+
black myoquant
33
black tests
44

55
black-diff:
6-
black app --diff
6+
black myoquant --diff
77
black tests --diff
88

99
build:
@@ -17,7 +17,7 @@ mkserve:
1717
mkdocs serve
1818

1919
mypy:
20-
mypy app/ --ignore-missing-imports
20+
mypy myoquant/ --ignore-missing-imports
2121

2222
pre-commit: black mypy ruff test
2323

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
</p>
88

99
MyoQuant🔬 is a command-line tool to automatically quantify pathological features in muscle fiber histology images.
10-
It is built using CellPose, Stardist, custom neural-network models and image analysis techniques to automatically analyze myopathy histology images. Currently MyoQuant is capable of quantifying centralization of nuclei in muscle fiber with HE staining and anomaly in the mitochondria distribution in muscle fibers with SDH staining.
10+
It is built using CellPose, Stardist, custom neural-network models and image analysis techniques to automatically analyze myopathy histology images.
11+
Currently MyoQuant is capable of quantifying centralization of nuclei in muscle fiber with HE staining, anomaly in the mitochondria distribution in muscle fibers with SDH staining and the number of type 1 muscle fiber vs type 2 muscle fiber with ATP staining.
1112

1213
An online demo with a web interface is available at [https://lbgi.fr/MyoQuant/](https://lbgi.fr/MyoQuant/). This project is free and open-source under the AGPL license, feel free to fork and contribute to the development.
1314

@@ -41,6 +42,9 @@ Then you can perform SDH or HE analysis. You can use the command `myoquant --hel
4142
- **For HE Image Analysis** the command is:
4243
`myoquant he-analysis IMAGE_PATH`
4344
Don't forget to run `myoquant he-analysis --help` for information about options.
45+
- **For ATP Image Analysis** the command is:
46+
`myoquant atp-analysis IMAGE_PATH`
47+
Don't forget to run `myoquant atp-analysis --help` for information about options.
4448

4549
_If you're running into an issue such as `myoquant: command not found` please check if you activated your virtual environment with the package installed. And also you can try to run it with the full command: `python -m myoquant sdh-analysis --help`_
4650

@@ -55,15 +59,19 @@ Creator and Maintainer: [**Corentin Meyer**, 3rd year PhD Student in the CSTB Te
5559
## Examples
5660

5761
For HE Staining analysis, you can download this sample image: [HERE](https://www.lbgi.fr/~meyer/SDH_models/sample_he.jpg)
58-
For SDH Staining analysis, you can download this sample image: [HERE](https://www.lbgi.fr/~meyer/SDH_models/sample_sdh.jpg)
62+
For SDH Staining analysis, you can download this sample image: [HERE](https://www.lbgi.fr/~meyer/SDH_models/sample_sdh.jpg)
63+
For ATP Staining analysis, you can download this sample image: [HERE](https://www.lbgi.fr/~meyer/SDH_models/sample_atp.jpg)
5964

60-
1. Example of successful SDH analysis with: `myoquant sdh-analysis sample_sdh.jpg`
65+
1. Example of successful SDH analysis output with: `myoquant sdh-analysis sample_sdh.jpg`
6166

6267
![image](https://user-images.githubusercontent.com/20109584/210328050-11b0b6d5-28ec-41a4-b9d3-264962d04fa3.png)
68+
![image](https://i.imgur.com/4Nlnwdx.png) 2. Example of HE analysis: `myoquant he-analysis sample_he.jpg`
6369

64-
2. Example of successful HE analysis with: `myoquant he-analysis sample_he.jpg`
70+
![image](https://i.imgur.com/q2cXgIf.png)
6571

66-
![image](https://user-images.githubusercontent.com/20109584/210328002-6c483ecf-5ba4-4dab-8347-6d71f5726c5e.png)
72+
3. Example of ATP analysis with: `myoquan atp-analysis sample_atp.jpg`
73+
74+
![image](https://i.imgur.com/2ceiOx8.png)
6775

6876
## Advanced information
6977

myoquant/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from rich.console import Console
33

44
from .commands.docs import app as docs_app
5-
from .commands import run_sdh, run_he
5+
from .commands import run_sdh, run_he, run_atp
66

77
console = Console()
88

@@ -16,7 +16,9 @@
1616

1717

1818
app.registered_commands += (
19-
run_sdh.app.registered_commands + run_he.app.registered_commands
19+
run_sdh.app.registered_commands
20+
+ run_he.app.registered_commands
21+
+ run_atp.app.registered_commands
2022
)
2123

2224
if __name__ == "__main__":

0 commit comments

Comments
 (0)