From 1b61742f088546d93a0d3b55235ae1d050bf8d9e Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 11 Sep 2024 11:10:39 -0600 Subject: [PATCH 1/4] wip --- .../tools/testing/mock_interfaces.py | 3 +++ tests/test_ophys/test_ophys_interfaces.py | 25 +++++-------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/neuroconv/tools/testing/mock_interfaces.py b/src/neuroconv/tools/testing/mock_interfaces.py index f05228b34..93672b2d2 100644 --- a/src/neuroconv/tools/testing/mock_interfaces.py +++ b/src/neuroconv/tools/testing/mock_interfaces.py @@ -162,6 +162,9 @@ class MockImagingInterface(BaseImagingExtractorInterface): A mock imaging interface for testing purposes. """ + ExtractorModuleName = "roiextractors.testing" + ExtractorName = "generate_dummy_imaging_extractor" + def __init__( self, num_frames: int = 30, diff --git a/tests/test_ophys/test_ophys_interfaces.py b/tests/test_ophys/test_ophys_interfaces.py index 1a774f713..9ae151d5a 100644 --- a/tests/test_ophys/test_ophys_interfaces.py +++ b/tests/test_ophys/test_ophys_interfaces.py @@ -1,22 +1,9 @@ -import tempfile -import unittest -from pathlib import Path - -from pynwb.testing.mock.file import mock_NWBFile - +from neuroconv.tools.testing.data_interface_mixins import ( + ImagingExtractorInterfaceTestMixin, +) from neuroconv.tools.testing.mock_interfaces import MockImagingInterface -class TestMockImagingInterface(unittest.TestCase): - def setUp(self): - self.mock_imaging_interface = MockImagingInterface() - - def test_run_conversion(self): - - with tempfile.TemporaryDirectory() as tmpdir: - nwbfile_path = Path(tmpdir) / "test.nwb" - self.mock_imaging_interface.run_conversion(nwbfile_path=nwbfile_path) - - def test_add_to_nwbfile(self): - nwbfile = mock_NWBFile() - self.mock_imaging_interface.add_to_nwbfile(nwbfile) +class TestMockImagingInterface(ImagingExtractorInterfaceTestMixin): + data_interface_cls = MockImagingInterface + interface_kwargs = dict() From 9a886587aece41b3be0c5951b2d6ed54ece83304 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 11 Sep 2024 11:14:04 -0600 Subject: [PATCH 2/4] make get_extractor work with imaging mock interface --- .../tools/testing/mock_interfaces.py | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/neuroconv/tools/testing/mock_interfaces.py b/src/neuroconv/tools/testing/mock_interfaces.py index 93672b2d2..47e723aa5 100644 --- a/src/neuroconv/tools/testing/mock_interfaces.py +++ b/src/neuroconv/tools/testing/mock_interfaces.py @@ -172,17 +172,42 @@ def __init__( num_columns: int = 10, sampling_frequency: float = 30, dtype: str = "uint16", - verbose: bool = True, + verbose: bool = False, + seed: int = 0, photon_series_type: Literal["OnePhotonSeries", "TwoPhotonSeries"] = "TwoPhotonSeries", ): - from roiextractors.testing import generate_dummy_imaging_extractor + """ + Parameters + ---------- + num_frames : int, optional + The number of frames in the mock imaging data, by default 30. + num_rows : int, optional + The number of rows (height) in each frame of the mock imaging data, by default 10. + num_columns : int, optional + The number of columns (width) in each frame of the mock imaging data, by default 10. + sampling_frequency : float, optional + The sampling frequency of the mock imaging data in Hz, by default 30. + dtype : str, optional + The data type of the generated imaging data (e.g., 'uint16'), by default 'uint16'. + verbose : bool, optional + If True, prints additional information during processing, by default True. + seed : int, optional + Random seed for reproducibility, by default 0. + photon_series_type : Literal["OnePhotonSeries", "TwoPhotonSeries"], optional + The type of photon series for the mock imaging data, either "OnePhotonSeries" or + "TwoPhotonSeries", by default "TwoPhotonSeries". + verbose : bool, default False + controls verbosity + """ - self.imaging_extractor = generate_dummy_imaging_extractor( + self.seed = seed + super().__init__( num_frames=num_frames, num_rows=num_rows, num_columns=num_columns, sampling_frequency=sampling_frequency, dtype=dtype, + verbose=verbose, ) self.verbose = verbose From 74bfa0e591a0633078526bc08022624bc6cee634 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 11 Sep 2024 11:18:42 -0600 Subject: [PATCH 3/4] remove redundant verbose --- src/neuroconv/tools/testing/mock_interfaces.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/neuroconv/tools/testing/mock_interfaces.py b/src/neuroconv/tools/testing/mock_interfaces.py index 47e723aa5..12f1dafd4 100644 --- a/src/neuroconv/tools/testing/mock_interfaces.py +++ b/src/neuroconv/tools/testing/mock_interfaces.py @@ -189,8 +189,6 @@ def __init__( The sampling frequency of the mock imaging data in Hz, by default 30. dtype : str, optional The data type of the generated imaging data (e.g., 'uint16'), by default 'uint16'. - verbose : bool, optional - If True, prints additional information during processing, by default True. seed : int, optional Random seed for reproducibility, by default 0. photon_series_type : Literal["OnePhotonSeries", "TwoPhotonSeries"], optional From ca374cb397fd1203ff3b34a0bbf48da3c3e3c308 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 11 Sep 2024 14:23:23 -0600 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09220c407..619648b20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Upcoming ## Bug Fixes -Fixed a setup bug introduced in `v0.6.2` where installation process created a directory instead of a file for test configuration file [PR #1070](https://github.com/catalystneuro/neuroconv/pull/1070) +* Fixed a setup bug introduced in `v0.6.2` where installation process created a directory instead of a file for test configuration file [PR #1070](https://github.com/catalystneuro/neuroconv/pull/1070) +* The method `get_extractor` now works for `MockImagingInterface` [PR #1076](https://github.com/catalystneuro/neuroconv/pull/1076) ## Deprecations