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

Make get_extractor work with MockImagingInterface #1076

Merged
merged 5 commits into from
Sep 12, 2024
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
32 changes: 29 additions & 3 deletions src/neuroconv/tools/testing/mock_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,50 @@ 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,
num_rows: int = 10,
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'.
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
Expand Down
25 changes: 6 additions & 19 deletions tests/test_ophys/test_ophys_interfaces.py
Original file line number Diff line number Diff line change
@@ -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()
Loading