NeurodataWithoutBorders / matnwb

A Matlab interface for reading and writing NWB files
BSD 2-Clause "Simplified" License
49 stars 32 forks source link

Error epoching data #265

Closed owoolnough closed 3 years ago

owoolnough commented 3 years ago

@bendichter I'm updating my code from NWB 2.0b to 2.2.5. Having an issue using util.loadTrialAlignedTimeSeriesData to pull out epoched data. Data file was generated using 2.2.5. My data import code that previously worked for 2.0b is below. trial_conditions = containers.Map({'correct','good','articulation'},{1 1 0}); [trial_data, tt] = util.loadTrialAlignedTimeSeriesData(nwb2,timeseries, window+[-0.5 0.5], trial_conditions);

Getting the following error: Error using containers.Map/subsref Only '()' indexing is supported by a containers.Map.

Error in types.untyped.Set/get (line 165) o{i} = obj.map(name{i});

Error in util.loadTrialAlignedTimeSeriesData (line 44) times = trials.vectordata.get(align_to);

Error in blrk2NWB (line 212) [trial_data, tt] = util.loadTrialAlignedTimeSeriesData(nwb2,timeseries, window+[-0.5 0.5], trial_conditions);

bendichter commented 3 years ago

@owoolnough would you be able to provide an example file? I can provide a Google Drive folder or Globus Endpoint if that would be easier for you

owoolnough commented 3 years ago

@bendichter Sent you a link over Slack

bendichter commented 3 years ago

@owoolnough I found two issues:

  1. You need to adjust the way you call the function. It should be: [trial_data, tt] = util.loadTrialAlignedTimeSeriesData(nwb, ts, [-0.5 0.5], 'start_time', trial_conditions);

  2. One of the columns, correct, is dimensions ntrials x 2, but it should be ntrials x 1.

Once you fix those issues it should work with no alterations to matnwb. Can you adjust those two things and let me know if it works?

owoolnough commented 3 years ago

That works! Thank you