nsteinme / steinmetz-et-al-2019

Code accompanying Steinmetz et al., 2019
GNU General Public License v3.0
55 stars 14 forks source link

Error using nwbRead function in MATLAB #3

Closed cspurandare closed 4 years ago

cspurandare commented 4 years ago

Hello, I downloaded the data set (Steinmetz2019_Forssmann and Cori) and am trying to load it in MATLAB(R2019a) using the nwbRead function from the Allen Institute website. I adjusted the nwb-schema to 2.1.0 so that it is compatible with the files. But when I run the nwbRead function I get the following error -

nwb=nwbRead('C:\Users\UCLA ASA\Downloads\Steinmetz2019_Forssmann_2017-11-05.nwb'); Error using types.util.checkDtype (line 174) Property id must be a types.core.ElementIdentifiers.

Error in types.core.DynamicTable/validate_id (line 69) val = types.util.checkDtype('id', 'types.core.ElementIdentifiers', val);

Error in types.core.DynamicTable/set.id (line 52) obj.id = obj.validate_id(val);

Error in types.core.DynamicTable (line 39) obj.id = p.Results.id;

Error in types.core.TimeIntervals (line 25) obj = obj@types.core.DynamicTable(varargin{:});

Error in io.parseGroup (line 85) parsed = eval([Type.typename '(kwargs{:})']);

Error in io.parseGroup (line 38) subg = io.parseGroup(filename, group, Blacklist);

Error in io.parseGroup (line 38) subg = io.parseGroup(filename, group, Blacklist);

Error in nwbRead (line 33) nwb = io.parseGroup(filename, h5info(filename), Blacklist);

Instead, when I use the dataToNWB files from https://github.com/SteinmetzLab/dataToNWB things seem to work ok with the hd5read function. Do you happen to have an fix for the MATLAB error above? I am imagining that it is some sort of an compatibility issue of the code which created your .nwb files and the reader I am using. Thanks in anticipation, Chinmay

nsteinme commented 4 years ago

@bendichter could you help us assess this?

bendichter commented 4 years ago

@nsteinme Looks like an issue of incompatibility between PyNWB and MatNWB. I'll take a look.

bendichter commented 4 years ago

I'm not able to reproduce this error. For me, nwbRead works as expected from the data posted on FigShare.

>> nwbRead('/Volumes/easystore5T/data/Steinmetz/Steinmetz2019_Forssmann_2017-11-05.nwb')

ans = 

  NwbFile with properties:

                                nwb_version: '2.1.0'
                                acquisition: [2×1 types.untyped.Set]
                                   analysis: [0×1 types.untyped.Set]
                           file_create_date: [1×1 types.untyped.DataStub]
                                    general: [0×1 types.untyped.Set]
                    general_data_collection: []
                            general_devices: [2×1 types.untyped.Set]
             general_experiment_description: 'Large-scale Neuropixels recordings across brain regions of mice during a head-fixed visual discrimination task. '
                       general_experimenter: [1×1 types.untyped.DataStub]
                general_extracellular_ephys: [2×1 types.untyped.Set]
     general_extracellular_ephys_electrodes: [1×1 types.hdmf_common.DynamicTable]
                        general_institution: 'University College London'
                general_intracellular_ephys: [0×1 types.untyped.Set]
      general_intracellular_ephys_filtering: []
    general_intracellular_ephys_sweep_table: []
                           general_keywords: [1×1 types.untyped.DataStub]
                                general_lab: 'The Carandini and Harris Lab'
                              general_notes: []
                       general_optogenetics: [0×1 types.untyped.Set]
                     general_optophysiology: [0×1 types.untyped.Set]
                       general_pharmacology: []
                           general_protocol: []
               general_related_publications: [1×1 types.untyped.DataStub]
                         general_session_id: []
                             general_slices: []
                      general_source_script: []
            general_source_script_file_name: []
                           general_stimulus: []
                            general_subject: [1×1 types.core.Subject]
                            general_surgery: []
                              general_virus: []
                                 identifier: 'Forssmann_2017-11-05'
                                  intervals: [1×1 types.untyped.Set]
                           intervals_epochs: []
                    intervals_invalid_times: []
                           intervals_trials: [1×1 types.core.TimeIntervals]
                                 processing: [1×1 types.untyped.Set]
                                    scratch: [0×1 types.untyped.Set]
                        session_description: 'Neuropixels recording during visual discrimination in awake mice.'
                         session_start_time: 2017-11-05T12:00:00.000000Z
                      stimulus_presentation: [6×1 types.untyped.Set]
                         stimulus_templates: [0×1 types.untyped.Set]
                  timestamps_reference_time: 2017-11-05T12:00:00.000000Z
                                      units: [1×1 types.core.Units]

@cspurandare, I'm a little confused by "from the Allen Institute website." Where did you find this function? You should use the latest version that is currently on GitHub. You can get the latest code with the following commands inside MATLAB:

!git clone https://github.com/NeurodataWithoutBorders/matnwb.git
cd matnwb
addpath(genpath(pwd));
generateCore(); % generate core namespace located in the repository.

Those commands should

  1. Get you the most up-to-date code that works on my computer
  2. Add it to your path
  3. Generate the API

If that doesn't work, make sure you don't have some other version of MatNWB somewhere else on your path.

cspurandare commented 4 years ago

Hi Ben, Thank you for your reply. I was using the function from the website - https://github.com/NeurodataWithoutBorders/matnwb I think there was some conflict with the schemas at my end, although I had installed 2.1.0 for this particular dataset, it was still reverting back to 2.2.4 which is the latest one on the aforesaid website. I did a clean wipe of my directories and re-run of GenerateCore did the trick ! I am able to create the nwb file now ! Thank you for your help, Chinmay

bendichter commented 4 years ago

@cspurandare glad to hear the issue has resolved. Feel free to reach out if more issues arise. Ben

@nsteinme, you can close this now