コード例 #1
0
    def test_device_factory_failed_creating_Probe_due_to_none_param_in_FlProbe(
            self):
        mock_fl_header_device = Mock(spec=FlHeaderDevice)
        mock_fl_header_device.name = 'HeaderDevice_1'
        mock_fl_header_device.global_configuration = None

        DeviceFactory.create_header_device(
            fl_header_device=mock_fl_header_device)
コード例 #2
0
 def __init__(self, header, metadata):
     header_path = str(path) + '/../../../data/' + \
         metadata['default_header_file_path']
     default_header = Header(header_path)
     self.fl_header_device_manager = FlHeaderDeviceManager(
         'header_device', header.configuration.global_configuration,
         default_header.configuration.global_configuration)
     self.device_injector = DeviceInjector()
     self.device_factory = DeviceFactory()
コード例 #3
0
    def test_device_factory_create_DataAcqDevice_successfully(self):
        mock_fl_data_acq_device = Mock(spec=FlDataAcqDevice)
        mock_fl_data_acq_device.name = 'Acq_0'
        mock_fl_data_acq_device.system = 'system_0'
        mock_fl_data_acq_device.amplifier = 'amplifier_0'
        mock_fl_data_acq_device.adc_circuit = 'adc_circuit_0'

        DeviceFactory.create_data_acq_device(
            fl_data_acq_device=mock_fl_data_acq_device)
コード例 #4
0
    def test_device_factory_failed_creating_CameraDevice_due_to_none_name_in_FlDevice(
            self):
        mock_fl_camera_device = Mock(spec=FlCameraDevice)
        mock_fl_camera_device.name = 'CameraDevice1'
        mock_fl_camera_device.meters_per_pixel = None
        mock_fl_camera_device.manufacturer = 'novela'
        mock_fl_camera_device.model = 'gt500'
        mock_fl_camera_device.lens = '500dpt'
        mock_fl_camera_device.camera_name = 'john'

        DeviceFactory.create_camera_device(
            fl_camera_device=mock_fl_camera_device)
コード例 #5
0
    def test_device_factory_failed_creating_Probe_due_to_none_param_in_metadata_FlProbe(
            self):
        mock_fl_probe = Mock(spec=FlProbe)
        mock_fl_probe.probe_id = 1
        mock_fl_probe.name = None
        mock_fl_probe.probe_type = None
        mock_fl_probe.units = None
        mock_fl_probe.probe_description = None
        mock_fl_probe.contact_side_numbering = None
        mock_fl_probe.contact_size = None
        mock_fl_probe.shanks = None

        DeviceFactory.create_probe(fl_probe=mock_fl_probe)
コード例 #6
0
    def test_device_factory_create_Probe_successfully(self):
        mock_shank_1 = Mock(spec=Shank)
        mock_shank_2 = Mock(spec=Shank)

        mock_fl_probe = Mock(spec=FlProbe)
        mock_fl_probe.probe_id = 1
        mock_fl_probe.name = 'probe 1'
        mock_fl_probe.probe_type = 'Type1'
        mock_fl_probe.units = 'um'
        mock_fl_probe.probe_description = 'sample description'
        mock_fl_probe.contact_side_numbering = True
        mock_fl_probe.contact_size = 20.0
        mock_fl_probe.shanks = [mock_shank_1, mock_shank_2]

        probe = DeviceFactory.create_probe(fl_probe=mock_fl_probe)

        self.assertIsNotNone(probe)
        self.assertIsInstance(probe, Probe)

        self.assertEqual(probe.name, 'probe 1')
        self.assertEqual(probe.id, 1)
        self.assertEqual(probe.contact_size, 20.0)
        self.assertEqual(probe.probe_type, 'Type1')
        self.assertEqual(probe.units, 'um')
        self.assertEqual(probe.probe_description, 'sample description')
        self.assertEqual(probe.contact_side_numbering, True)
        self.assertEqual(probe.shanks, {
            mock_shank_1.name: mock_shank_1,
            mock_shank_2.name: mock_shank_2
        })
コード例 #7
0
    def test_device_factory_create_Device_successfully(self):
        mock_fl_device = Mock(spec=FlDevice)
        mock_fl_device.name = 'Device1'

        device = DeviceFactory.create_device(fl_device=mock_fl_device)

        self.assertIsNotNone(device)

        self.assertIsInstance(device, Device)
        self.assertEqual(device.name, 'Device1')
コード例 #8
0
    def test_device_factory_create_CameraDevice_successfully(self):
        mock_fl_camera_device = Mock(spec=FlCameraDevice)
        mock_fl_camera_device.name = 'CameraDevice1'
        mock_fl_camera_device.meters_per_pixel = 0.02
        mock_fl_camera_device.manufacturer = 'novela'
        mock_fl_camera_device.model = 'gt500'
        mock_fl_camera_device.lens = '500dpt'
        mock_fl_camera_device.camera_name = 'john'

        camera_device = DeviceFactory.create_camera_device(
            fl_camera_device=mock_fl_camera_device)

        self.assertIsInstance(camera_device, CameraDevice)
        self.assertEqual(camera_device.name, 'CameraDevice1')
        self.assertEqual(camera_device.meters_per_pixel, 0.02)
コード例 #9
0
class CameraDeviceOriginator:

    def __init__(self, metadata):
        self.fl_camera_device_manager = FlCameraDeviceManager(metadata)
        self.device_injector = DeviceInjector()
        self.device_factory = DeviceFactory()

    def make(self, nwb_content):
        logger.info('CameraDevice: Building')
        fl_camera_devices = self.fl_camera_device_manager.get_fl_device_manager()
        logger.info('CameraDevice: Creating')
        camera_devices = [self.device_factory.create_camera_device(single_camera_device)
                          for single_camera_device in fl_camera_devices]
        logger.info('CameraDevice: Injecting into NWB')
        self.device_injector.inject_all_devices(nwb_content, camera_devices)
コード例 #10
0
class HeaderDeviceOriginator:
    def __init__(self, header, metadata):
        header_path = str(path) + '/../../../data/' + \
            metadata['default_header_file_path']
        default_header = Header(header_path)
        self.fl_header_device_manager = FlHeaderDeviceManager(
            'header_device', header.configuration.global_configuration,
            default_header.configuration.global_configuration)
        self.device_injector = DeviceInjector()
        self.device_factory = DeviceFactory()

    def make(self, nwb_content):
        logger.info('HeaderDevice: Building')
        fl_header_device = self.fl_header_device_manager.get_fl_header_device()
        logger.info('HeaderDevice: Creating')
        header_device = self.device_factory.create_header_device(
            fl_header_device)
        logger.info('HeaderDevice: Injecting into NWB')
        self.device_injector.inject_all_devices(nwb_content, [header_device])
コード例 #11
0
 def test_device_factory_failed_creating_CameraDevice_due_to_none_FlDevice(
         self):
     DeviceFactory.create_camera_device(fl_camera_device=None)
コード例 #12
0
    def test_device_factory_failed_creating_Device_due_to_none_name_in_FlDevice(
            self):
        mock_fl_device = Mock(spec=FlDevice)
        mock_fl_device.name = None

        DeviceFactory.create_device(fl_device=mock_fl_device)
コード例 #13
0
 def __init__(self, metadata):
     self.fl_camera_device_manager = FlCameraDeviceManager(metadata)
     self.device_injector = DeviceInjector()
     self.device_factory = DeviceFactory()
コード例 #14
0
    def test_device_factory_create_HeaderDevice_successfully(self):
        mock_fl_header_device = Mock(spec=FlHeaderDevice)
        mock_global_configuration = {}
        mock_global_configuration[
            'headstage_serial'] = 'Sample headstage_serial'
        mock_global_configuration[
            'headstage_smart_ref_on'] = 'Sample headstage_smart_ref_on'
        mock_global_configuration['realtime_mode'] = 'Sample realtime_mode'
        mock_global_configuration[
            'headstage_auto_settle_on'] = 'Sample headstage_auto_settle_on'
        mock_global_configuration[
            'timestamp_at_creation'] = 'Sample timestamp_at_creation'
        mock_global_configuration[
            'controller_firmware_version'] = 'Sample controller_firmware_version'
        mock_global_configuration[
            'controller_serial'] = 'Sample controller_serial'
        mock_global_configuration[
            'save_displayed_chan_only'] = 'Sample save_displayed_chan_only'
        mock_global_configuration[
            'headstage_firmware_version'] = 'Sample headstage_firmware_version'
        mock_global_configuration['qt_version'] = 'Sample qt_version'
        mock_global_configuration['compile_date'] = 'Sample compile_date'
        mock_global_configuration['compile_time'] = 'Sample compile_time'
        mock_global_configuration['file_prefix'] = 'Sample file_prefix'
        mock_global_configuration[
            'headstage_gyro_sensor_on'] = 'Sample headstage_gyro_sensor_on'
        mock_global_configuration[
            'headstage_mag_sensor_on'] = 'Sample headstage_mag_sensor_on'
        mock_global_configuration['trodes_version'] = 'Sample trodes_version'
        mock_global_configuration[
            'headstage_accel_sensor_on'] = 'Sample headstage_accel_sensor_on'
        mock_global_configuration['commit_head'] = 'Sample commit_head'
        mock_global_configuration[
            'system_time_at_creation'] = 'Sample system_time_at_creation'
        mock_global_configuration['file_path'] = 'Sample file_path'
        mock_fl_header_device.name = 'HeaderDevice_1'
        mock_fl_header_device.global_configuration = mock_global_configuration

        header_device = DeviceFactory.create_header_device(
            fl_header_device=mock_fl_header_device)

        self.assertIsNotNone(header_device)
        self.assertIsInstance(header_device, HeaderDevice)
        self.assertEqual(header_device.name, 'HeaderDevice_1')
        self.assertEqual(header_device.headstage_serial,
                         'Sample headstage_serial')
        self.assertEqual(header_device.headstage_smart_ref_on,
                         'Sample headstage_smart_ref_on')
        self.assertEqual(header_device.realtime_mode, 'Sample realtime_mode')
        self.assertEqual(header_device.headstage_auto_settle_on,
                         'Sample headstage_auto_settle_on')
        self.assertEqual(header_device.timestamp_at_creation,
                         'Sample timestamp_at_creation')
        self.assertEqual(header_device.controller_firmware_version,
                         'Sample controller_firmware_version')
        self.assertEqual(header_device.controller_serial,
                         'Sample controller_serial')
        self.assertEqual(header_device.save_displayed_chan_only,
                         'Sample save_displayed_chan_only')
        self.assertEqual(header_device.headstage_firmware_version,
                         'Sample headstage_firmware_version')
        self.assertEqual(header_device.qt_version, 'Sample qt_version')
        self.assertEqual(header_device.compile_date, 'Sample compile_date')
        self.assertEqual(header_device.compile_time, 'Sample compile_time')
        self.assertEqual(header_device.file_prefix, 'Sample file_prefix')
        self.assertEqual(header_device.headstage_gyro_sensor_on,
                         'Sample headstage_gyro_sensor_on')
        self.assertEqual(header_device.headstage_mag_sensor_on,
                         'Sample headstage_mag_sensor_on')
        self.assertEqual(header_device.trodes_version, 'Sample trodes_version')
        self.assertEqual(header_device.headstage_accel_sensor_on,
                         'Sample headstage_accel_sensor_on')
        self.assertEqual(header_device.commit_head, 'Sample commit_head')
        self.assertEqual(header_device.system_time_at_creation,
                         'Sample system_time_at_creation')
        self.assertEqual(header_device.file_path, 'Sample file_path')
コード例 #15
0
 def test_device_factory_failed_creating_Probe_due_to_none_FlProbe(self):
     DeviceFactory.create_probe(fl_probe=None)
コード例 #16
0
    def test_header_device_manager_create_HeaderDevice_successfully(self):
        mock_configuration = Mock(GlobalConfiguration)
        header_device_manager = FlHeaderDeviceManager("sample_name",
                                                      mock_configuration,
                                                      mock_configuration)
        header_device_manager.global_configuration = {
            'headstage_serial': 'Sample headstage_serial',
            'headstage_smart_ref_on': 'Sample headstage_smart_ref_on',
            'realtime_mode': 'Sample realtime_mode',
            'headstage_auto_settle_on': 'Sample headstage_auto_settle_on',
            'timestamp_at_creation': 'Sample timestamp_at_creation',
            'controller_firmware_version':
            'Sample controller_firmware_version',
            'controller_serial': 'Sample controller_serial',
            'save_displayed_chan_only': 'Sample save_displayed_chan_only',
            'headstage_firmware_version': 'Sample headstage_firmware_version',
            'qt_version': 'Sample qt_version',
            'compile_date': 'Sample compile_date',
            'compile_time': 'Sample compile_time',
            'file_prefix': 'Sample file_prefix',
            'headstage_gyro_sensor_on': 'Sample headstage_gyro_sensor_on',
            'headstage_mag_sensor_on': 'Sample headstage_mag_sensor_on',
            'trodes_version': 'Sample trodes_version',
            'headstage_accel_sensor_on': 'Sample headstage_accel_sensor_on',
            'commit_head': 'Sample commit_head',
            'system_time_at_creation': 'Sample system_time_at_creation',
            'file_path': 'Sample file_path'
        }
        header_device_manager.default_configuration = {
            'headstage_serial': '1',
            'headstage_smart_ref_on': '1',
            'realtime_mode': '1',
            'headstage_auto_settle_on': '1',
            'timestamp_at_creation': '1',
            'controller_firmware_version': '1',
            'controller_serial': '1',
            'save_displayed_chan_only': '1',
            'headstage_firmware_version': '1',
            'qt_version': '1',
            'compile_date': '1',
            'compile_time': '1',
            'file_prefix': '1',
            'headstage_gyro_sensor_on': '1',
            'headstage_mag_sensor_on': '1',
            'trodes_version': '1',
            'headstage_accel_sensor_on': '1',
            'commit_head': '1',
            'system_time_at_creation': '1',
            'file_path': '1'
        }

        fl_header_device = header_device_manager.get_fl_header_device()
        header_device = DeviceFactory.create_header_device(fl_header_device)

        self.assertIsNotNone(header_device)
        self.assertIsInstance(header_device, HeaderDevice)
        self.assertEqual(header_device.headstage_serial,
                         'Sample headstage_serial')
        self.assertEqual(header_device.headstage_smart_ref_on,
                         'Sample headstage_smart_ref_on')
        self.assertEqual(header_device.realtime_mode, 'Sample realtime_mode')
        self.assertEqual(header_device.headstage_auto_settle_on,
                         'Sample headstage_auto_settle_on')
        self.assertEqual(header_device.timestamp_at_creation,
                         'Sample timestamp_at_creation')
        self.assertEqual(header_device.controller_firmware_version,
                         'Sample controller_firmware_version')
        self.assertEqual(header_device.controller_serial,
                         'Sample controller_serial')
        self.assertEqual(header_device.save_displayed_chan_only,
                         'Sample save_displayed_chan_only')
        self.assertEqual(header_device.headstage_firmware_version,
                         'Sample headstage_firmware_version')
        self.assertEqual(header_device.qt_version, 'Sample qt_version')
        self.assertEqual(header_device.compile_date, 'Sample compile_date')
        self.assertEqual(header_device.compile_time, 'Sample compile_time')
        self.assertEqual(header_device.file_prefix, 'Sample file_prefix')
        self.assertEqual(header_device.headstage_gyro_sensor_on,
                         'Sample headstage_gyro_sensor_on')
        self.assertEqual(header_device.headstage_mag_sensor_on,
                         'Sample headstage_mag_sensor_on')
        self.assertEqual(header_device.trodes_version, 'Sample trodes_version')
        self.assertEqual(header_device.headstage_accel_sensor_on,
                         'Sample headstage_accel_sensor_on')
        self.assertEqual(header_device.commit_head, 'Sample commit_head')
        self.assertEqual(header_device.system_time_at_creation,
                         'Sample system_time_at_creation')
        self.assertEqual(header_device.file_path, 'Sample file_path')
コード例 #17
0
 def test_device_factory_failed_creating_HeaderDevice_due_to_none_FlHeaderDevice(
         self):
     DeviceFactory.create_header_device(fl_header_device=None)
コード例 #18
0
    def __init__(self,
                 data_path: str,
                 animal_name: str,
                 date: str,
                 nwb_metadata: MetadataManager,
                 process_dio: bool = True,
                 process_mda: bool = True,
                 process_analog: bool = True,
                 process_pos_timestamps: bool = True,
                 video_path: str = '',
                 output_file: str = 'output.nwb',
                 reconfig_header: str = ''):

        logger.info('NWBFileBuilder initialization')
        logger.info('NWB builder initialization parameters: \n' +
                    'data_path = ' + str(data_path) + '\n' + 'animal_name = ' +
                    str(animal_name) + '\n' + 'date = ' + str(date) + '\n' +
                    'nwb_metadata = ' + str(nwb_metadata) + '\n' +
                    'process_dio = ' + str(process_dio) + '\n' +
                    'process_mda = ' + str(process_mda) + '\n' +
                    'process_analog = ' + str(process_analog) + '\n' +
                    'output_file = ' + str(output_file) + '\n')

        validation_registrator = ValidationRegistrator()
        validation_registrator.register(PathValidator(data_path))
        validation_registrator.validate()

        self.animal_name = animal_name
        self.date = date
        self.data_path = data_path
        self.metadata = nwb_metadata.metadata
        metadata_section_validator = MetadataSectionValidator(self.metadata)
        metadata_section_validator.validate_sections()
        if self.metadata.get('associated_files', []):
            associated_files_existance_validator = AssociatedFilesExistanceValidator(
                self.metadata['associated_files'])
            if associated_files_existance_validator.files_exist():
                pass
            else:
                raise Exception(
                    "one or more associated file listed in metadata.yaml file does not exist"
                )
        self.probes = nwb_metadata.probes
        self.process_dio = process_dio
        self.process_mda = process_mda
        self.process_analog = process_analog
        self.process_pos_timestamps = process_pos_timestamps
        self.output_file = output_file
        self.video_path = video_path
        self.link_to_notes = self.metadata.get('link to notes', None)
        data_types_for_scanning = {
            'pos': True,
            'time': True,
            'mda': process_mda,
            'DIO': process_dio,
            'analog': process_analog
        }

        rec_files_list = RecFileFinder().find_rec_files(
            path=(self.data_path + '/' + self.animal_name + '/raw/' +
                  self.date))

        header_file = HeaderProcessor.process_headers(rec_files_list)
        if reconfig_header:
            self.header = Header(reconfig_header)
        else:
            self.header = Header(header_file)
        self.data_scanner = DataScanner(data_path, animal_name, nwb_metadata)
        self.dataset_names = self.data_scanner.get_all_epochs(date)
        full_data_path = data_path + '/' + animal_name + '/preprocessing/' + date

        validation_registrator = ValidationRegistrator()
        validation_registrator.register(
            NTrodeValidator(self.metadata, self.header, self.probes))
        validation_registrator.register(
            PreprocessingValidator(full_data_path, self.dataset_names,
                                   data_types_for_scanning))
        validation_registrator.register(TaskValidator(self.metadata['tasks']))
        validation_registrator.validate()

        self.__extract_datasets(animal_name, date)

        self.corrupted_data_manager = CorruptedDataManager(self.metadata)

        self.shanks_electrode_originator = ShanksElectrodeOriginator(
            self.probes, self.metadata)
        self.shanks_originator = ShanksOriginator(self.probes, self.metadata)

        self.fl_probe_manager = FlProbeManager(self.probes)
        self.device_injector = DeviceInjector()
        self.device_factory = DeviceFactory()

        self.electrode_group_originator = ElectrodeGroupOriginator(
            self.metadata)
        self.electrodes_originator = ElectrodesOriginator(
            self.probes, self.metadata)

        self.session_time_extractor = SessionTimeExtractor(
            self.datasets, self.animal_name, self.date, self.dataset_names)

        self.mda_valid_time_originator = MdaValidTimeOriginator(
            self.header, self.metadata)
        self.mda_invalid_time_originator = MdaInvalidTimeOriginator(
            self.header, self.metadata)
        self.pos_valid_time_originator = PosValidTimeOriginator(self.metadata)
        self.pos_invalid_time_originator = PosInvalidTimeOriginator(
            self.metadata)

        self.epochs_originator = EpochsOriginator(self.datasets)

        if 'associated_files' in self.metadata:
            self.associated_files_originator = AssociatedFilesOriginator(
                self.metadata)

        self.electrodes_extension_originator = ElectrodesExtensionOriginator(
            self.probes, self.metadata, self.header)

        self.sample_count_timestamp_corespondence_originator =\
            SampleCountTimestampCorespondenceOriginator(self.datasets)
        self.processing_module_originator = ProcessingModuleOriginator()
        self.task_originator = TaskOriginator(self.metadata)
        self.camera_device_originator = CameraDeviceOriginator(self.metadata)
        self.header_device_originator = HeaderDeviceOriginator(
            self.header, self.metadata)
        self.probes_originator = ProbeOriginator(self.device_factory,
                                                 self.device_injector,
                                                 self.probes)
        self.camera_sample_frame_counts_originator = CameraSampleFrameCountsOriginator(
            self.data_path + "/" + animal_name + "/raw/" + self.date + "/")
        self.video_files_originator = VideoFilesOriginator(
            self.data_path + "/" + animal_name + "/raw/" + self.date + "/",
            self.video_path,
            self.metadata["associated_video_files"],
        )

        self.data_acq_device_originator = DataAcqDeviceOriginator(
            device_factory=self.device_factory,
            device_injector=self.device_injector,
            metadata=self.metadata['data acq device'])

        if self.process_mda:
            self.mda_originator = MdaOriginator(self.datasets, self.header,
                                                self.metadata)

        if self.process_dio:
            self.dio_originator = DioOriginator(self.metadata, self.datasets)

        if self.process_analog:
            self.analog_originator = AnalogOriginator(self.datasets,
                                                      self.metadata)

        self.position_originator = PositionOriginator(
            self.datasets, self.metadata, self.dataset_names,
            self.process_pos_timestamps)
コード例 #19
0
    def __init__(
            self,
            data_path: str,
            animal_name: str,
            date: str,
            nwb_metadata: MetadataManager,
            process_dio: bool = True,
            process_mda: bool = True,
            process_analog: bool = True,
            process_pos_timestamps: bool = True,
            preprocessing_path: str = '',
            video_path: str = '',
            output_file: str = 'output.nwb',
            reconfig_header: str = '',
            is_old_dataset: bool = False,
            session_start_time=None,
    ):

        logger.info('NWBFileBuilder initialization')
        logger.info(
            'NWB builder initialization parameters: \n'
            + 'data_path = ' + str(data_path) + '\n'
            + 'animal_name = ' + str(animal_name) + '\n'
            + 'date = ' + str(date) + '\n'
            + 'nwb_metadata = ' + str(nwb_metadata) + '\n'
            + 'process_dio = ' + str(process_dio) + '\n'
            + 'process_mda = ' + str(process_mda) + '\n'
            + 'process_analog = ' + str(process_analog) + '\n'
            + 'output_file = ' + str(output_file) + '\n'
        )

        validation_registrator = ValidationRegistrator()
        validation_registrator.register(PathValidator(data_path))
        validation_registrator.validate()

        self.animal_name = animal_name
        self.date = date
        self.data_path = data_path
        self.metadata = nwb_metadata.metadata
        metadata_section_validator = MetadataSectionValidator(self.metadata)
        metadata_section_validator.validate_sections()
        if self.metadata.get('associated_files', []):
            associated_files_existance_validator = AssociatedFilesExistanceValidator(
                self.metadata['associated_files'])
            if not associated_files_existance_validator.files_exist():
                raise Exception(
                    "one or more associated file listed in metadata.yaml file does not exist")
        self.probes = nwb_metadata.probes
        self.process_dio = process_dio
        self.process_mda = process_mda
        self.process_analog = process_analog
        self.process_pos_timestamps = process_pos_timestamps
        if not preprocessing_path:
            self.preprocessing_path = data_path
        else:
            self.preprocessing_path = preprocessing_path
        self.output_file = output_file
        self.video_path = video_path
        self.is_old_dataset = is_old_dataset
        self.link_to_notes = self.metadata.get('link to notes', None)
        data_types_for_scanning = {'pos': True,
                                   'time': True,
                                   'mda': process_mda,
                                   'DIO': process_dio,
                                   'analog': process_analog}

        rec_files_list = RecFileFinder().find_rec_files(
            path=os.path.join(
                self.data_path, self.animal_name, 'raw', self.date)
        )

        if not preprocessing_path:
            header_path = None  # default
        else:
            header_path = os.path.join(
                self.preprocessing_path, self.animal_name, 'headers',
                self.date)
            os.makedirs(header_path, exist_ok=True)
        header_file = HeaderProcessor.process_headers(
            rec_files_list, copy_dir=header_path)
        if reconfig_header:
            self.header = Header(reconfig_header)
        else:
            self.header = Header(header_file)
        self.data_scanner = DataScanner(
            self.preprocessing_path, animal_name, nwb_metadata)
        self.dataset_names = self.data_scanner.get_all_epochs(date)
        full_data_path = os.path.join(self.preprocessing_path,
                                      self.animal_name, 'preprocessing', date)

        validation_registrator = ValidationRegistrator()
        validation_registrator.register(NTrodeValidator(
            self.metadata, self.header, self.probes))
        validation_registrator.register(PreprocessingValidator(
            full_data_path,
            self.dataset_names,
            data_types_for_scanning
        ))
        validation_registrator.register(TaskValidator(self.metadata['tasks']))
        validation_registrator.validate()

        self.__extract_datasets(animal_name, date)

        self.corrupted_data_manager = CorruptedDataManager(self.metadata)

        self.shanks_electrode_originator = ShanksElectrodeOriginator(
            self.probes, self.metadata)
        self.shanks_originator = ShanksOriginator(self.probes, self.metadata)

        self.fl_probe_manager = FlProbeManager(self.probes)
        self.device_injector = DeviceInjector()
        self.device_factory = DeviceFactory()

        self.electrode_group_originator = ElectrodeGroupOriginator(
            self.metadata)
        self.electrodes_originator = ElectrodesOriginator(
            self.probes, self.metadata)

        if self.is_old_dataset:
            if not session_start_time:
                raise ValueError(
                    'session_start_time is required for old dataset.')
            self.session_start_time = session_start_time
        else:
            session_time_extractor = SessionTimeExtractor(
                self.datasets,
                self.animal_name,
                self.date,
                self.dataset_names
            )
            self.session_start_time = session_time_extractor.get_session_start_time()

        self.mda_valid_time_originator = MdaValidTimeOriginator(
            self.header, self.metadata)
        self.mda_invalid_time_originator = MdaInvalidTimeOriginator(
            self.header, self.metadata)
        self.pos_valid_time_originator = PosValidTimeOriginator(self.metadata)
        self.pos_invalid_time_originator = PosInvalidTimeOriginator(
            self.metadata)

        self.epochs_originator = EpochsOriginator(self.datasets)

        if 'associated_files' in self.metadata:
            self.associated_files_originator = AssociatedFilesOriginator(
                self.metadata)

        self.electrodes_extension_originator = ElectrodesExtensionOriginator(
            self.probes,
            self.metadata,
            self.header
        )

        self.sample_count_timestamp_corespondence_originator =\
            SampleCountTimestampCorespondenceOriginator(self.datasets)
        self.processing_module_originator = ProcessingModuleOriginator()
        self.task_originator = TaskOriginator(self.metadata)
        self.camera_device_originator = CameraDeviceOriginator(self.metadata)
        self.header_device_originator = HeaderDeviceOriginator(
            self.header, self.metadata)
        self.probes_originator = ProbeOriginator(
            self.device_factory, self.device_injector, self.probes)
        self.camera_sample_frame_counts_originator = CameraSampleFrameCountsOriginator(
            os.path.join(self.data_path, self.animal_name, 'raw', self.date))
        if self.is_old_dataset:
            self.video_files_originator = VideoFilesOriginator(
                os.path.join(self.data_path, self.animal_name,
                             'raw', self.date),
                self.video_path,
                self.metadata["associated_video_files"],
                convert_timestamps=_CONVERT_OLD_TIMESTAMPS,
                return_timestamps=_RETURN_OLD_TIMESTAMPS,
            )
        else:
            self.video_files_originator = VideoFilesOriginator(
                os.path.join(self.data_path, self.animal_name,
                             'raw', self.date),
                self.video_path,
                self.metadata["associated_video_files"],
            )

        self.data_acq_device_originator = DataAcqDeviceOriginator(
            device_factory=self.device_factory,
            device_injector=self.device_injector,
            metadata=self.metadata['data_acq_device']
        )

        if self.process_mda:
            self.mda_originator = MdaOriginator(
                self.datasets, self.header, self.metadata)

        if self.process_dio:
            if self.is_old_dataset:
                self.dio_originator = DioOriginator(
                    self.metadata, self.datasets,
                    convert_timestamps=_CONVERT_OLD_TIMESTAMPS)
            else:
                self.dio_originator = DioOriginator(
                    self.metadata, self.datasets)

        if self.process_analog:
            if self.is_old_dataset:
                self.analog_originator = AnalogOriginator(
                    self.datasets, self.metadata,
                    convert_timestamps=_CONVERT_OLD_TIMESTAMPS,
                    return_timestamps=_RETURN_OLD_TIMESTAMPS)
            else:
                self.analog_originator = AnalogOriginator(
                    self.datasets, self.metadata)

        self.position_originator = PositionOriginator(
            self.datasets, self.metadata,
            self.dataset_names)