Replies: 2 comments 1 reply
-
|
Here's steps to change values in the electrode table without re-writing the whole file:
from pynwb import NWBHDF5IO
file_path = "/stelmo/sam/dummy.nwb"
# load the current electrodes dataframe
with NWBHDF5IO(file_path,"r") as io:
nwb = io.read()
electrodes_df = nwb.electrodes.to_dataframe()
current_bad_channels = electrodes_df.bad_channel.values
# make an array with the needed changes to the dataframe column
new_bad_channels = current_bad_channels.copy()
new_bad_channels[11] = True
import h5py
# change the values in the file to the new values
with h5py.File(file_path, "a") as file:
print(file["general"]["extracellular_ephys"]["electrodes"]["bad_channel"][:])
file["general"]["extracellular_ephys"]["electrodes"]["bad_channel"][:] = new_bad_channels
# confirm the change
with NWBHDF5IO(file_path,"r") as io:
nwb = io.read()
assert (nwb.electrodes.to_dataframe().bad_channel.values == new_bad_channels).all() |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Awesome, thanks @samuelbray32 ! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! As I mentioned earlier, I'm trying to update some values in the
electrodespart of many of our nwbs, specifically thebad_channelvalues, based on newly-updated yaml files. How would you recommend going about updating those before re-inserting them into spyglass? Thanks!Beta Was this translation helpful? Give feedback.
All reactions