From f7d190011ebbd271250da44464ce43701bfc3eb5 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Mon, 3 Jun 2024 13:04:13 +0100 Subject: [PATCH] fixture to provide cell data for regression testing --- tests/tests/conftest.py | 21 +++++++++++++++ tests/tests/test_cells/test_matches.py | 37 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/tests/conftest.py b/tests/tests/conftest.py index 65a23bd..2ac4e08 100644 --- a/tests/tests/conftest.py +++ b/tests/tests/conftest.py @@ -1,5 +1,6 @@ from pathlib import Path +import pooch import pytest @@ -7,3 +8,23 @@ def data_path(): """Directory storing all test data""" return Path(__file__).parent.parent / "data" + + +@pytest.fixture +def test_data_registry(): + """ + Create a test data registry for BrainGlobe. + + Returns: + pooch.Pooch: The test data registry object. + + """ + registry = pooch.create( + path=pooch.os_cache("brainglobe_test_data"), + base_url="https://gin.g-node.org/BrainGlobe/test-data/raw/master/", + registry={ + "cellfinder/cells-z-1000-1050.xml": None, + "cellfinder/other-cells-z-1000-1050.xml": None, + }, + ) + return registry diff --git a/tests/tests/test_cells/test_matches.py b/tests/tests/test_cells/test_matches.py index add83bd..6bb7657 100644 --- a/tests/tests/test_cells/test_matches.py +++ b/tests/tests/test_cells/test_matches.py @@ -11,6 +11,36 @@ match_cells, match_points, ) +from brainglobe_utils.IO.cells import get_cells + + +@pytest.fixture +def cells_and_other_cells(test_data_registry): + """ + Provides real-life cell coordinates from a CFOS-labelled brain from + two different cellfinder versions (pre- and post cellfinder PR #398). + Intended to be used for regression testing our cell matching code. + + Parameters + ---------- + test_data_registry : Pooch.pooch + The BrainGlobe test data registry. + + Returns + ------- + cell_data : List[Cell] + The loaded cell data. + + """ + cell_data_path = test_data_registry.fetch( + "cellfinder/cells-z-1000-1050.xml" + ) + other_cell_data_path = test_data_registry.fetch( + "cellfinder/other_cells-z-1000-1050.xml" + ) + cell_data = get_cells(cell_data_path) + other_cell_data = get_cells(other_cell_data_path) + return cell_data, other_cell_data def as_cell(x: List[float]): @@ -19,6 +49,13 @@ def as_cell(x: List[float]): return cells +@pytest.mark.xfail +def test_cell_matching_regression(cells_and_other_cells): + cells, other_cells = cells_and_other_cells + # TODO implement cell matching regression test here, then remove xfail + assert False + + @pytest.mark.parametrize("use_scipy", [True, False]) @pytest.mark.parametrize("pre_match", [True, False]) def test_cell_matches_equal_size(pre_match, use_scipy):