Skip to content

Commit

Permalink
myoquant v0.3.0 with ATP analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin committed Jan 19, 2023
1 parent 2a2e42f commit 6ecfe65
Show file tree
Hide file tree
Showing 12 changed files with 586 additions and 133 deletions.
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
"module": "myoquant",
"justMyCode": true,
"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"],
},
{
"name": "ATP Analysis",
"type": "python",
"request": "launch",
"module": "myoquant",
"justMyCode": true,
"args": ["atp-analysis", "sample_img/sample_atp.jpg", "--cellpose-path", "sample_img/sample_atp_cellpose_mask.tiff"],
}
]
}
104 changes: 70 additions & 34 deletions CLI_Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `myoquant`

MyoQuant Analysis Command Line Interface
myoquant Analysis Command Line Interface

**Usage**:

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

**Options**:

* `--help`: Show this message and exit.
- `--help`: Show this message and exit.

**Commands**:

* `docs`: Generate documentation
* `he-analysis`: Run the HE analysis and quantification on...
* `sdh-analysis`: Run the SDH analysis and quantification on...
- `atp-analysis`: Run the fibre type 1 vs type 2 analysis on...
- `docs`: Generate documentation
- `he-analysis`: Run the nuclei position analysis on HE and...
- `sdh-analysis`: Run the mitochondiral analysis and...

## `myoquant atp-analysis`

Run the fibre type 1 vs type 2 analysis on ATP images.
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.
Then depending on the presence of cellpose , Cellpose is run or not and mask accordingly if binary mask is provided.
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.

**Usage**:

```console
$ myoquant atp-analysis [OPTIONS] IMAGE_PATH
```

**Arguments**:

- `IMAGE_PATH`: The ATP image file path to analyse. [required]

**Options**:

- `--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.
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
- `--output-path PATH`: The path to the folder to save the results. Will save in the same folder as input image if not specified.
- `--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]
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
- `--export-stats / --no-export-stats`: Export per fiber and per nuclei stat table. [default: export-stats]
- `--help`: Show this message and exit.

## `myoquant docs`

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

**Options**:

* `--help`: Show this message and exit.
- `--help`: Show this message and exit.

**Commands**:

* `generate`: Generate markdown version of usage...
- `generate`: Generate markdown version of usage...

### `myoquant docs generate`

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

**Options**:

* `--name TEXT`: The name of the CLI program to use in docs.
* `--output FILE`: An output file to write docs to, like README.md.
* `--help`: Show this message and exit.
- `--name TEXT`: The name of the CLI program to use in docs.
- `--output FILE`: An output file to write docs to, like README.md.
- `--help`: Show this message and exit.

## `myoquant he-analysis`

Run the HE analysis and quantification on the image.
Run the nuclei position analysis on HE and fluo images.
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.
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.
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.

**Usage**:

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

**Arguments**:

* `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]
- `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]

**Options**:

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

## `myoquant sdh-analysis`

Run the SDH analysis and quantification on the image.
Run the mitochondiral analysis and quantification on the image.
First input arguments and option are printed in stdout and all modules are imported and latest SDH model is downloaded.
Then the input image is mask with the binary mask if provided.
Then depending on the presence of cellpose path, Cellpose is run or not and mask accordingly if binary mask is provided.
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.

**Usage**:

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

**Arguments**:

* `IMAGE_PATH`: The image file path to analyse. [required]
- `IMAGE_PATH`: The image file path to analyse. [required]

**Options**:

* `--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.
* `--model-path FILE`: The SDH model path to use for analysis. Will download latest one if no path provided.
* `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
* `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
* `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
* `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
* `--export-stats / --no-export-stats`: Export per fiber stat table. [default: export-stats]
* `--help`: Show this message and exit.
- `--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.
- `--model-path FILE`: The SDH model path to use for analysis. Will download latest one if no path provided.
- `--cellpose-path FILE`: The pre-computed CellPose mask to use for analysis. Will run Cellpose if no path provided. Required as an image file.
- `--output-path PATH`: The path to the folder to save the results. Will save in the current folder if not specified.
- `--cellpose-diameter INTEGER`: Approximative single cell diameter in pixel for CellPose detection. If not specified, Cellpose will try to deduce it.
- `--export-map / --no-export-map`: Export the original image with cells painted by classification label. [default: export-map]
- `--export-stats / --no-export-stats`: Export per fiber stat table. [default: export-stats]
- `--help`: Show this message and exit.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
black:
black app
black myoquant
black tests

black-diff:
black app --diff
black myoquant --diff
black tests --diff

build:
Expand All @@ -17,7 +17,7 @@ mkserve:
mkdocs serve

mypy:
mypy app/ --ignore-missing-imports
mypy myoquant/ --ignore-missing-imports

pre-commit: black mypy ruff test

Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</p>

MyoQuant🔬 is a command-line tool to automatically quantify pathological features in muscle fiber histology images.
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.
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, 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.

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.

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

_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`_

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

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

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

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

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

![image](https://user-images.githubusercontent.com/20109584/210328002-6c483ecf-5ba4-4dab-8347-6d71f5726c5e.png)
3. Example of ATP analysis with: `myoquan atp-analysis sample_atp.jpg`

![image](https://i.imgur.com/2ceiOx8.png)

## Advanced information

Expand Down
6 changes: 4 additions & 2 deletions myoquant/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from rich.console import Console

from .commands.docs import app as docs_app
from .commands import run_sdh, run_he
from .commands import run_sdh, run_he, run_atp

console = Console()

Expand All @@ -16,7 +16,9 @@


app.registered_commands += (
run_sdh.app.registered_commands + run_he.app.registered_commands
run_sdh.app.registered_commands
+ run_he.app.registered_commands
+ run_atp.app.registered_commands
)

if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 6ecfe65

Please sign in to comment.