8000 Test plant trait computation for DicotPipeline by andrewjoc · Pull Request #95 · talmolab/sleap-roots · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Test plant trait computation for DicotPipeline #95

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

Merged
merged 15 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions sleap_roots/convhull.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def get_chull_intersection_vectors(


def get_chull_intersection_vectors_left(
vectors: Tuple[np.ndarray, np.ndarray]
vectors: Tuple[np.ndarray, np.ndarray],
) -> np.ndarray:
"""Get the vector from the top left point to the left intersection point.

Expand All @@ -623,7 +623,7 @@ def get_chull_intersection_vectors_left(


def get_chull_intersection_vectors_right(
vectors: Tuple[np.ndarray, np.ndarray]
vectors: Tuple[np.ndarray, np.ndarray],
) -> np.ndarray:
"""Get the vector from the top right point to the right intersection point.

Expand Down
2 changes: 1 addition & 1 deletion sleap_roots/networklength.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_bbox(pts: np.ndarray) -> Tuple[float, float, float, float]:


def get_network_width_depth_ratio(
pts: Union[np.ndarray, Tuple[float, float, float, float]]
pts: Union[np.ndarray, Tuple[float, float, float, float]],
) -> float:
"""Return width to depth ratio of bounding box for root network.

Expand Down
4 changes: 2 additions & 2 deletions sleap_roots/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def get_left_right_normalized_vectors(


def get_left_normalized_vector(
normalized_vectors: Tuple[np.ndarray, np.ndarray]
normalized_vectors: Tuple[np.ndarray, np.ndarray],
) -> np.ndarray:
"""Get the normalized vector from r0 to r1 on the left side of a crown root system.

Expand All @@ -283,7 +283,7 @@ def get_left_normalized_vector(


def get_right_normalized_vector(
normalized_vectors: Tuple[np.ndarray, np.ndarray]
normalized_vectors: Tuple[np.ndarray, np.ndarray],
) -> np.ndarray:
"""Get the normalized vector from r0 to r1 on the right side of a crown root system.

Expand Down
2 changes: 2 additions & 0 deletions tests/data/canola_7do/919QDUH.batch_traits.csv

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions tests/data/canola_7do/919QDUH.traits.csv

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions tests/data/soy_6do/6PR6AA22JK.batch_traits.csv

Large diffs are not rendered by default.

73 changes: 73 additions & 0 deletions tests/data/soy_6do/6PR6AA22JK.traits.csv

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions tests/fixtures/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ def canola_lateral_slp():
return "tests/data/canola_7do/919QDUH.lateral.predictions.slp"


@pytest.fixture
def canola_traits_csv():
"""Path to computed traits csv for 7 day old canola."""
return "tests/data/canola_7do/919QDUH.traits.csv"


@pytest.fixture
def canola_batch_traits_csv():
"""Path to computed batch traits csv for 7 day old canola."""
return "tests/data/canola_7do/919QDUH.batch_traits.csv"


@pytest.fixture
def rice_pipeline_output_folder():
"""Path to the folder with the output of the rice pipeline."""
Expand Down Expand Up @@ -109,6 +121,18 @@ def soy_lateral_slp():
return "tests/data/soy_6do/6PR6AA22JK.lateral.predictions.slp"


@pytest.fixture
def soy_traits_csv():
"""Path to computed traits csv for 6 day old soy."""
return "tests/data/soy_6do/6PR6AA22JK.traits.csv"


@pytest.fixture
def soy_batch_traits_csv():
"""Path to computed batch traits csv for 6 day old soy."""
return "tests/data/soy_6do/6PR6AA22JK.batch_traits.csv"


@pytest.fixture
def multiple_arabidopsis_11do_folder():
"""Path to a folder with the predictions for 3, 11 day old arabidopsis."""
Expand Down
64 changes: 62 additions & 2 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,39 @@ def test_get_frame_rice_10do(
# Get the crown labeled frame
crown_lf = frames.get("crown")

# Compare instances
for i in range(len(expected_labeled_frame.instances)):

crown_instance = crown_lf.instances[i]
expected_labeled_frame_instance = expected_labeled_frame.instances[i]

assert np.allclose(
crown_instance.numpy(),
expected_labeled_frame_instance.numpy(),
atol=1e-7,
equal_nan=True,
)

assert (
(crown_instance.track is None)
and (expected_labeled_frame_instance.track is None)
) or (crown_instance.track is expected_labeled_frame_instance.track)

assert np.isclose(
crown_instance.score,
expected_labeled_frame_instance.score,
atol=1e-7,
equal_nan=True,
)
assert np.isclose(
crown_instance.tracking_score,
expected_labeled_frame_instance.tracking_score,
atol=1e-7,
equal_nan=True,
)

# Compare the attributes of the labeled frames
assert crown_lf.frame_idx == expected_labeled_frame.frame_idx
assert crown_lf.instances == expected_labeled_frame.instances
assert crown_lf.video.filename == expected_labeled_frame.video.filename
assert crown_lf.video.shape == expected_labeled_frame.video.shape
assert crown_lf.video.backend == expected_labeled_frame.video.backend
Expand All @@ -307,9 +337,39 @@ def test_get_frame_rice_10do_no_video(
# Get the crown labeled frame
crown_lf = frames.get("crown")

# Compare instances
for i in range(len(expected_labeled_frame.instances)):

crown_instance = crown_lf.instances[i]
expected_labeled_frame_instance = expected_labeled_frame.instances[i]

assert np.allclose(
crown_instance.numpy(),
expected_labeled_frame_instance.numpy(),
atol=1e-7,
equal_nan=True,
)

assert (
(crown_instance.track is None)
and (expected_labeled_frame_instance.track is None)
) or (crown_instance.track is expected_labeled_frame_instance.track)

assert np.isclose(
crown_instance.score,
expected_labeled_frame_instance.score,
atol=1e-7,
equal_nan=True,
)
assert np.isclose(
crown_instance.tracking_score,
expected_labeled_frame_instance.tracking_score,
atol=1e-7,
equal_nan=True,
)

# Compare the attributes of the labeled frames
assert crown_lf.frame_idx == expected_labeled_frame.frame_idx
assert crown_lf.instances == expected_labeled_frame.instances
assert crown_lf.video.filename == expected_labeled_frame.video.filename
assert crown_lf.video.shape == expected_labeled_frame.video.shape
assert crown_lf.video.backend == expected_labeled_frame.video.backend
Expand Down
Loading
Loading
0