Example #1
0
    def test_fl_nwb_electrode_group_manager_get_FlElectrodeGroups_successfully(self):
        electrode_groups_metadata_1 = {
            'id': 0, 'location': 'mPFC', 'device_type': 'tetrode_12.5', 'description': 'Probe 1',
            'targeted_location': 'Sample predicted location 1', 'targeted_x': 0.0, 'targeted_y': 0.0,
            'targeted_z': 0.0, 'units': 'um'
        }
        electrode_groups_metadata_2 = {
            'id': 1, 'location': 'mPFC', 'device_type': '128c-4s8mm6cm-20um-40um-sl', 'description': 'Probe 2',
            'targeted_location': 'Sample predicted location 2', 'targeted_x': 0.0, 'targeted_y': 0.0,
            'targeted_z': 0.0, 'units': 'um'
        }
        electrode_groups_metadata_3 = {
            'id': 2, 'location': 'mPFC', 'device_type': '128c-4s8mm6cm-20um-40um-sl', 'description': 'Probe 3',
            'targeted_location': 'Sample predicted location 3', 'targeted_x': 0.0, 'targeted_y': 0.0,
            'targeted_z': 0.0, 'units': 'um'
        }
        electrode_groups_metadata = [
            electrode_groups_metadata_1, electrode_groups_metadata_2, electrode_groups_metadata_3
        ]

        mock_probe_1 = Mock(spec=Probe)
        mock_probe_1.probe_type = 'tetrode_12.5'
        mock_probe_2 = Mock(spec=Probe)
        mock_probe_2.probe_type = '128c-4s8mm6cm-20um-40um-sl'
        probes = [mock_probe_1, mock_probe_2]

        mock_electrode_groups_valid_map = {0, 2}

        fl_nwb_electrode_group_manager = FlNwbElectrodeGroupManager(
            electrode_groups_metadata=electrode_groups_metadata
        )

        fl_nwb_electrode_groups = fl_nwb_electrode_group_manager.get_fl_nwb_electrode_groups(
            probes=probes,
            electrode_groups_valid_map=mock_electrode_groups_valid_map
        )
        self.assertEqual(2, len(fl_nwb_electrode_groups))
        self.assertIsInstance(fl_nwb_electrode_groups, list)

        self.assertIsInstance(fl_nwb_electrode_groups[0], FlNwbElectrodeGroup)
        self.assertEqual(fl_nwb_electrode_groups[0].name, '0')
        self.assertEqual(fl_nwb_electrode_groups[0].description, 'Probe 1')
        self.assertEqual(fl_nwb_electrode_groups[0].location, 'mPFC')
        self.assertEqual(fl_nwb_electrode_groups[0].device, mock_probe_1)
        self.assertEqual(fl_nwb_electrode_groups[0].targeted_location, 'Sample predicted location 1')
        self.assertEqual(fl_nwb_electrode_groups[0].targeted_x, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[0].targeted_y, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[0].targeted_z, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[0].units, 'um')

        self.assertIsInstance(fl_nwb_electrode_groups[1], FlNwbElectrodeGroup)
        self.assertEqual(fl_nwb_electrode_groups[1].name, '2')
        self.assertEqual(fl_nwb_electrode_groups[1].description, 'Probe 3')
        self.assertEqual(fl_nwb_electrode_groups[1].location, 'mPFC')
        self.assertEqual(fl_nwb_electrode_groups[1].device, mock_probe_2)
        self.assertEqual(fl_nwb_electrode_groups[1].targeted_location, 'Sample predicted location 3')
        self.assertEqual(fl_nwb_electrode_groups[1].targeted_x, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[1].targeted_y, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[1].targeted_z, 0.0)
        self.assertEqual(fl_nwb_electrode_groups[1].units, 'um')
Example #2
0
 def test_fl_nwb_electrode_group_manager_failed_get_FlNwbElectrodeGroups_due_to_None_params(self):
     fl_nwb_electrode_group_manager = FlNwbElectrodeGroupManager(
         electrode_groups_metadata=[{}, {}]
     )
     fl_nwb_electrode_group_manager.get_fl_nwb_electrode_groups(
         probes=None,
         electrode_groups_valid_map=None
     )
Example #3
0
class ElectrodeGroupOriginator:
    def __init__(self, metadata):
        self.fl_nwb_electrode_group_manager = FlNwbElectrodeGroupManager(
            metadata['electrode groups'])
        self.electrode_group_creator = ElectrodeGroupFactory()
        self.electrode_group_injector = ElectrodeGroupInjector()

    def make(self, nwb_content, probes, electrode_groups_valid_map):
        logger.info('ElectrodeGroups: Building')
        fl_nwb_electrode_groups = self.fl_nwb_electrode_group_manager.get_fl_nwb_electrode_groups(
            probes=probes,
            electrode_groups_valid_map=electrode_groups_valid_map)
        logger.info('ElectrodeGroups: Creating')
        nwb_electrode_groups = [
            self.electrode_group_creator.create_nwb_electrode_group(
                nwb_electrode_group)
            for nwb_electrode_group in fl_nwb_electrode_groups
        ]
        logger.info('ElectrodeGroups: Injecting into NWB')
        self.electrode_group_injector.inject_all_electrode_groups(
            nwb_content, nwb_electrode_groups)
        return nwb_electrode_groups
Example #4
0
 def __init__(self, metadata):
     self.fl_nwb_electrode_group_manager = FlNwbElectrodeGroupManager(
         metadata['electrode groups'])
     self.electrode_group_creator = ElectrodeGroupFactory()
     self.electrode_group_injector = ElectrodeGroupInjector()
Example #5
0
 def test_fl_nwb_electrode_group_manager_failed_init_due_to_None_metadata(
         self):
     FlNwbElectrodeGroupManager(electrode_groups_metadata=None)