Skip to content

Commit

Permalink
initial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Nov 22, 2024
1 parent 60c5e2a commit 9e53812
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import h5py
import numcodecs
import numpy as np
import pynwb
import zarr
from hdmf import Container
from hdmf.utils import get_data_shape
Expand Down Expand Up @@ -258,9 +259,24 @@ def from_neurodata_object(cls, neurodata_object: Container, dataset_name: Litera
and `timestamps`, each of which can be configured separately.
"""
location_in_file = _find_location_in_memory_nwbfile(neurodata_object=neurodata_object, field_name=dataset_name)

candidate_dataset = getattr(neurodata_object, dataset_name)
full_shape = get_data_shape(data=candidate_dataset)

manager = pynwb.get_manager()
namespace_catalog = manager.type_map.namespace_catalog
for namespace in namespace_catalog.namespaces:
try:
spec = namespace_catalog.get_spec(namespace, neurodata_object.parent.neurodata_type)
break
except ValueError:
continue
spec = spec.get_dataset(neurodata_object.name)
spec = spec if spec is not None else {}
dtype = spec.get("dtype", None)
if isinstance(dtype, list): # compound dtype
full_shape = (len(candidate_dataset),)
else:
full_shape = get_data_shape(data=candidate_dataset)

dtype = _infer_dtype(dataset=candidate_dataset)

if isinstance(candidate_dataset, GenericDataChunkIterator):
Expand Down Expand Up @@ -312,3 +328,10 @@ def from_neurodata_object(cls, neurodata_object: Container, dataset_name: Litera
buffer_shape=buffer_shape,
compression_method=compression_method,
)


def get_spec(namespace_catalog, namespace, neurodata_type, default=None):
try:
return namespace_catalog.get_spec(namespace, neurodata_type)
except ValueError:
return default

0 comments on commit 9e53812

Please sign in to comment.