def test_sweep_table():
    nwb_interpreter = NWBModelInterpreter(os.path.join(HERE, 'nwb_files', 'pynwb_test_files', 'test_SweepTable.nwb'))

    geppetto_model = nwb_interpreter.create_model()
    import_main_type(geppetto_model, nwb_interpreter)

    var = pointer_utility.find_variable_from_path(geppetto_model, 'nwbfile.sweep_table')

    assert type(var.types[0]) == CompositeType

    var = pointer_utility.find_variable_from_path(geppetto_model, 'nwbfile.sweep_table.colnames')

    assert type(var.types[0]) == SimpleArrayType
    colnames = var.initialValues[0].value
    assert type(colnames) == StringArray
    assert len(colnames.elements) == 2

    var = pointer_utility.find_variable_from_path(geppetto_model, 'nwbfile.sweep_table.columns')

    assert type(var.types[0]) == CompositeType

    variables = var.types[0].variables
    assert len(variables) == 3
    assert variables[1].name == colnames.elements[0]
    assert variables[2].name == colnames.elements[1]

    references_time_series = variables[1].initialValues[0].value.elements

    assert len(references_time_series) == 1
    assert type(references_time_series[0]) == Pointer
    assert references_time_series[0].path == 'nwbfile.acquisition.pcs'
def test_importValue(nwbfile):
    nwb_interpreter = NWBModelInterpreter(nwbfile)
    # Create the model
    model = nwb_interpreter.create_model()

    import_main_type(model, nwb_interpreter)
    # Call import value
    var_to_import = pointer_utility.find_variable_from_path(model, 'nwbfile.acquisition.t1.data')
    value = var_to_import.initialValues[0].value
    assert type(value), ImportValue
    value = nwb_interpreter.importValue(value)

    #Test
    from pygeppetto.model.values import TimeSeries
    assert type(value) == TimeSeries
    assert len(value.value) == 100
    assert value.value[0] == 0.0

    var_to_import = pointer_utility.find_variable_from_path(model, 'nwbfile.acquisition.t1.timestamps')
    value = var_to_import.initialValues[0].value
    assert type(value), ImportValue
    value = nwb_interpreter.importValue(value)
    assert type(value) == TimeSeries
    assert len(value.value) == 100
    assert value.value[0] == 0.0
    assert value.value[1] == 1.0

    var_to_import = pointer_utility.find_variable_from_path(model, 'nwbfile.acquisition.t2.timestamps')
    value = var_to_import.initialValues[0].value
    assert type(value), ImportValue
    value = nwb_interpreter.importValue(value)
    assert type(value) == TimeSeries
    assert len(value.value) == 100
    assert value.value[0] == 0.0
    assert value.value[1] == 1.0
Beispiel #3
0
def test_importType(nwbfile):
    nwb_interpreter = NWBModelInterpreter(nwbfile)
    geppetto_model = nwb_interpreter.create_model()

    assert len(geppetto_model.variables) == 1
    variable_type = geppetto_model.variables[0].types[0]
    assert variable_type.eContainer() == nwb_interpreter.library

    typename = 'typename'
    geppetto_model_access = GeppettoModelAccess(geppetto_model)
    imported_type = nwb_interpreter.importType('DUMMY', typename,
                                               variable_type.eContainer(),
                                               geppetto_model_access)
    var_names = [var.name for var in imported_type.variables]
    assert imported_type.id
    assert imported_type.name
    assert 'acquisition' in var_names
    assert 'stimulus' in var_names

    assert len(imported_type.variables[0].types) == 1

    geppetto_model_access.swap_type(variable_type, imported_type)

    var = pointer_utility.find_variable_from_path(geppetto_model,
                                                  'nwbfile.acquisition')
    variable_type = var.types[0]
    assert len(variable_type.variables) == 4
    assert isinstance(variable_type, CompositeType)
    assert var.name == 'acquisition'
    assert variable_type.name == 'LabelledDict'

    var = pointer_utility.find_variable_from_path(geppetto_model,
                                                  'nwbfile.acquisition.t1')
    variable_type = var.types[0]
    assert isinstance(variable_type, CompositeType)
    assert var.name == 't1'
    assert variable_type.name == 'TimeSeries'

    var = pointer_utility.find_variable_from_path(
        geppetto_model, 'nwbfile.acquisition.t1.data')
    variable_type = var.types[0]
    assert isinstance(variable_type, StateVariableType)
    assert var.id == 'data'