Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jupyter notebooks for code instruction #72

Merged
merged 19 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 46 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import sleap_roots as sr

plant = sr.Series.load(
"tests/data/canola_7do/919QDUH.h5",
primary_name="primary_multi_day",
lateral_name="lateral_3_nodes"
primary_name="primary",
lateral_name="lateral"
eberrigan marked this conversation as resolved.
Show resolved Hide resolved
)
pipeline = sr.DicotPipeline()
traits = pipeline.compute_plant_traits(plant, write_csv=True)
Expand All @@ -46,8 +46,8 @@ plant_paths = sr.find_all_series("tests/data/soy_6do")
plants = [
sr.Series.load(
plant_path,
primary_name="primary_multi_day",
lateral_name="lateral__nodes",
primary_name="primary",
lateral_name="lateral",
eberrigan marked this conversation as resolved.
Show resolved Hide resolved
) for plant_path in plant_paths]

pipeline = sr.DicotPipeline()
Expand All @@ -59,15 +59,18 @@ all_traits = pipeline.compute_batch_traits(plants, write_csv=True)
```py
import sleap_roots as sr
import numpy as np
from sleap_roots.points import get_all_pts_array
eberrigan marked this conversation as resolved.
Show resolved Hide resolved

plant = sr.Series.load(
"tests/data/canola_7do/919QDUH.h5",
primary_name="primary_multi_day",
lateral_name="lateral_3_nodes"
primary_name="primary",
lateral_name="lateral"
)

primary, lateral = plant[10]
pts = np.concatenate([primary.numpy(), lateral.numpy()], axis=0).reshape(-1, 2)
frame_index = 0
primary_pts = plant.get_primary_points(frame_index)
lateral_pts = plant.get_lateral_points(frame_index)
pts = get_all_pts_array(primary_pts, lateral_pts)
convex_hull = sr.convhull.get_convhull(pts)
```

Expand All @@ -80,8 +83,8 @@ import sleap_roots as sr

plant = sr.Series.load(
"tests/data/rice_3do/0K9E8BI.h5",
primary_name="longest_3do_6nodes",
lateral_name="main_3do_6nodes"
primary_name="primary",
lateral_name="crown"
)
pipeline = sr.YoungerMonocotPipeline()
traits = pipeline.compute_plant_traits(plant, write_csv=True)
Expand All @@ -96,8 +99,8 @@ plant_paths = sr.find_all_series("tests/data/rice_3do")
plants = [
sr.Series.load(
plant_path,
primary_name="longest_3do_6nodes",
lateral_name="main_3do_6nodes"
primary_name="primary",
lateral_name="crown"
) for plant_path in plant_paths]

pipeline = sr.YoungerMonocotPipeline()
Expand All @@ -109,18 +112,42 @@ all_traits = pipeline.compute_batch_traits(plants, write_csv=True)
```py
import sleap_roots as sr
import numpy as np
from sleap_roots.points import get_all_pts_array

plant = sr.Series.load(
"tests/data/rice_3do/0K9E8BI.h5",
primary_name="longest_3do_6nodes",
lateral_name="main_3do_6nodes"
primary_name="primary",
lateral_name="crown"
)

primary, lateral = plant[10]
pts = np.concatenate([primary.numpy(), lateral.numpy()], axis=0).reshape(-1, 2)
frame_index = 0
primary_pts = plant.get_primary_points(frame_index)
lateral_pts = plant.get_lateral_points(frame_index)
pts = get_all_pts_array(primary_pts, lateral_pts)
convex_hull = sr.convhull.get_convhull(pts)
```

## Tutorials
Jupyter notebooks are located in this repo at `sleap-roots/notebooks`.

To use them, add Jupyter Lab to your conda environment (recommended):

```
conda activate sleap-roots
pip install jupyterlab
```

Then you can change directories to the location of the notebooks, and open Jupyter Lab:

```
cd notebooks
jupyter lab
```

Go through the commands in the notebooks to learn about each pipeline.
You can use the test data located at `tests/data` or copy the notebooks elsewhere for use with your own data!


## Development
For development, first clone the repository:
```
Expand Down Expand Up @@ -167,4 +194,6 @@ This repository was created by the [Talmo Lab](https://talmolab.org) and [Busch

### Citation

*Coming soon.*
E.M. Berrigan, L. Wang, H. Carrillo, K. Echegoyen, M. Kappes, J. Torres, A. Ai-Perreira, E. McCoy, E. Shane, C.D. Copeland, L. Ragel, C. Georgousakis, S. Lee, D. Reynolds,
A. Talgo, J. Gonzalez, L. Zhang, A.B. Rajurkar, M. Ruiz, E. Daniels, L. Maree, S. Pariyar, W. Busch, T.D. Pereira. "Fast and Efficient Root Phenotyping via Pose Estimation"
*Plant Phenomics* 0: DOI:[10.34133/plantphenomics.0175](https://doi.org/10.34133/plantphenomics.0175).
954 changes: 954 additions & 0 deletions notebooks/DicotPipeline.ipynb

Large diffs are not rendered by default.

623 changes: 623 additions & 0 deletions notebooks/MultipleDicotPipeline.ipynb

Large diffs are not rendered by default.

977 changes: 977 additions & 0 deletions notebooks/OlderMonocotPipeline.ipynb

Large diffs are not rendered by default.

990 changes: 990 additions & 0 deletions notebooks/YoungerMonocotPipeline.ipynb

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ dynamic = ["version", "readme"]
version = {attr = "sleap_roots.__version__"}
readme = {file = ["README.md"], content-type="text/markdown"}

[tool.setuptools.packages.find]
include = ["sleap_roots"] # Include only the sleap_roots package
exclude = ["notebooks"] # Exclude the notebooks directory
namespaces = false

[project.optional-dependencies]
dev = [
"pytest",
Expand Down
1 change: 1 addition & 0 deletions sleap_roots/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Series:
Properties:
series_name: Name of the series derived from the HDF5 filename.
expected_count: Fetch the expected plant count for this series from the CSV.
group: Group name for the series from the CSV.
eberrigan marked this conversation as resolved.
Show resolved Hide resolved
"""

h5_path: Optional[str] = None
Expand Down
Loading