-
Summarized from a conversation I had with a user on Slack: User: I am working on combining different parts of our nwb files into one nwb file (e.g. data from stimulus only nwb and ophys nwb need to be combined into a single nwb). I am using lindi to do this and running into trouble opening what I think is the combined file. Can you help me debug this? I am new to using nwbs. I was trying to go off your example but my paths are local. The Ryan: Is your goal to get a combined NWB file that is an HDF5 or Zarr file? LINDI creates an NWB file in its own JSON-based format that is not totally standard or widely accepted yet User: A zarr file. The inputs are h5's but we are changing all our nwb outputs to zarr |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The overall workflow is something like:
with NWBZarrIO(zarr_filename, mode='w') as export_io:
export_io.export(src_io=read_io, write_args=dict(link_data=False)) That particular workflow of open, add, export from HDF5 to Zarr may have some rough edges. Let me know if you run into any issues! import pynwb
import hdmf_zarr
ophys_nwb_file_path = "/Users/rly/Downloads/dataset-5c19bc2b-3332-40b0-9ff3-a801f32b020b/multiplane-ophys_753906_2025-01-30_11-20-04_processed_2025-02-21_16-24-27.nwb"
beh_nwb_file_path = "/Users/rly/Downloads/dataset-cea5c998-a823-4837-8f64-8b304c313b6f/multiplane-ophys_753906_2025-01-30_11-20-04.nwb"
zarr_file_path = "/Users/rly/Downloads/ophys_beh_merged.zarr"
with pynwb.NWBHDF5IO(ophys_nwb_file_path, mode='r') as ophys_io:
ophys_nwb = ophys_io.read()
with pynwb.NWBHDF5IO(beh_nwb_file_path, mode='r') as beh_io:
beh_nwb = beh_io.read()
for v in beh_nwb.acquisition.values():
v.reset_parent()
ophys_nwb.add_acquisition(v)
for v in beh_nwb.processing.values():
v.reset_parent()
ophys_nwb.add_processing_module(v)
with hdmf_zarr.NWBZarrIO(zarr_file_path, mode='w') as export_io:
export_io.export(src_io=ophys_io, write_args=dict(link_data=False))
with hdmf_zarr.NWBZarrIO(zarr_file_path, mode='r') as io:
nwb = io.read()
print(nwb)
|
Beta Was this translation helpful? Give feedback.
The overall workflow is something like:
NWBFile
to ophysNWBFile
- like you have in your codeNWBFile
to Zarr usinghdmf_zarr.NWBZarrIO
:That particular workflow of open, add, export from HDF5 to Zarr may have some rough edges. Let me know if you run into any issues!