Skip to content

Commit

Permalink
remove old recording
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Nov 13, 2024
1 parent 5690c73 commit 9b68611
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 53 deletions.
1 change: 0 additions & 1 deletion src/neuroconv/tools/testing/data_interface_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def test_metadata_schema_valid(self, setup_interface):
Draft7Validator.check_schema(schema=schema)

def test_metadata(self, setup_interface):
# Validate metadata now happens on the class itself
metadata = self.interface.get_metadata()
self.check_extracted_metadata(metadata)

Expand Down
79 changes: 27 additions & 52 deletions tests/test_ecephys/test_ecephys_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,49 @@ class TestSortingInterface(SortingExtractorInterfaceTestMixin):
data_interface_cls = MockSortingInterface
interface_kwargs = dict(num_units=4, durations=[0.100])

def test_propagate_conversion_options(self, setup_interface):
interface = self.interface
metadata = interface.get_metadata()
nwbfile = interface.create_nwbfile(
stub_test=True,
metadata=metadata,
write_as="processing",
units_name="processed_units",
units_description="The processed units.",
)

ecephys = get_module(nwbfile, "ecephys")
self.assertIsNone(nwbfile.units)
self.assertIn("processed_units", ecephys.data_interfaces)


class TestRecordingInterface(RecordingExtractorInterfaceTestMixin):
data_interface_cls = MockRecordingInterface
interface_kwargs = dict(durations=[0.100])


class TestRecordingInterfaceOld(TestCase):
"""Old-style tests for the RecordingInterface. Remove once we we are sure all the behaviors are covered by the mock."""

@classmethod
def setUpClass(cls):
cls.single_segment_recording_interface = MockRecordingInterface(durations=[0.100])
cls.multi_segment_recording_interface = MockRecordingInterface(durations=[0.100, 0.100])

def test_stub_single_segment(self):
interface = self.single_segment_recording_interface
def test_stub(self, setup_interface):
interface = self.interface
metadata = interface.get_metadata()
interface.create_nwbfile(stub_test=True, metadata=metadata)

def test_stub_multi_segment(self):
interface = self.multi_segment_recording_interface
metadata = interface.get_metadata()
interface.create_nwbfile(stub_test=True, metadata=metadata)

def test_no_slash_in_name(self):
interface = self.single_segment_recording_interface
metadata = interface.get_metadata()
def test_no_slash_in_name(self, setup_interface):
interface = self.interface
metadata = interface.interface()
metadata["Ecephys"]["ElectricalSeries"]["name"] = "test/slash"
with self.assertRaises(jsonschema.exceptions.ValidationError):
interface.validate_metadata(metadata)

def test_stub_multi_segment(self):

class TestAlwaysWriteTimestamps:
interface = MockRecordingInterface(durations=[0.100, 0.100])
metadata = interface.get_metadata()
interface.create_nwbfile(stub_test=True, metadata=metadata)

def test_always_write_timestamps(self):
# By default the MockRecordingInterface has a uniform sampling rate
interface = MockRecordingInterface(durations=[1.0], sampling_frequency=30_000.0)
def test_always_write_timestamps(self, setup_interface):

nwbfile = interface.create_nwbfile(always_write_timestamps=True)
nwbfile = self.interface.create_nwbfile(always_write_timestamps=True)
electrical_series = nwbfile.acquisition["ElectricalSeries"]

expected_timestamps = interface.recording_extractor.get_times()

expected_timestamps = self.interface.recording_extractor.get_times()
np.testing.assert_array_equal(electrical_series.timestamps[:], expected_timestamps)


Expand Down Expand Up @@ -188,28 +188,3 @@ def test_sorting_full(self):
nwbfile = io.read()
for i, start_times in enumerate(self.sorting_start_frames):
assert len(nwbfile.units["spike_times"][i]) == self.num_frames - start_times

def test_sorting_propagate_conversion_options(self):
minimal_nwbfile = self.test_dir / "temp2.nwb"
metadata = self.test_sorting_interface.get_metadata()
metadata["NWBFile"]["session_start_time"] = datetime.now().astimezone()
units_description = "The processed units."
conversion_options = dict(
TestSortingInterface=dict(
write_as="processing",
units_name="processed_units",
units_description=units_description,
)
)
self.test_sorting_interface.run_conversion(
nwbfile_path=minimal_nwbfile,
metadata=metadata,
conversion_options=conversion_options,
)

with NWBHDF5IO(minimal_nwbfile, "r") as io:
nwbfile = io.read()
ecephys = get_module(nwbfile, "ecephys")
self.assertIsNone(nwbfile.units)
self.assertIn("processed_units", ecephys.data_interfaces)
self.assertEqual(ecephys["processed_units"].description, units_description)

0 comments on commit 9b68611

Please sign in to comment.