Closed bendichter closed 6 years ago
date = datetime(2018, 3, 1, 12, 0, 0); nwb = nwbfile( 'source', 'acquired on rig2', ... 'session_description', 'a test NWB File', ... 'identifier', 'mouse004_day4', ... 'session_start_time', datestr(date, 'yyyy-mm-ddTHH:MM:SS'), ... 'file_create_date', datestr(now, 'yyyy-mm-ddTHH:MM:SS')); device_labels = {'a','a','a','a','a','b','b','b','b','b'}; udevice_labels = unique(device_labels, 'stable'); variables = {'id', 'x', 'y', 'z', 'imp', 'location', 'filtering', ... 'description', 'group', 'group_name'}; for i_device = 1:length(udevice_labels) device_label = udevice_labels{i_device}; nwb.general_devices.set(device_label,... types.core.Device('source', 'lab notebook')); nwb.general_extracellular_ephys.set(device_label,... types.core.ElectrodeGroup('source', 'my source', ... 'description', 'a test ElectrodeGroup', ... 'location', 'unknown', ... 'device', types.untyped.SoftLink(['/general/devices/' device_label]))); ov = types.untyped.ObjectView(['/general/extracellular_ephys/' device_label]); elec_nums = find(strcmp(device_labels, device_label)); for i_elec = 1:length(elec_nums) elec_num = elec_nums(i_elec); if i_device == 1 && i_elec == 1 tbl = table(int64(1), NaN, NaN, NaN, NaN, {'CA1'}, {'filtering'}, ... {'electrode label'}, ov, {'electrode_group'},... 'VariableNames', variables); else tbl = [tbl; {int64(elec_num), NaN, NaN, NaN, NaN,... 'CA1', 'filtering', 'another label', ov, 'electrode_group'}]; end end end et = types.core.ElectrodeTable('data', tbl); nwb.general_extracellular_ephys.set('electrodes', et); rv = types.untyped.RegionView('/general/extracellular_ephys/electrodes',... {[1 height(tbl)]}); electrode_table_region = types.core.ElectrodeTableRegion('data', rv); electrical_series = types.core.ElectricalSeries(... 'source', 'my source', ... 'starting_time', 0.0, ... % seconds 'starting_time_rate', 200., ... % Hz 'data',randn(1000, 10),... 'electrodes', electrode_table_region,... 'data_unit','V'); nwb.acquisition.set('ECoG', electrical_series); nwbExport(nwb, 'ecephys_tutorial.nwb')
Error using nwbfile/export (line 46) Could not resolve paths for the following reference(s): /acquisition/ECoG/electrodes Error in nwbExport (line 34) export(nwb(i), fn);
The quick fix is to make region references vertical array of bounds a la:
rv = types.untyped.RegionView('/general/extracellular_ephys/electrodes',... {[1; height(tbl)]});
Fix is forthcoming.