Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: general_extracellular_ephys_electrodes isn't been exported into the nwb file #566

Open
2 tasks done
amadaabrego opened this issue Mar 22, 2024 · 9 comments
Open
2 tasks done
Labels
category: file issue issue with reading or writing nwb file status: need verification potentially solved, but needs verification

Comments

@amadaabrego
Copy link

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.
image

However, once I export it, and read it again general_extracellular_ephys_electrodes is empty
image

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
image

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

@ehennestad
Copy link
Collaborator

Try to add it without doing the toTable(). Does that work?

@amadaabrego
Copy link
Author

amadaabrego commented Mar 22, 2024

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

@rly
Copy link
Contributor

rly commented Mar 28, 2024

@lawrence-mbf could you look into this?

@lawrence-mbf
Copy link
Collaborator

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?

@amadaabrego
Copy link
Author

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!

@lawrence-mbf
Copy link
Collaborator

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.

@amadaabrego
Copy link
Author

amadaabrego commented Apr 1, 2024 via email

@lawrence-mbf
Copy link
Collaborator

lawrence-mbf commented Apr 1, 2024

Gotcha, I guess there are two things that may have problems here:

  1. A file meant for amending should be validated as a real NWB file.
  2. 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.

@ehennestad ehennestad added category: file issue issue with reading or writing nwb file status: need verification potentially solved, but needs verification labels Oct 31, 2024
@ehennestad
Copy link
Collaborator

@amadaabrego Are you still experiencing problems related to this issue that we should look into, or is it ok to close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: file issue issue with reading or writing nwb file status: need verification potentially solved, but needs verification
Projects
None yet
Development

No branches or pull requests

4 participants