Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Apr 25, 2024
1 parent 5ac7321 commit b24d47d
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 13 deletions.
29 changes: 26 additions & 3 deletions src/pynwb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
import os.path
from pathlib import Path
from copy import deepcopy
from copy import deepcopy, copy
import h5py

from hdmf.spec import NamespaceCatalog
Expand Down Expand Up @@ -46,11 +46,34 @@ def _get_resources():

__NS_CATALOG = NamespaceCatalog(NWBGroupSpec, NWBDatasetSpec, NWBNamespace)

class NWBTypeMap(TypeMap):
def __init__(self, **kwargs):
super().__init__(**kwargs)

def __copy__(self):
ret = NWBTypeMap(namespaces=copy(self._TypeMap__ns_catalog),
mapper_cls=self._TypeMap__default_mapper_cls,
type_config=self.type_config)
ret.merge(self)
return ret

def modify_builder(self, builder):
try:
ndtype = builder['neurodata_type']
except KeyError:
ndtype = 'Not Group'
# remap ElectrodesTable from a DynamicTable named electrodes
if ndtype == 'DynamicTable' and builder.name == 'electrodes':
builder.set_attribute(name='namespace', value='core')
builder.set_attribute(name='neurodata_type', value='ElectrodesTable')
return builder
else:
return None

hdmf_typemap = hdmf.common.get_type_map()
__TYPE_MAP = TypeMap(__NS_CATALOG)
__TYPE_MAP = NWBTypeMap(namespaces=__NS_CATALOG)
__TYPE_MAP.merge(hdmf_typemap, ns_catalog=True)


@docval({'name': 'extensions', 'type': (str, TypeMap, list),
'doc': 'a path to a namespace, a TypeMap, or a list consisting of paths to namespaces and TypeMaps',
'default': None},
Expand Down
2 changes: 1 addition & 1 deletion src/pynwb/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def add_invalid_time_interval(self, **kwargs):
self.__check_invalid_times()
self.invalid_times.add_interval(**kwargs)

@docval({'name': 'electrode_table', 'type': DynamicTable, 'doc': 'the ElectrodesTable for this file'})
@docval({'name': 'electrode_table', 'type': ElectrodesTable, 'doc': 'the ElectrodesTable for this file'})
def set_electrode_table(self, **kwargs):
"""
Set the electrode table of this NWBFile to an existing ElectrodesTable
Expand Down
4 changes: 2 additions & 2 deletions src/pynwb/testing/mock/ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from hdmf.common.table import DynamicTableRegion, DynamicTable

from ...device import Device
from ...file import ElectrodeTable, NWBFile
from ...ecephys import ElectricalSeries, ElectrodeGroup, SpikeEventSeries
from ...file import NWBFile
from ...ecephys import ElectricalSeries, ElectrodeGroup, SpikeEventSeries, ElectrodesTable
from .device import mock_Device
from .utils import name_generator
from ...misc import Units
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/hdf5/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
FeatureExtraction,
)
from pynwb.device import Device
from pynwb.file import ElectrodeTable as get_electrode_table
from pynwb.ecephys import ElectrodesTable as get_electrode_table
from pynwb.testing import NWBH5IOMixin, AcquisitionH5IOMixin, NWBH5IOFlexMixin, TestCase


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/hdf5/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pynwb.testing import NWBH5IOMixin, AcquisitionH5IOMixin, TestCase
from pynwb.ecephys import ElectrodeGroup
from pynwb.device import Device
from pynwb.file import ElectrodeTable as get_electrode_table
from pynwb.ecephys import ElectrodesTable as get_electrode_table


class TestUnitsIO(AcquisitionH5IOMixin, TestCase):
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/foo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
# breakpoint()
# with NWBHDF5IO("ecephys_tutorial.nwb", "w") as io:
# io.write(nwbfile)
# new='/Users/mavaylon/Research/NWB/pynwb/ecephys_tutorial.nwb'
io= NWBHDF5IO("/Users/mavaylon/Research/NWB/pynwb/tests/back_compat/2.6.0_DynamicTableElectrodes.nwb", "r")
# io= NWBHDF5IO(new, 'r')
read_nwbfile = io.read()

breakpoint()
2 changes: 1 addition & 1 deletion tests/unit/test_ecephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
FilteredEphys,
FeatureExtraction,
ElectrodeGroup,
ElectrodesTable
)
from pynwb.device import Device
from pynwb.file import ElectrodeTable
from pynwb.testing import TestCase
from pynwb.testing.mock.ecephys import mock_ElectricalSeries

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from hdmf.utils import docval, get_docval, popargs
from pynwb import NWBFile, TimeSeries, NWBHDF5IO
from pynwb.base import Image, Images
from pynwb.file import Subject, ElectrodeTable, _add_missing_timezone
from pynwb.file import Subject, _add_missing_timezone
from pynwb.epoch import TimeIntervals
from pynwb.ecephys import ElectricalSeries
from pynwb.ecephys import ElectricalSeries, ElectrodesTable
from pynwb.testing import TestCase, remove_test_file


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from hdmf.common import DynamicTable, VectorData, DynamicTableRegion

from pynwb.misc import AnnotationSeries, AbstractFeatureSeries, IntervalSeries, Units, DecompositionSeries
from pynwb.file import TimeSeries, ElectrodeTable as get_electrode_table
from pynwb.file import TimeSeries
from pynwb.device import Device
from pynwb.ecephys import ElectrodeGroup
from pynwb.ecephys import ElectrodeGroup, ElectrodesTable as get_electrode_table
from pynwb.testing import TestCase


Expand Down

0 comments on commit b24d47d

Please sign in to comment.