Skip to content

Commit c6a23db

Browse files
author
Corentin
committed
Fixing some infinite slope bug
1 parent 2a3a5dd commit c6a23db

File tree

6 files changed

+56
-11
lines changed

6 files changed

+56
-11
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,5 @@ pid
164164
*.jpg
165165
*.csv
166166
*.png
167-
*.tif
167+
*.tif
168+
debug_data/

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Module",
9+
"type": "python",
10+
"request": "launch",
11+
"module": "myoquant",
12+
"justMyCode": true,
13+
"args": ["he-analysis", "debug_data/tritc_16.tif", "--stardist-path", "debug_data/dapi_16_labels.tif", "--cellpose-path", "debug_data/tritc_16_cp_masks.tif"],
14+
}
15+
]
16+
}

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Twitter Follow](https://img.shields.io/twitter/follow/corentinm_py?style=social) ![Demo Version](https://img.shields.io/badge/Demo-https%3A%2F%2Flbgi.fr%2FMyoQuant%2F-9cf) ![PyPi](https://img.shields.io/badge/PyPi-https%3A%2F%2Fpypi.org%2Fproject%2Fmyoquant%2F-blueviolet) ![Pypi verison](https://img.shields.io/pypi/v/myoquant) ![PyPi Python Version](https://img.shields.io/pypi/pyversions/myoquant) ![PyPi Format](https://img.shields.io/pypi/format/myoquant) ![GitHub last commit](https://img.shields.io/github/last-commit/lambda-science/MyoQuant) ![GitHub](https://img.shields.io/github/license/lambda-science/MyoQuant)
1+
![Twitter Follow](https://img.shields.io/twitter/follow/corentinm_py?style=social) ![Demo Version](https://img.shields.io/badge/Demo-https%3A%2F%2Flbgi.fr%2FMyoQuant%2F-9cf) ![PyPi](https://img.shields.io/badge/PyPi-https%3A%2F%2Fpypi.org%2Fproject%2Fmyoquant%2F-blueviolet) ![Pypi verison](https://img.shields.io/pypi/v/myoquant) ![PyPi Python Version](https://img.shields.io/pypi/pyversions/myoquant) ![PyPi Format](https://img.shields.io/pypi/format/myoquant) ![GitHub last commit](https://img.shields.io/github/last-commit/lambda-science/MyoQuant) ![GitHub](https://img.shields.io/github/license/lambda-science/MyoQuant)
22

33
# MyoQuant🔬: a tool to automatically quantify pathological features in muscle fiber histology images
44

@@ -7,16 +7,17 @@
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. 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.
1111

12-
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.
12+
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.
1313

14-
#### *Warning: This tool is still in early phases and active development.*
14+
#### _Warning: This tool is still in early phases and active development._
1515

1616
## How to install
1717

1818
### Installing from PyPi (Preferred)
19-
**MyoQuant package is officially available on PyPi (pip) repository. [https://pypi.org/project/myoquant/](https://pypi.org/project/myoquant/) ![Pypi verison](https://img.shields.io/pypi/v/myoquant)**
19+
20+
**MyoQuant package is officially available on PyPi (pip) repository. [https://pypi.org/project/myoquant/](https://pypi.org/project/myoquant/) ![Pypi verison](https://img.shields.io/pypi/v/myoquant)**
2021

2122
Using pip, you can simply install MyoQuant in a python environment with a simple: `pip install myoquant`
2223

@@ -42,10 +43,12 @@ Then you can perform SDH or HE analysis. You can use the command `myoquant --hel
4243
_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`_
4344

4445
## Contact
45-
Creator and Maintainer: [**Corentin Meyer**, 3rd year PhD Student in the CSTB Team, ICube — CNRS — Unistra](https://cmeyer.fr) <[email protected]>
46+
47+
Creator and Maintainer: [**Corentin Meyer**, 3rd year PhD Student in the CSTB Team, ICube — CNRS — Unistra](https://cmeyer.fr) <[email protected]>
4648

4749
## Citing MyoQuant🔬
48-
[placeholder]
50+
51+
[placeholder]
4952

5053
## Examples
5154

@@ -62,9 +65,15 @@ For SDH Staining analysis, you can download this sample image: [HERE](https://ww
6265

6366
## Advanced information
6467

68+
### Model path and manual download
69+
6570
For the SDH Analysis our custom model will be downloaded and placed inside the myoquant package directory. You can also download it manually here: [https://lbgi.fr/~meyer/SDH_models/model.h5](https://lbgi.fr/~meyer/SDH_models/model.h5) and then you can place it in the directory of your choice and provide the path to the model file using:
6671
`myoquant sdh-analysis IMAGE_PATH --model_path /path/to/model.h5`
6772

73+
### HuggingFace🤗 repositories for Data and Model
74+
75+
In a effort to push for open-science, MyoQuant [SDH dataset](https://huggingface.co/datasets/corentinm7/MyoQuant-SDH-Data) and [model](https://huggingface.co/corentinm7/MyoQuant-SDH-Model) and availiable on HuggingFace🤗
76+
6877
## Partners
6978

7079
<p align="center">

myoquant/HE_analysis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ def single_cell_analysis(
4848
for _, value in df_nuc_single.iterrows():
4949
n_nuc += 1
5050
# Extend line and find closest point
51+
52+
# Handling of the case where the nucleus is at the exact center of the fiber
53+
if x_fiber == value[3] and y_fiber == value[2]:
54+
n_nuc_intern += 1
55+
continue
56+
5157
m, b = line_equation(x_fiber, y_fiber, value[3], value[2])
5258

5359
intersections_lst = calculate_intersection(

myoquant/draw_line.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
import math
2+
3+
14
def line_equation(x1, y1, x2, y2):
2-
m = (y2 - y1) / (x2 - x1)
5+
# Poor man's handling of the case where the equation is infinite
6+
if x2 - x1 == 0 and y2 > y1:
7+
m = 9999
8+
elif x2 - x1 == 0 and y1 > y2:
9+
m = -9999
10+
else:
11+
m = (y2 - y1) / (x2 - x1)
312
b = y1 - m * x1
13+
if math.isinf(m) or math.isinf(b):
14+
raise ValueError("Line equation is infinite")
415
return m, b
516

617

@@ -16,6 +27,8 @@ def calculate_intersection(m, b, image_dim=(256, 256)):
1627
intersect = (i - b) / m
1728
if intersect >= 0 and intersect < image_dim[1]:
1829
results.append((intersect, i))
30+
if results == []:
31+
raise ValueError("No intersection found")
1932
return results
2033

2134

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "myoquant"
3-
version = "0.1.4"
4-
description = "Command line interface (CLI) for MyoQuant, my histology image quantification tool."
3+
version = "0.1.6"
4+
description = "MyoQuant🔬: a tool to automatically quantify pathological features in muscle fiber histology images."
55
authors = ["Corentin Meyer <[email protected]>"]
66
maintainers = ["Corentin Meyer <[email protected]>"]
77
license = "AGPL-3.0-or-later"

0 commit comments

Comments
 (0)