Example #1
0
    def test_fl_mda_invalid_time_manager_get_fl_mda_invalid_times_failed_due_to_None_param(self):
        gaps_margin = 0.0001
        sampling_rate = 1.0
        mock_metadata = {}

        fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(sampling_rate, mock_metadata)
        fl_mda_invalid_time_manager.get_fl_mda_invalid_times(
            nwb_content=None,
            gaps_margin=gaps_margin
        )
Example #2
0
    def test_fl_mda_invalid_time_manager_get_fl_mda_invalid_times_failed_due_to_lack_of_timestamps(self):
        gaps_margin = 0.0001
        sampling_rate = 1.0
        mock_nwb = MagicMock(spec=NWBFile)
        mock_nwb.acquisition['e-series'].timestamps = None
        mock_metadata = {}

        fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(sampling_rate, mock_metadata)
        fl_mda_invalid_time_manager.get_fl_mda_invalid_times(
            nwb_content=mock_nwb,
            gaps_margin=gaps_margin
        )
Example #3
0
    def test_fl_mda_invalid_time_manager_get_fl_mda_invalid_times_without_gap(self):
        sampling_rate = 1.0
        gaps_margin = 0.0001
        mock_array = np.ndarray(dtype='float', shape=[10,])
        array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        for i, number in enumerate(array):
            mock_array[i] = number
        mock_nwb = MagicMock(spec=NWBFile)
        mock_nwb.acquisition['e-series'].timestamps = mock_array
        mock_metadata = {}

        fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(sampling_rate, mock_metadata)
        fl_mda_invalid_times = fl_mda_invalid_time_manager.get_fl_mda_invalid_times(
            nwb_content=mock_nwb,
            gaps_margin=gaps_margin
        )

        self.assertEqual(fl_mda_invalid_times, [])
Example #4
0
    def test_fl_mda_invalid_time_manager_get_fl_mda_invalid_times_with_gap_at_start(self):
        sampling_rate = 1.0
        gaps_margin = 0.0001
        mock_array = np.ndarray(dtype='float', shape=[10,])
        array = [1, 3, 5, 6, 7, 8, 9, 10, 11, 12]
        for i, number in enumerate(array):
            mock_array[i] = number
        mock_nwb = MagicMock(spec=NWBFile)
        mock_nwb.acquisition['e-series'].timestamps = mock_array
        mock_metadata = {}

        fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(sampling_rate, mock_metadata)
        fl_mda_invalid_times = fl_mda_invalid_time_manager.get_fl_mda_invalid_times(
            nwb_content=mock_nwb,
            gaps_margin=gaps_margin
        )

        self.assertEqual(len(fl_mda_invalid_times), 1)
        self.assertEqual(round(fl_mda_invalid_times[0].start_time, 4), 1.0001)
        self.assertEqual(round(fl_mda_invalid_times[0].stop_time, 4), 4.9999)
Example #5
0
class MdaInvalidTimeOriginator:
    def __init__(self, header, metadata):
        self.fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(
            sampling_rate=float(
                header.configuration.hardware_configuration.sampling_rate),
            metadata=metadata)
        self.mda_invalid_time_injector = MdaInvalidTimeInjector()

    def make(self, nwb_content):
        logger.info('MDA invalid times: Building')
        mda_invalid_times = self.fl_mda_invalid_time_manager.get_fl_mda_invalid_times(
            nwb_content)
        logger.info('MDA invalid times: Injecting')
        self.mda_invalid_time_injector.inject_all(mda_invalid_times,
                                                  nwb_content)
Example #6
0
 def __init__(self, header, metadata):
     self.fl_mda_invalid_time_manager = FlMdaInvalidTimeManager(
         sampling_rate=float(
             header.configuration.hardware_configuration.sampling_rate),
         metadata=metadata)
     self.mda_invalid_time_injector = MdaInvalidTimeInjector()
Example #7
0
 def test_fl_mda_invalid_time_manager_not_initialized_due_to_None_param(self):
     with self.assertRaises(TypeError):
         FlMdaInvalidTimeManager(None)