Error opening nwb files

Hi,

I'm new to NWB format and had problems with reading NWB data (schema version 2.2.5) in Brainstorm (Version: 21-Jun-2022). The issue is that some NWB data don't have the 'group_name' key that is required by Brainstorm.
I temporarily solved the issue by editing the code in Brainstorm but I feel it's dirty and there must be better solutions, so I recorded it here.

Here is what happened:

  1. Initially I used MATLAB 2017b and encountered the error below:

** Error: Line 34: max
** Invalid option. Option must be 'omitnan' or 'includenan'.
**
** Call stack:
** >correctType.m at 34
** >checkDtype.m at 111
** >DynamicTableRegion.m>DynamicTableRegion.validate_data at 34
** >Data.m>Data.set.data at 29
** >Data.m>Data.Data at 22
** >VectorData.m>VectorData.VectorData at 13
** >DynamicTableRegion.m>DynamicTableRegion.DynamicTableRegion at 13
** >parseDataset.m at 72
** >parseGroup.m at 22
** >parseGroup.m at 38
** >parseGroup.m at 38
** >nwbRead.m at 59
** >in_fopen_nwb.m at 49
** >in_fopen.m at 171
** >import_raw.m at 127
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@import_raw,,,iSubject) at 660

  1. It seems to require a newer version of max(). So I changed to R2019b and the error above disappeared, but it threw another error:

** Error: Line 165: containers.Map/subsref
** The specified key is not present in this container.
**
** Call stack:
** >Set.m>Set.get at 165
** >in_fopen_nwb.m>getDeeperModule at 244
** >in_fopen_nwb.m at 90
** >in_fopen.m at 171
** >import_raw.m at 127
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@import_raw,,,iSubject) at 660

  1. According to in_fopen_nwb.m>getDeeperModule at 244, there might be something wrong with this sentence not_ordered_groupLabels = nwb.(electrodes_path).vectordata.get('group_name').data.load;. So I checked the data using nwbRead() and didn't find a key named group_name.
    Here is the output of nwb.(electrodes_path).vectordata:

14×1 Set array with properties:

        HCP: [types.hdmf_common.VectorData]
  filtering: [types.hdmf_common.VectorData]
       good: [types.hdmf_common.VectorData]
      group: [types.hdmf_common.VectorData]
       hemi: [types.hdmf_common.VectorData]
        imp: [types.hdmf_common.VectorData]
      label: [types.hdmf_common.VectorData]
   location: [types.hdmf_common.VectorData]
  pial_dist: [types.hdmf_common.VectorData]
     vertex: [types.hdmf_common.VectorData]
          x: [types.hdmf_common.VectorData]
          y: [types.hdmf_common.VectorData]
          z: [types.hdmf_common.VectorData]
       zone: [types.hdmf_common.VectorData]
  1. So I had to extract the names of electrode groups (i.e., group_name) by modifying the code as:

not_ordered_groupLabels = {nwb.(electrodes_path).vectordata.get('group').data.path};
[~, not_ordered_groupLabels] = cellfun(@(x) fileparts(x), not_ordered_groupLabels', 'UniformOutput', 0);

and finally I can read the data. I'm not sure if it's just an issue about labeling or the data was badly formatted (I obtained the data from an open database). As mentioned by mpompolas, the key names in NWB could be arbitrary.

Thanks,
Shuai