holographic stimulation #32
-
I'd like to add holographic optogenetic stimulation. They key difference with this method is that stimulation can be applied to a very small spatial area, and is often used to stimulate a specific neuron (ophys ROI). I want to associate stimulus sites with an ROI in the from pynwb.ogen import OptogeneticStimulusSite
from pynwb.device import Device
from pynwb.ophys import PlaneSegmentation, ImagingPlane, OpticalChannel
import numpy as np
from pynwb import NWBHDF5IO, NWBFile
from datetime import datetime
nwbfile = NWBFile("aa", "aa", datetime.now())
device = nwbfile.create_device("my_device")
optical_channel = OpticalChannel(
name="optical_channel",
description="description",
emission_lambda=500.,
)
imaging_plane = nwbfile.create_imaging_plane(
name="name",
optical_channel=optical_channel,
description="description",
device=device,
excitation_lambda=500.,
indicator="GFP",
location="M1"
)
ogen_stim_site = nwbfile.create_ogen_site(
"my_stim_site",
device=device,
description="my desc",
excitation_lambda=500.,
location="M1",
)
plane_seg = PlaneSegmentation(description="desc", imaging_plane=imaging_plane)
plane_seg.add_column("ogen_stim_site", "link to optogenetic stimulation site")
plane_seg.add_row(ogen_stim_site=ogen_stim_site)
ophys = nwbfile.create_processing_module("ophys", "ophys")
ophys.add(plane_seg)
with NWBHDF5IO("test_ogen.nwb", "w") as io:
io.write(plane_seg) ---------------------------------------------------------------------------
ReferenceTargetNotBuiltError Traceback (most recent call last)
/var/folders/cg/mhhypnc14wn9kz5ydllymyc00000gp/T/ipykernel_20605/2585812746.py in <module>
44
45 with NWBHDF5IO("test_ogen.nwb", "w") as io:
---> 46 io.write(plane_seg)
~/dev/hdmf/src/hdmf/utils.py in func_call(*args, **kwargs)
591 def func_call(*args, **kwargs):
592 pargs = _check_args(args, kwargs)
--> 593 return func(args[0], **pargs)
594 else:
595 def func_call(*args, **kwargs):
~/dev/hdmf/src/hdmf/backends/hdf5/h5tools.py in write(self, **kwargs)
356
357 cache_spec = popargs('cache_spec', kwargs)
--> 358 call_docval_func(super().write, kwargs)
359 if cache_spec:
360 self.__cache_spec()
~/dev/hdmf/src/hdmf/utils.py in call_docval_func(func, kwargs)
432 def call_docval_func(func, kwargs):
433 fargs, fkwargs = fmt_docval_args(func, kwargs)
--> 434 return func(*fargs, **fkwargs)
435
436
~/dev/hdmf/src/hdmf/utils.py in func_call(*args, **kwargs)
591 def func_call(*args, **kwargs):
592 pargs = _check_args(args, kwargs)
--> 593 return func(args[0], **pargs)
594 else:
595 def func_call(*args, **kwargs):
~/dev/hdmf/src/hdmf/backends/io.py in write(self, **kwargs)
48 """Write a container to the IO source."""
49 container = popargs('container', kwargs)
---> 50 f_builder = self.__manager.build(container, source=self.__source, root=True)
51 self.write_builder(f_builder, **kwargs)
52
~/dev/hdmf/src/hdmf/utils.py in func_call(*args, **kwargs)
591 def func_call(*args, **kwargs):
592 pargs = _check_args(args, kwargs)
--> 593 return func(args[0], **pargs)
594 else:
595 def func_call(*args, **kwargs):
~/dev/hdmf/src/hdmf/build/manager.py in build(self, **kwargs)
186 container.__class__.__name__, container.name))
187 if root: # create reference builders only after building all other builders
--> 188 self.__add_refs()
189 self.__active_builders.clear() # reset active builders now that build process has completed
190 return result
~/dev/hdmf/src/hdmf/build/manager.py in __add_refs(self)
231 self.logger.debug("Adding ReferenceBuilder with call id %d from queue (length %d)"
232 % (id(call), len(self.__ref_queue)))
--> 233 call()
234
235 def queue_ref(self, func):
~/dev/hdmf/src/hdmf/build/objectmapper.py in _filler()
841 bldr_data.append(None)
842 else:
--> 843 target_builder = self.__get_target_builder(d, build_manager, builder)
844 bldr_data.append(ReferenceBuilder(target_builder))
845 builder.data = bldr_data
~/dev/hdmf/src/hdmf/build/objectmapper.py in __get_target_builder(self, container, build_manager, builder)
885 target_builder = build_manager.get_builder(container)
886 if target_builder is None:
--> 887 raise ReferenceTargetNotBuiltError(builder, container)
888 return target_builder
889
ReferenceTargetNotBuiltError: ogen_stim_site (name/ogen_stim_site): Could not find already-built Builder for OptogeneticStimulusSite 'my_stim_site' in BuildManager @rly do you think this is a good approach? Do you know how we might fix this so that it works? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think that approach is fine. If this is a common new type of data, it might be nice to create an extension so that the format becomes more standardized.
should be
to make it work. |
Beta Was this translation helpful? Give feedback.
I think that approach is fine. If this is a common new type of data, it might be nice to create an extension so that the format becomes more standardized.
should be
to make it work.