matnwb
matnwb copied to clipboard
[Bug]: general_extracellular_ephys_electrodes isn't been exported into the nwb file
What happened?
Hello!
I'm working into exporting an intan file to a nwb format - I am customizing the labels, and therefore not using Intan's written code.
I followed the instructions in the tutorial to create a ElectrodesDynamicTable, that will be the general_extracellular_ephys_electrodes. This is how the nwb file organization looks like BEFORE exporting.
However, once I export it, and read it again general_extracellular_ephys_electrodes is empty
I have double, triple checked that the formats in the ElectrodesDynamicTable fits whatever is in the tutorial, but still doesn't work. This is how the ElectrodesDynamicTable looks like
Steps to Reproduce
This is how I define the ElectrodesDynamicTable
% Create 'electrode_table_region' object.
ElectrodesDynamicTable = types.hdmf_common.DynamicTable(...
'colnames', {'x','y','z', 'impedance','location', 'filtering',...
'group', 'group_name', 'label'}, ...
'description', 'all electrodes');
% Based on the labels in the file, extract the device type
Label_Devices=extractBefore(label,'-');
unique_devices=string(unique(Label_Devices,'stable'));
electrode_number=1;
% For each type of DEVICE, add it to the nwb file
for i=1:length(unique_devices)
device_type=string(unique_devices(i));
switch device_type
case 'ECoG'
manufacturer='unknown';
case 'sEEG'
manufacturer = 'PMT';
case 'DISC'
manufacturer = 'Seymour Lab/TBBL';
case ''
manufacturer='unknown';
end
Device = types.core.Device(...
'description', char(device_type), ...
'manufacturer', manufacturer ...
);
% Adds the device under general_devices
nwb.general_devices.set(device_type, Device);
% Create an Electrode group, and add it to the nwb file
EGroup = types.core.ElectrodeGroup( ...
'description', sprintf('electrode group for %s', device_type), ...
'location', 'unknown', ...
'device', types.untyped.SoftLink(Device) ...
);
nwb.general_extracellular_ephys.set(device_type, EGroup);
% For each electrode that matches that device type, add the device
% information
continue_loop_flag=1;
while continue_loop_flag==1
if electrode_number<=length(Label_Devices) && string(Label_Devices(electrode_number))==device_type
if string(Label_Devices(electrode_number))==device_type
ElectrodesDynamicTable.addRow( ...
'x', x_coord(electrode_number),...
'y', y_coord(electrode_number),...
'z', z_coord(electrode_number),...
'impedance', impedances(electrode_number),...
'location', 'unknown', ...
'filtering', char(filtering(electrode_number,:)),...
'group', types.untyped.ObjectView(EGroup), ...
'group_name', char(device_type), ...
'label', char(label(electrode_number)));
electrode_number=electrode_number+1;
else
break
end
else
continue_loop_flag=0;
end
end
end
ElectrodesDynamicTable.toTable()
nwb.general_extracellular_ephys_electrodes = ElectrodesDynamicTable;
Error Message
No response
Operating System
macOS
Matlab Version
Matlab_2023b
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] Have you ensured this bug was not already reported?
Try to add it without doing the toTable(). Does that work?
Try to add it without doing the toTable(). Does that work?
@ehennestad It doesn't. I added it to be able to visualize the data
@lawrence-mbf could you look into this?
Hi @amadaabrego are there any errors when you export the file? I don't have the "labels" variable in your script so I attempted to recreate using an empty DynamicTable which, after setting the id and the vectorindex, appeared to work without issues.
Can you also use HDFView to search if the /general/extracellular_ephys/electrodes directory is present?
Hey everyone, I tried the HDFView, and it did show it. I ended up deleting the nwb file, and doing the export again. It fixed the problem.
Thanks!
Very odd, were there any errors the first time exporting? MatNWB will attempt to amend a file if the filename is the same so there may be a bug there.
Yes! I had a lot of errors the first time I tried to export it. I was inputting strings and not chars. It took me a while to realize that nwb only accepts text if they are char. I assumed that it would overwrite the file instead of trying to amend it. Good to know nowThank you so much for everything! On Apr 1, 2024, at 3:49 PM, Lawrence @.***> wrote: Very odd, were there any errors the first time exporting? MatNWB will attempt to amend a file if the filename is the same so there may be a bug there.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
Gotcha, I guess there are two things that may have problems here:
- A file meant for amending should be validated as a real NWB file.
- strings should be supported.
When MatNWB was first written, string types were still considered new so few people actually used it. It should not be too bad to support strings, though, since they should be better mapped to the HDF5 type.