Skip to content

Commit a9d384d

Browse files
v0.4.0: Add TUI for MyoQuant using Trogon
1 parent 3dba43d commit a9d384d

File tree

12 files changed

+119
-94
lines changed

12 files changed

+119
-94
lines changed

CLI_Documentation.md

Lines changed: 81 additions & 84 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,140 +10,137 @@ $ myoquant [OPTIONS] COMMAND [ARGS]...
1010

1111
**Options**:
1212

13-
- `--version`
14-
- `--help`: Show this message and exit.
13+
* `--version`
14+
* `--help`: Show this message and exit.
1515

1616
**Commands**:
1717

18-
- `atp-analysis`: Run the fibre type 1 vs type 2 analysis on...
19-
- `docs`: Generate documentation
20-
- `he-analysis`: Run the nuclei position analysis on HE and...
21-
- `sdh-analysis`: Run the mitochondiral analysis and...
18+
* `sdh-analysis`: Run the mitochondrial analysis and...
19+
* `he-analysis`: Run the nuclei position analysis on HE and...
20+
* `atp-analysis`: Run the fibre type 1 vs type 2 analysis on...
21+
* `tui`: Open Textual TUI.
22+
* `generate-docs`: Generate markdown version of usage...
2223

23-
## `myoquant atp-analysis`
24+
## `myoquant sdh-analysis`
2425

25-
Run the fibre type 1 vs type 2 analysis on ATP images.
26-
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.
27-
Then depending on the presence of cellpose , Cellpose is run or not and mask accordingly if binary mask is provided.
28-
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.
26+
Run the mitochondrial analysis and quantification on the image.
27+
First input arguments and option are printed in stdout and all modules are imported and latest SDH model is downloaded.
28+
Then the input image is mask with the binary mask if provided.
29+
Then depending on the presence of cellpose path, Cellpose is run or not and mask accordingly if binary mask is provided.
30+
Finally, the mitochondrial classification is run with run_sdh_analysis() function and the results are saved in the output folder and some info are printed in stdout.
2931

3032
**Usage**:
3133

3234
```console
33-
$ myoquant atp-analysis [OPTIONS] IMAGE_PATH
35+
$ myoquant sdh-analysis [OPTIONS] IMAGE_PATH
3436
```
3537

3638
**Arguments**:
3739

38-
- `IMAGE_PATH`: The ATP image file path to analyse. [required]
40+
* `IMAGE_PATH`: The image file path to analyse. \[required]
3941

4042
**Options**:
4143

42-
- `--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.
43-
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
44-
- `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
45-
- `--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]
46-
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
47-
- `--channel INTEGER`: Image channel to use for the analysis. If not specified, the analysis will be performed on all three channels.
48-
- `--channel-first / --no-channel-first`: If the channel is the first dimension of the image, set this to True. False by default. [default: no-channel-first]
49-
- `--rescale-exposure / --no-rescale-exposure`: Rescale the image exposure if your image is not in the 0 255 forma, False by default. [default: no-rescale-exposure]
50-
- `--n-classes INTEGER RANGE`: The number of classes of cell to detect. If not specified this is defaulted to two classes. [default: 2; x<=10]
51-
- `--intensity-method TEXT`: The method to use to compute the intensity of the cell. Can be either 'median' or 'mean'. [default: median]
52-
- `--erosion INTEGER RANGE`: Perform an erosion on the cells images to remove signal in the cell membrane (usefull for fluo). Expressed in percentage of the cell radius [default: False; x<=45]
53-
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
54-
- `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
55-
- `--help`: Show this message and exit.
56-
57-
## `myoquant docs`
58-
59-
Generate documentation
44+
* `--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.
45+
* `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
46+
* `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
47+
* `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
48+
* `--export-map / --no-export-map`: Export the original image with cells painted by classification label. \[default: export-map]
49+
* `--export-stats / --no-export-stats`: Export per fiber stat table. \[default: export-stats]
50+
* `--help`: Show this message and exit.
51+
52+
## `myoquant he-analysis`
53+
54+
Run the nuclei position analysis on HE and fluo images.
55+
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.
56+
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.
57+
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.
6058

6159
**Usage**:
6260

6361
```console
64-
$ myoquant docs [OPTIONS] COMMAND [ARGS]...
62+
$ myoquant he-analysis [OPTIONS] IMAGE_PATH
6563
```
6664

67-
**Options**:
65+
**Arguments**:
6866

69-
- `--help`: Show this message and exit.
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]
7068

71-
**Commands**:
69+
**Options**:
7270

73-
- `generate`: Generate markdown version of usage...
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.
7483

75-
### `myoquant docs generate`
84+
## `myoquant atp-analysis`
7685

77-
Generate markdown version of usage documentation
86+
Run the fibre type 1 vs type 2 analysis on ATP 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 , Cellpose is run or not and mask accordingly if binary mask is provided.
89+
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.
7890

7991
**Usage**:
8092

8193
```console
82-
$ myoquant docs generate [OPTIONS]
94+
$ myoquant atp-analysis [OPTIONS] IMAGE_PATH
8395
```
8496

85-
**Options**:
97+
**Arguments**:
8698

87-
- `--name TEXT`: The name of the CLI program to use in docs.
88-
- `--output FILE`: An output file to write docs to, like README.md.
89-
- `--help`: Show this message and exit.
99+
* `IMAGE_PATH`: The ATP image file path to analyse. \[required]
90100

91-
## `myoquant he-analysis`
101+
**Options**:
92102

93-
Run the nuclei position analysis on HE and fluo images.
94-
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.
95-
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.
96-
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.
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+
* `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
106+
* `--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]
107+
* `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
108+
* `--channel INTEGER`: Image channel to use for the analysis. If not specified, the analysis will be performed on all three channels.
109+
* `--channel-first / --no-channel-first`: If the channel is the first dimension of the image, set this to True. False by default. \[default: no-channel-first]
110+
* `--rescale-exposure / --no-rescale-exposure`: Rescale the image exposure if your image is not in the 0 255 forma, False by default. \[default: no-rescale-exposure]
111+
* `--n-classes INTEGER RANGE`: The number of classes of cell to detect. If not specified this is defaulted to two classes. \[default: 2; x<=10]
112+
* `--intensity-method TEXT`: The method to use to compute the intensity of the cell. Can be either 'median' or 'mean'. \[default: median]
113+
* `--erosion INTEGER RANGE`: Perform an erosion on the cells images to remove signal in the cell membrane (usefull for fluo). Expressed in percentage of the cell radius \[default: False; x<=45]
114+
* `--export-map / --no-export-map`: Export the original image with cells painted by classification label. \[default: export-map]
115+
* `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. \[default: export-stats]
116+
* `--help`: Show this message and exit.
117+
118+
## `myoquant tui`
119+
120+
Open Textual TUI.
97121

98122
**Usage**:
99123

100124
```console
101-
$ myoquant he-analysis [OPTIONS] IMAGE_PATH
125+
$ myoquant tui [OPTIONS]
102126
```
103127

104-
**Arguments**:
105-
106-
- `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]
107-
108128
**Options**:
109129

110-
- `--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.
111-
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
112-
- `--stardist-path FILE`: The pre-computed Stardist mask to use for analysis. Will run Stardist if no path provided. Required as an image file.
113-
- `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
114-
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
115-
- `--nms-thresh FLOAT RANGE`: NMS Threshold for Stardist nuclei detection. [default: 0.4; 0<=x<=1]
116-
- `--prob-thresh FLOAT RANGE`: Probability Threshold for Stardist nuclei detection. [default: 0.5; 0.5<=x<=1]
117-
- `--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]
118-
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
119-
- `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
120-
- `--fluo-nuc FILE`: The path to single channel fluo image for nuclei.
121-
- `--help`: Show this message and exit.
130+
* `--help`: Show this message and exit.
122131

123-
## `myoquant sdh-analysis`
132+
## `myoquant generate-docs`
124133

125-
Run the mitochondiral analysis and quantification on the image.
126-
First input arguments and option are printed in stdout and all modules are imported and latest SDH model is downloaded.
127-
Then the input image is mask with the binary mask if provided.
128-
Then depending on the presence of cellpose path, Cellpose is run or not and mask accordingly if binary mask is provided.
129-
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.
134+
Generate markdown version of usage documentation
130135

131136
**Usage**:
132137

133138
```console
134-
$ myoquant sdh-analysis [OPTIONS] IMAGE_PATH
139+
$ myoquant generate-docs [OPTIONS]
135140
```
136141

137-
**Arguments**:
138-
139-
- `IMAGE_PATH`: The image file path to analyse. [required]
140-
141142
**Options**:
142143

143-
- `--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.
144-
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
145-
- `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
146-
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
147-
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
148-
- `--export-stats / --no-export-stats`: Export per fiber stat table. [default: export-stats]
149-
- `--help`: Show this message and exit.
144+
* `--name TEXT`: The name of the CLI program to use in docs.
145+
* `--output FILE`: An output file to write docs to, like README.md.
146+
* `--help`: Show this message and exit.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ I recommend using UV for python environment management. See [UV documentation](h
3434

3535
## How to Use
3636

37+
#### **🆕 NEW:** MyoQuant now comes with a Text User Interface (TUI) for an easier discoverability of the different CLI parameter. **For this you can run `myoquant tui` or `uv run myoquant tui` to launch the TUI.**
38+
39+
![img.png](static/tui.png)
40+
3741
To use the command-line tool, first activate your venv in which MyoQuant is installed: `source .venv/bin/activate` or simply install the package using UV.
3842
Then you can perform SDH or HE analysis. You can use the command `myoquant --help` or `uv run myoquant --help` to list available commands.
3943

@@ -66,9 +70,10 @@ For SDH Staining analysis, you can download this sample image: [HERE](https://ww
6670
For ATP Staining analysis, you can download this sample image: [HERE](https://www.lbgi.fr/~meyer/SDH_models/sample_atp.jpg)
6771

6872
1. Example of successful SDH analysis output with: `myoquant sdh-analysis sample_sdh.jpg`
73+
![img.png](static/sdh_cli.png)
74+
![image](https://i.imgur.com/4Nlnwdx.png)
6975

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

7378
![image](https://i.imgur.com/q2cXgIf.png)
7479

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "myoquant"
3-
version = "0.3.11"
3+
version = "0.4.0"
44
description = "MyoQuant🔬: a tool to automatically quantify pathological features in muscle fiber histology images."
55
authors = [{name="Corentin Meyer", email="[email protected]"}]
66
maintainers = [{name="Corentin Meyer", email="[email protected]"}]
@@ -32,6 +32,7 @@ dependencies = [
3232
"pillow>=11.1.0",
3333
"tifffile>=2025.3.13",
3434
"huggingface-hub>=0.32.4",
35+
"trogon>=0.6.0",
3536
]
3637

3738
[project.scripts]

src/myoquant/__main__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
__version_torch__ = pkg_resources.get_distribution("torch").version
99
__version_tensorflow__ = pkg_resources.get_distribution("tensorflow").version
1010

11+
from trogon.typer import init_tui
12+
1113
from myoquant.commands.docs import app as docs_app
1214
from myoquant.commands import run_sdh, run_he, run_atp
1315

@@ -28,14 +30,19 @@ def version_callback(value: bool):
2830
help="MyoQuant Analysis Command Line Interface",
2931
pretty_exceptions_show_locals=False,
3032
)
31-
app.add_typer(docs_app, name="docs", help="Generate documentation")
33+
app.add_typer(run_sdh.app, help="SDH Analysis")
34+
app.add_typer(run_he.app, help="HE Analysis")
35+
app.add_typer(run_atp.app, help="ATP Analysis")
36+
app.add_typer(docs_app, help="Generate documentation")
3237

3338
app.registered_commands += (
3439
run_sdh.app.registered_commands
3540
+ run_he.app.registered_commands
3641
+ run_atp.app.registered_commands
3742
)
3843

44+
app = init_tui(app)
45+
3946
@app.callback()
4047
def main(
4148
version: bool = typer.Option(

src/myoquant/commands/docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_docs_for_click(
9494

9595

9696
@app.command(help="Generate markdown version of usage documentation")
97-
def generate(
97+
def generate_docs(
9898
ctx: typer.Context,
9999
name: str = typer.Option("", help="The name of the CLI program to use in docs."),
100100
output: Path = typer.Option(

src/myoquant/commands/run_atp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def atp_analysis(
9696
"""Run the fibre type 1 vs type 2 analysis on ATP images.
9797
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.
9898
Then depending on the presence of cellpose , Cellpose is run or not and mask accordingly if binary mask is provided.
99-
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.
99+
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.
100100
"""
101101
start_time = time.time()
102102
console.print(

src/myoquant/commands/run_he.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def he_analysis(
9696
"""Run the nuclei position analysis on HE and fluo images.
9797
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.
9898
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.
99-
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.
99+
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.
100100
"""
101101
start_time = time.time()
102102
console.print(

0 commit comments

Comments
 (0)