Esempio n. 1
0
def main(output_file, file_recording_raw, file_recording_processed, file_sorting, file_metadata):
    # Source data
    source_data = dict(
        BlackrockRaw=dict(filename=file_recording_raw),
        BlackrockProcessed=dict(filename=file_recording_processed),
        BlackrockSorting=dict(
            filename=file_sorting,
            nsx_to_load=6
        )
    )

    # Initialize converter
    converter = MovshonBlackrockNWBConverter(source_data=source_data)

    # Get metadata from source data and modify any values you want
    metadata = converter.get_metadata()
    if file_metadata:
        m = load_metadata_from_file(file_metadata)
        metadata = dict_deep_update(metadata, m)
        converter.validate_metadata(metadata)

    # Get conversion options and modify any values you want
    conversion_options = converter.get_conversion_options()

    # Run conversion
    converter.run_conversion(
        metadata=metadata, 
        nwbfile_path=output_file, 
        save_to_file=True,
        overwrite=True,
        conversion_options=conversion_options
    )
Esempio n. 2
0
def main(output_file, file_raw, file_lfp, file_expo, file_ttl, file_metadata):
    # Source data
    source_data = dict(SpikeGLXRaw=dict(file_path=str(file_raw)),
                       SpikeGLXLFP=dict(file_path=str(file_lfp)),
                       ExpoDataInterface=dict(expo_file=str(file_expo),
                                              ttl_file=str(file_ttl)))

    # Initialize converter
    converter = MovshonSpikeglxNWBConverter(source_data=source_data)

    # Get metadata from source data and modify any values you want
    metadata = converter.get_metadata()
    if file_metadata:
        m = load_metadata_from_file(file_metadata)
        metadata = dict_deep_update(metadata, m)
        converter.validate_metadata(metadata)

    # Get conversion options and modify any values you want
    conversion_options = converter.get_conversion_options()

    # Run conversion
    converter.run_conversion(metadata=metadata,
                             nwbfile_path=output_file,
                             save_to_file=True,
                             overwrite=True,
                             conversion_options=conversion_options)
Esempio n. 3
0
def main(output_file, dir_oephys, file_expo, file_ttl, file_metadata):
    # Source data
    source_data = dict(
        OpenEphysRecordingExtractorInterface=dict(folder_path=str(dir_oephys)),
        ExpoDataInterface=dict(expo_file=str(file_expo),
                               ttl_file=str(file_ttl)))

    # Initialize converter
    converter = MovshonOpenEphysNWBConverter(source_data=source_data)

    # Get metadata from source data and modify any values you want
    metadata = converter.get_metadata()
    if file_metadata:
        m = load_metadata_from_file(file_metadata)
        metadata = dict_deep_update(metadata, m)
        converter.validate_metadata(metadata)

    # Get conversion options and modify any values you want
    conversion_options = converter.get_conversion_options()

    # Run conversion
    converter.run_conversion(metadata=metadata,
                             nwbfile_path=output_file,
                             save_to_file=True,
                             overwrite=True,
                             conversion_options=conversion_options)
Esempio n. 4
0
def convert_session(session_path: FolderPathType, nwbfile_path: FilePathType):
    """Wrap converter for Parallel use."""
    print(f"Processsing {session_path}...")
    session_name = session_path.stem
    subject_name = session_path.parent.name
    dat_file_path = session_path / f"{session_name}.dat"
    eeg_file_path = session_path / f"{session_name}.eeg"

    source_data = dict(
        NeuroscopeRecording=dict(file_path=str(dat_file_path),
                                 gain=conversion_factor),
        NeuroscopeLFP=dict(file_path=str(eeg_file_path),
                           gain=conversion_factor),
        YutaVCBehavior=dict(folder_path=str(session_path)),
        PhySorting=dict(folder_path=str(session_path),
                        exclude_cluster_groups=["noise", "mua"]),
    )
    converter = YutaVCNWBConverter(source_data=source_data)
    conversion_options = dict(
        NeuroscopeRecording=dict(stub_test=stub_test,
                                 es_key="ElectricalSeries_raw"),
        NeuroscopeLFP=dict(stub_test=stub_test),
        PhySorting=dict(stub_test=stub_test),
    )
    metadata = converter.get_metadata()
    metadata["Subject"].update(genotype=subject_genotypes[subject_name])
    metadata_from_yaml = load_metadata_from_file(metadata_path)
    metadata = dict_deep_update(metadata, metadata_from_yaml)
    converter.run_conversion(nwbfile_path=str(nwbfile_path),
                             conversion_options=conversion_options,
                             metadata=metadata,
                             overwrite=True)
    sys.stdout.flush()  # Needed for verbosity in Parallel
Esempio n. 5
0
def test_load_metadata_from_file():
    m0 = dict(NWBFile=dict(
        experimenter='Mr Tester',
        identifier='abc123',
        institution='My University',
        lab='My lab',
        session_description='testing conversion tools software',
        session_start_time='2020-04-15T10:00:00+00:00'),
              Subject=dict(description='ADDME',
                           sex='M',
                           species='ADDME',
                           subject_id='sid000',
                           weight='10g',
                           date_of_birth='2020-04-07T00:15:00+00:00'),
              Ecephys=dict(Device=[dict(name='device_ecephys')],
                           ElectricalSeries=[
                               dict(description='ADDME',
                                    name='ElectricalSeries',
                                    rate=10.0,
                                    starting_time=0.0,
                                    conversion=1.0)
                           ],
                           ElectrodeGroup=[
                               dict(description='ADDME',
                                    device='device_ecephys',
                                    location='ADDME',
                                    name='ElectrodeGroup')
                           ]))

    yaml_file = os.path.join(os.path.dirname(__file__), 'metadata_tests.yml')
    json_file = os.path.join(os.path.dirname(__file__), 'metadata_tests.json')

    m1 = load_metadata_from_file(file=yaml_file)
    compare_dicts_2(m0, m1)

    m2 = load_metadata_from_file(file=json_file)
    compare_dicts_2(m0, m2)