Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant use NdxEventsNWBFile with normal NWBFile functions #22

Open
Lathomas42 opened this issue Jan 7, 2025 · 1 comment
Open

Cant use NdxEventsNWBFile with normal NWBFile functions #22

Lathomas42 opened this issue Jan 7, 2025 · 1 comment

Comments

@Lathomas42
Copy link

nwbfile.units.get_ancestor(data_type='NWBFile') returns None, so functions like "nwbfile.add_unit" fails when using a NdxEventsNWBFile

to reproduce, just try to add a unit after running the write_ttls_events.py script:
nwbfile.add_unit(spike_times=[0,1])

Let me know if I can provide any other information. Id love to use the events table, but cannot if it means I cannot use the rest of the nwb functions. Let me know if there is a workaround or somethign I am doing wrong.

@Lathomas42 Lathomas42 reopened this Jan 7, 2025
@Lathomas42
Copy link
Author

Sorry, found the specifics of what causes this issue.

Trying to add a unit with an electrode associated with it. Here is a minimum code to recreate the issue:

from datetime import datetime
from pynwb import NWBHDF5IO

from ndx_events import (
    EventsTable,
    CategoricalVectorData,
    MeaningsTable,
    NdxEventsNWBFile,
)

nwbfile = NdxEventsNWBFile(
    session_description="session description",
    identifier="cool_experiment_001",
    session_start_time=datetime.now().astimezone(),
)
electrode_group = nwbfile.create_electrode_group(
                name='test_group',
                description="test",
                location='unknown',
                device=nwbfile.create_device(name='test_device'))


nwbfile.add_electrode(
        id = 0,
        group=electrode_group,
        location="brain area"
    )

nwbfile.add_unit(spike_times=[0,1],electrodes=[0])

The error is then:

AttributeError: 'NoneType' object has no attribute 'electrodes'

and it results from the fact that

nwbfile.units.get_ancestor(data_type='NWBFile') is None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant