Neurodata Without Borders Extracellular Electrophysiology Tutorial

Table of Contents

About This Tutorial

This tutorial describes storage of hypothetical data from extracellular electrophysiology experiments in NWB for the following data categories:

Before You Begin

It is recommended to first work through the Introduction to MatNWB tutorial, which demonstrates installing MatNWB and creating an NWB file with subject information, animal position, and trials, as well as writing and reading NWB files in MATLAB.
Important: The dimensions of timeseries data in MatNWB should be defined in the opposite order of how it is defined in the nwb-schemas. In NWB, time is always stored in the first dimension of the data, whereas in MatNWB time should be stored in the last dimension of the data. This is explained in more detail here: MatNWB <-> HDF5 Dimension Mapping.

Setting up the NWB File

An NWB file represents a single session of an experiment. Each file must have a session_description, identifier, and session_start_time. Create a new NWBFile object these required fields along with any additional metadata. In MatNWB, arguments are specified using MATLAB's keyword argument pair convention, where each argument name is followed by its value.
nwb = NwbFile( ...
'session_description', 'mouse in open exploration',...
'identifier', 'Mouse5_Day3', ...
'session_start_time', datetime(2018, 4, 25, 2, 30, 3, 'TimeZone', 'local'), ...
'timestamps_reference_time', datetime(2018, 4, 25, 3, 0, 45, 'TimeZone', 'local'), ...
'general_experimenter', 'Last Name, First Name', ... % optional
'general_session_id', 'session_1234', ... % optional
'general_institution', 'University of My Institution', ... % optional
'general_related_publications', {'DOI:10.1016/j.neuron.2016.12.011'}); % optional
nwb
nwb =
NwbFile with properties: nwb_version: '2.8.0' file_create_date: [] identifier: 'Mouse5_Day3' session_description: 'mouse in open exploration' session_start_time: {[2018-04-25T02:30:03.000000+02:00]} timestamps_reference_time: {[2018-04-25T03:00:45.000000+02:00]} acquisition: [0×1 types.untyped.Set] analysis: [0×1 types.untyped.Set] general: [0×1 types.untyped.Set] general_data_collection: '' general_devices: [0×1 types.untyped.Set] general_experiment_description: '' general_experimenter: 'Last Name, First Name' general_extracellular_ephys: [0×1 types.untyped.Set] general_extracellular_ephys_electrodes: [] general_institution: 'University of My Institution' general_intracellular_ephys: [0×1 types.untyped.Set] general_intracellular_ephys_experimental_conditions: [] general_intracellular_ephys_filtering: '' general_intracellular_ephys_intracellular_recordings: [] general_intracellular_ephys_repetitions: [] general_intracellular_ephys_sequential_recordings: [] general_intracellular_ephys_simultaneous_recordings: [] general_intracellular_ephys_sweep_table: [] general_keywords: '' general_lab: '' general_notes: '' general_optogenetics: [0×1 types.untyped.Set] general_optophysiology: [0×1 types.untyped.Set] general_pharmacology: '' general_protocol: '' general_related_publications: {'DOI:10.1016/j.neuron.2016.12.011'} general_session_id: 'session_1234' general_slices: '' general_source_script: '' general_source_script_file_name: '' general_stimulus: '' general_subject: [] general_surgery: '' general_virus: '' general_was_generated_by: '' intervals: [0×1 types.untyped.Set] intervals_epochs: [] intervals_invalid_times: [] intervals_trials: [] processing: [0×1 types.untyped.Set] scratch: [0×1 types.untyped.Set] stimulus_presentation: [0×1 types.untyped.Set] stimulus_templates: [0×1 types.untyped.Set] units: []

Electrode Information

In order to store extracellular electrophysiology data, you first must create an electrodes table describing the electrodes that generated this data. Extracellular electrodes are stored in an electrodes table, which is also a DynamicTable. electrodes has several required fields: x, y, z, impedance, location, filtering, and electrode_group.
The electrodes table references a required ElectrodeGroup, which is used to represent a group of electrodes. Before creating an ElectrodeGroup, you must define a Device object. The fields description, manufacturer, model_number, model_name, and serial_number are optional, but recommended.
device = types.core.Device(...
'description', 'A 12-channel array with 4 shanks and 3 channels per shank', ...
'manufacturer', 'Array Technologies', ...
'model_number', 'PRB_1_4_0480_123', ...
'model_name', 'Neurovoxels 0.99', ...
'serial_number', '1234567890' ...
);
 
% Add device to nwb object
nwb.general_devices.set('array', device);

Electrodes Table

Since this is a DynamicTable, we can add additional metadata fields. We will be adding a "label" column to the table.
numShanks = 4;
numChannelsPerShank = 3;
numChannels = numShanks * numChannelsPerShank;
 
electrodesDynamicTable = types.hdmf_common.DynamicTable(...
'colnames', {'location', 'group', 'group_name', 'label'}, ...
'description', 'all electrodes');
 
for iShank = 1:numShanks
shankGroupName = sprintf('shank%d', iShank);
electrodeGroup = types.core.ElectrodeGroup( ...
'description', sprintf('electrode group for %s', shankGroupName), ...
'location', 'brain area', ...
'device', types.untyped.SoftLink(device) ...
);
nwb.general_extracellular_ephys.set(shankGroupName, electrodeGroup);
for iElectrode = 1:numChannelsPerShank
electrodesDynamicTable.addRow( ...
'location', 'unknown', ...
'group', types.untyped.ObjectView(electrodeGroup), ...
'group_name', shankGroupName, ...
'label', sprintf('%s-electrode%d', shankGroupName, iElectrode));
end
end
electrodesDynamicTable.toTable() % Display the table
ans = 12×5 table
 idlocationgroupgroup_namelabel
10'unknown'1×1 ObjectView'shank1''shank1-electrode1'
21'unknown'1×1 ObjectView'shank1''shank1-electrode2'
32'unknown'1×1 ObjectView'shank1''shank1-electrode3'
43'unknown'1×1 ObjectView'shank2''shank2-electrode1'
54'unknown'1×1 ObjectView'shank2''shank2-electrode2'
65'unknown'1×1 ObjectView'shank2''shank2-electrode3'
76'unknown'1×1 ObjectView'shank3''shank3-electrode1'
87'unknown'1×1 ObjectView'shank3''shank3-electrode2'
98'unknown'1×1 ObjectView'shank3''shank3-electrode3'
109'unknown'1×1 ObjectView'shank4''shank4-electrode1'
1110'unknown'1×1 ObjectView'shank4''shank4-electrode2'
1211'unknown'1×1 ObjectView'shank4''shank4-electrode3'
nwb.general_extracellular_ephys_electrodes = electrodesDynamicTable;

Links

In the above loop, we create ElectrodeGroup objects. The electrodes table then uses an ObjectView in each row to link to the corresponding ElectrodeGroup object. An ObjectView is a construct that enables linking one neurodata type to another, allowing a neurodata type to reference another within the NWB file.

Recorded Extracellular Signals

Voltage data are stored using the ElectricalSeries class, a subclass of the TimeSeries class specialized for voltage data.

Referencing Electrodes

In order to create our ElectricalSeries object, we first need to reference a set of rows in the electrodes table to indicate which electrode (channel) each entry in the electrical series were recorded from. We will do this by creating a DynamicTableRegion, which is a type of link that allows you to reference specific rows of a DynamicTable, such as the electrodes table, using row indices.
Create a DynamicTableRegion that references all rows of the electrodes table.
electrode_table_region = types.hdmf_common.DynamicTableRegion( ...
'table', types.untyped.ObjectView(electrodesDynamicTable), ...
'description', 'all electrodes', ...
'data', (0:length(electrodesDynamicTable.id.data)-1)');

Raw Voltage Data

Now create an ElectricalSeries object to hold acquisition data collected during the experiment.
raw_electrical_series = types.core.ElectricalSeries( ...
'starting_time', 0.0, ... % seconds
'starting_time_rate', 30000., ... % Hz
'data', randn(numChannels, 3000), ... % nChannels x nTime
'electrodes', electrode_table_region, ...
'data_unit', 'volts');
This is the voltage data recorded directly from our electrodes, so it goes in the acquisition group.
nwb.acquisition.set('ElectricalSeries', raw_electrical_series);

Processed Extracellular Electrical Signals

LFP

LFP refers to data that has been low-pass filtered, typically below 300 Hz. This data may also be downsampled. Because it is filtered and potentially resampled, it is categorized as processed data. LFP data would also be stored in an ElectricalSeries. To help data analysis and visualization tools know that this ElectricalSeries object represents LFP data, we store it inside an LFP object and then place the LFP object in a ProcessingModule named 'ecephys'. This is analogous to how we stored the SpatialSeries object inside of a Position object and stored the Position object in a ProcessingModule named 'behavior' in the behavior tutorial
lfp_electrical_series = types.core.ElectricalSeries( ...
'starting_time', 0.0, ... % seconds
'starting_time_rate', 1000., ... % Hz
'data', randn(numChannels, 100), ... nChannels x nTime
'filtering', 'Low-pass filter at 300 Hz', ...
'electrodes', electrode_table_region, ...
'data_unit', 'volts');
 
lfp = types.core.LFP('ElectricalSeries', lfp_electrical_series);
 
ecephys_module = types.core.ProcessingModule(...
'description', 'extracellular electrophysiology');
 
ecephys_module.nwbdatainterface.set('LFP', lfp);
nwb.processing.set('ecephys', ecephys_module);

Other Types of Filtered Electrical Signals

If your acquired data is filtered for frequency ranges other than LFP—such as Gamma or Theta—you can store the result in an ElectricalSeries and encapsulate it within a FilteredEphys object instead of the LFP object.
% Generate filtered data
filtered_data = randn(50, 12); % 50 time points, 12 channels
filtered_data = permute(filtered_data, [2, 1]); % permute timeseries for matnwb
 
% Create an ElectricalSeries object
filtered_electrical_series = types.core.ElectricalSeries( ...
'description', 'Data filtered in the theta range', ...
'data', filtered_data, ...
'electrodes', electrode_table_region, ...
'filtering', 'Band-pass filtered between 4 and 8 Hz', ...
'starting_time', 0.0, ...
'starting_time_rate', 200.0 ...
);
 
% Create a FilteredEphys object and add the filtered electrical series
filtered_ephys = types.core.FilteredEphys();
filtered_ephys.electricalseries.set('FilteredElectricalSeries', filtered_electrical_series);
 
% Add the FilteredEphys object to the ecephys module
ecephys_module.nwbdatainterface.set('FilteredEphys', filtered_ephys);

Decomposition of LFP Data into Frequency Bands

In some cases, you may want to further process the LFP data and decompose the signal into different frequency bands for additional downstream analyses. You can then store the processed data from these spectral analyses using a DecompositionSeries object. This object allows you to include metadata about the frequency bands and metric used (e.g., power, phase, amplitude), as well as link the decomposed data to the original TimeSeries signal the data was derived from.
In this tutorial, the examples for FilteredEphys and DecompositionSeries may appear similar. However, the key difference is that DecompositionSeries is specialized for storing the results of spectral analyses of timeseries data in general, whereas FilteredEphys is defined specifically as a container for filtered electrical signals.
Note: When adding data to a DecompositionSeries, the data argument is assumed to be 3D where the first dimension is time, the second dimension is channels, and the third dimension is bands. As mentioned in the beginning of this tutorial, in MatNWB the data needs to be permuted because the dimensions are written to file in reverse order (See the dimensionMapNoDataPipes tutorial)
% Define the frequency bands of interest (in Hz):
band_names = {'theta'; 'beta'; 'gamma'};
band_mean = [8; 21; 55];
band_stdev = [2; 4.5; 12.5];
band_limits = [band_mean - 2*band_stdev, band_mean + 2*band_stdev];
 
% The bands should be added to the DecompositionSeries as a dynamic table
bands = table(band_names, band_mean, band_stdev, band_limits, ...
'VariableNames', {'band_name', 'band_mean', 'band_stdev', 'band_limits'})
bands = 3×4 table
 band_nameband_meanband_stdevband_limits
12
1'theta'82412
2'beta'214.50001230
3'gamma'5512.50003080
 
bands = util.table2nwb( bands );
 
% Generate random phase data for the demonstration.
phase_data = randn(50, 12, numel(band_names)); % 50 samples, 12 channels, 3 frequency bands
phase_data = permute(phase_data, [3,2,1]); % See dimensionMapNoDataPipes tutorial
 
decomp_series = types.core.DecompositionSeries(...
'data', phase_data, ...
'bands', bands, ...
'metric', 'phase', ...
'starting_time', 0.0, ... % seconds
'starting_time_rate', 1000.0, ... % Hz
'source_channels', electrode_table_region, ...
'source_timeseries', lfp_electrical_series);
 
% Add decomposition series to ecephys module
ecephys_module.nwbdatainterface.set('theta', decomp_series);

Spike Times and Extracellular Events

Sorted Spike Times

Spike times are stored in a Units table, a specialization of the DynamicTable class. The default Units table is located at /units in the HDF5 file. You can add columns to the Units table just like you did for electrodes and trials (see convertTrials). Here, we generate some random spike time data and populate the table. Note: Spike times of a Units table should be sorted in ascending order.
num_cells = 10;
spike_times = cell(1, num_cells);
for iShank = 1:num_cells
spike_times{iShank} = sort( rand(1, randi([16, 28])), 'ascend');
end
spike_times
spike_times = 1×10 cell
 12345678910
11×19 double1×16 double1×17 double1×28 double1×28 double1×25 double1×28 double1×19 double1×27 double1×24 double

Ragged Arrays

Spike times are an example of a ragged array- it's like a matrix, but each row has a different number of elements. We can represent this type of data as an indexed column of the Units table. These indexed columns have two components, the VectorData object that holds the data and the VectorIndex object that holds the indices in the vector that indicate the row breaks. You can use the convenience function util.create_indexed_column to create these objects. For more information about ragged arrays, we refer you to the "Ragged Array Columns" section of the dynamic table tutorial.
[spike_times_vector, spike_times_index] = util.create_indexed_column(spike_times);
 
nwb.units = types.core.Units( ...
'colnames', {'spike_times'}, ...
'description', 'units table', ...
'spike_times', spike_times_vector, ...
'spike_times_index', spike_times_index ...
);
 
nwb.units.toTable()
ans = 10×2 table
 idspike_times
1119×1 double
2216×1 double
3317×1 double
4428×1 double
5528×1 double
6625×1 double
7728×1 double
8819×1 double
9927×1 double
101024×1 double

Unsorted Spike Times

While the Units table is used to store spike times and waveform data for spike-sorted, single-unit activity, you may also want to store spike times and waveform snippets of unsorted spiking activity. This is useful for recording multi-unit activity detected via threshold crossings during data acquisition. Such information can be stored using SpikeEventSeries objects.
% In the SpikeEventSeries the dimensions should be ordered as
% [num_events, num_channels, num_samples].
% Define spike snippets: 20 events, 3 channels, 40 samples per event.
spike_snippets = rand(20, 3, 40);
% Permute spike snippets (See dimensionMapNoDataPipes tutorial)
spike_snippets = permute(spike_snippets, [3,2,1])
spike_snippets =
spike_snippets(:,:,1) = 0.3632 0.5182 0.5128 0.1808 0.6199 0.1835 0.3321 0.5755 0.3364 0.4506 0.9369 0.8301 0.0578 0.2067 0.4366 0.4005 0.4929 0.8444 0.5930 0.4952 0.0010 0.8500 0.9587 0.0791 0.3166 0.6158 0.4340 0.6987 0.3685 0.6232 0.8468 0.5832 0.3882 0.9573 0.8957 0.5304 0.1859 0.5861 0.3593 0.1213 0.8766 0.1928 0.4207 0.8604 0.9150 0.2882 0.9645 0.9614 0.5104 0.6147 0.8233 0.0355 0.0410 0.9516 0.5877 0.3250 0.4906 0.9435 0.7141 0.0569 0.5459 0.8422 0.9809 0.9810 0.5114 0.9647 0.6587 0.1781 0.4791 0.1639 0.9175 0.9126 0.0044 0.3949 0.8894 0.6674 0.9730 0.9469 0.1616 0.7084 0.9779 0.8892 0.5071 0.0085 0.7591 0.0696 0.1014 0.9200 0.7627 0.0914 0.6508 0.6546 0.5292 0.5206 0.2306 0.9407 0.7088 0.7777 0.7567 0.4180 0.8563 0.5013 0.0208 0.0415 0.5320 0.2808 0.3307 0.2079 0.1500 0.1979 0.3543 0.6623 0.6735 0.6648 0.1854 0.8095 0.4281 0.3264 0.4593 0.6088 spike_snippets(:,:,2) = 0.3741 0.0029 0.9295 0.5818 0.7874 0.1291 0.4985 0.9351 0.1593 0.3795 0.4274 0.1862 0.5281 0.6498 0.9900 0.5401 0.1619 0.4577 0.3466 0.1652 0.9278 0.3049 0.4371 0.3153 0.1639 0.0157 0.2046 0.6904 0.4372 0.5136 0.7032 0.5160 0.9067 0.2582 0.9922 0.4211 0.0532 0.8350 0.3423 0.5813 0.3731 0.5658 0.4566 0.8411 0.4073 0.1609 0.4008 0.7086 0.4720 0.9801 0.2170 0.4784 0.4855 0.8529 0.0918 0.4290 0.3830 0.8856 0.2107 0.5822 0.9216 0.2481 0.4470 0.5378 0.0797 0.2052 0.7951 0.4080 0.5716 0.4211 0.6854 0.4683 0.2522 0.5554 0.7880 0.5408 0.8890 0.5846 0.2445 0.3428 0.5063 0.3176 0.1683 0.0395 0.1068 0.4167 0.1085 0.6951 0.3395 0.6547 0.8929 0.9403 0.2319 0.4724 0.8036 0.6168 0.7853 0.8170 0.2833 0.0489 0.7234 0.6784 0.1694 0.7329 0.2084 0.6778 0.6014 0.0644 0.6981 0.9275 0.9523 0.4093 0.5078 0.5352 0.2624 0.2431 0.2504 0.4178 0.1495 0.7030 spike_snippets(:,:,3) = 0.5032 0.4640 0.4871 0.5844 0.2490 0.3721 0.1473 0.8858 0.0451 0.0527 0.4320 0.4229 0.9731 0.5462 0.3433 0.9330 0.9554 0.3721 0.6217 0.8803 0.7188 0.7876 0.4755 0.3857 0.5442 0.1009 0.1891 0.9056 0.6795 0.4412 0.0408 0.2534 0.9542 0.7208 0.8791 0.3632 0.3747 0.4943 0.7917 0.7212 0.6361 0.6318 0.0290 0.4603 0.9211 0.2222 0.8798 0.1820 0.6469 0.3367 0.5713 0.7143 0.1256 0.3099 0.7846 0.8619 0.8801 0.5945 0.3167 0.1474 0.4698 0.4673 0.8462 0.2969 0.4079 0.3021 0.4255 0.3667 0.4454 0.7899 0.9081 0.5835 0.7428 0.1157 0.5121 0.3237 0.3616 0.7042 0.6754 0.0043 0.7307 0.9385 0.0529 0.5360 0.7322 0.9612 0.8842 0.7363 0.2838 0.1179 0.0575 0.6034 0.8314 0.5310 0.8519 0.7056 0.5981 0.0138 0.2776 0.4375 0.2414 0.7821 0.8078 0.8065 0.7540 0.2214 0.2981 0.9667 0.8698 0.6365 0.4839 0.7271 0.6797 0.8300 0.4083 0.0384 0.9849 0.8816 0.5302 0.8979 spike_snippets(:,:,4) = 0.5449 0.5646 0.4484 0.5603 0.6743 0.2931 0.1059 0.1390 0.5090 0.8740 0.5258 0.7801 0.6468 0.7692 0.0921 0.2976 0.2031 0.1182 0.5349 0.2906 0.3676 0.2051 0.6809 0.3227 0.0234 0.9596 0.6935 0.7713 0.6416 0.2855 0.5333 0.8957 0.8830 0.9589 0.5892 0.3351 0.1145 0.5703 0.0503 0.8033 0.0430 0.4204 0.2983 0.0932 0.1633 0.3292 0.7832 0.2015 0.4668 0.9801 0.2202 0.0102 0.9904 0.8402 0.4240 0.0189 0.0777 0.9313 0.6864 0.1900 0.5086 0.6875 0.8263 0.4471 0.5739 0.6647 0.2582 0.3064 0.2290 0.7383 0.0041 0.5077 0.0969 0.6880 0.2574 0.5624 0.6921 0.1861 0.0810 0.4033 0.8597 0.3200 0.0637 0.4747 0.5442 0.6536 0.0475 0.2725 0.5702 0.9495 0.4577 0.2291 0.6482 0.9572 0.7286 0.6492 0.3944 0.4469 0.7977 0.2474 0.8736 0.3864 0.4932 0.8357 0.0022 0.4839 0.1409 0.4677 0.4450 0.1749 0.4610 0.8078 0.4879 0.4360 0.6353 0.9215 0.7464 0.9792 0.5838 0.5137 spike_snippets(:,:,5) = 0.4153 0.0693 0.0654 0.7621 0.3065 0.6522 0.7172 0.4484 0.2055 0.5872 0.4036 0.4513 0.7603 0.7771 0.6436 0.2667 0.1627 0.2198 0.8574 0.4834 0.3096 0.9741 0.3538 0.7200 0.4723 0.5202 0.2108 0.8465 0.0371 0.6823 0.1880 0.7965 0.2459 0.0161 0.8691 0.1887 0.4842 0.6178 0.0883 0.1699 0.3448 0.2300 0.4600 0.9785 0.0939 0.5418 0.5181 0.3015 0.6913 0.3006 0.1272 0.9578 0.2147 0.6264 0.4916 0.5732 0.0331 0.6137 0.8187 0.5443 0.5994 0.1335 0.2221 0.4095 0.9644 0.3933 0.0863 0.7050 0.9741 0.0317 0.4826 0.9286 0.8119 0.0334 0.9783 0.6455 0.8937 0.4585 0.7176 0.1290 0.2153 0.6583 0.3969 0.7901 0.4907 0.9680 0.1592 0.6581 0.6146 0.3346 0.5637 0.1577 0.8508 0.8528 0.6100 0.0262 0.1537 0.4297 0.4774 0.5284 0.8946 0.6464 0.7072 0.7436 0.4747 0.7435 0.9277 0.7271 0.2860 0.0805 0.1114 0.7811 0.6714 0.3130 0.3769 0.9252 0.2897 0.8737 0.3722 0.1405 spike_snippets(:,:,6) = 0.0763 0.2364 0.3650 0.4056 0.2909 0.0138 0.7028 0.2731 0.9736 0.0459 0.0985 0.8266 0.0568 0.5244 0.6244 0.8312 0.2496 0.4805 0.2076 0.5440 0.9214 0.7454 0.7051 0.3394 0.6040 0.3209 0.0938 0.0813 0.0868 0.9657 0.6102 0.1397 0.8555 0.9192 0.6464 0.0747 0.9073 0.7906 0.2621 0.7482 0.4618 0.2951 0.8889 0.7258 0.3943 0.4490 0.9695 0.0114 0.2865 0.9733 0.9258 0.1940 0.9995 0.2735 0.1813 0.0901 0.8102 0.6846 0.4168 0.5109 0.1988 0.4719 0.2133 0.6359 0.2320 0.6484 0.5243 0.6663 0.9095 0.9976 0.9121 0.5287 0.7862 0.7466 0.4362 0.5996 0.9122 0.6571 0.9737 0.7030 0.3519 0.8891 0.4928 0.9771 0.1241 0.3617 0.2208 0.2517 0.4837 0.5412 0.4657 0.8764 0.5787 0.9359 0.1406 0.6036 0.3637 0.1126 0.6308 0.5820 0.6792 0.5287 0.4958 0.0559 0.9294 0.9938 0.2217 0.5787 0.4113 0.5297 0.7555 0.6723 0.0057 0.1682 0.0613 0.8202 0.4313 0.0191 0.4224 0.4616 spike_snippets(:,:,7) = 0.1688 0.4000 0.4932 0.5037 0.5168 0.2114 0.4172 0.8651 0.5171 0.2470 0.1566 0.0013 0.9096 0.4953 0.4404 0.8769 0.6938 0.0270 0.2556 0.5880 0.6589 0.5604 0.6910 0.6519 0.6483 0.4096 0.2309 0.6740 0.6623 0.0503 0.2088 0.0952 0.8056 0.9761 0.5382 0.4641 0.3936 0.8665 0.9014 0.0075 0.1701 0.4080 0.8593 0.6276 0.7250 0.4811 0.5474 0.7787 0.5437 0.1385 0.7716 0.6448 0.8111 0.5123 0.7288 0.2984 0.8888 0.2559 0.7374 0.1228 0.4050 0.3966 0.1041 0.7329 0.0438 0.2613 0.6672 0.5516 0.1787 0.9827 0.9108 0.1156 0.0928 0.5723 0.8266 0.3471 0.6842 0.0050 0.2747 0.9155 0.1302 0.8747 0.1887 0.8827 0.6208 0.0840 0.5257 0.3594 0.5808 0.3324 0.9258 0.4272 0.7476 0.9315 0.0989 0.0101 0.7520 0.0744 0.6405 0.9010 0.3403 0.9194 0.1847 0.1275 0.8967 0.4094 0.5342 0.2052 0.4618 0.2844 0.2040 0.1349 0.4141 0.9510 0.3021 0.7055 0.9961 0.8682 0.6920 0.2310 spike_snippets(:,:,8) = 0.4068 0.6092 0.6291 0.6403 0.8800 0.7637 0.3127 0.4755 0.8588 0.5481 0.3856 0.9334 0.8622 0.4424 0.5190 0.7067 0.9865 0.8104 0.5081 0.0832 0.2481 0.7339 0.9566 0.2721 0.9790 0.0811 0.9867 0.2457 0.4348 0.7650 0.4659 0.0593 0.0079 0.8898 0.0262 0.8263 0.0542 0.2863 0.3978 0.6080 0.7664 0.6152 0.6828 0.3494 0.5616 0.2486 0.0152 0.4069 0.9289 0.3132 0.4969 0.2038 0.6786 0.7759 0.8784 0.8144 0.6858 0.5562 0.3193 0.9711 0.5149 0.2859 0.3051 0.6081 0.1928 0.3049 0.2739 0.9220 0.9925 0.8032 0.4984 0.8485 0.0225 0.7239 0.3484 0.0826 0.9913 0.7982 0.7890 0.2908 0.3864 0.1369 0.3864 0.4586 0.8380 0.6207 0.1885 0.9198 0.0699 0.9739 0.6546 0.8259 0.8891 0.4635 0.5513 0.9174 0.1724 0.7569 0.7397 0.6673 0.4485 0.2774 0.1633 0.8078 0.6112 0.0463 0.4154 0.9257 0.7293 0.5777 0.4014 0.1381 0.3180 0.1456 0.9487 0.6056 0.1338 0.7341 0.7836 0.6194 spike_snippets(:,:,9) = 0.9628 0.8975 0.2718 0.0546 0.3633 0.6150 0.8446 0.6844 0.1118 0.0860 0.5622 0.8052 0.7516 0.5644 0.5614 0.7263 0.4897 0.7388 0.8288 0.4004 0.4157 0.7984 0.0191 0.2703 0.2895 0.9058 0.7428 0.0395 0.4252 0.3582 0.9670 0.5165 0.9646 0.6134 0.4585 0.3719 0.7396 0.9848 0.3544 0.5037 0.3953 0.3936 0.7088 0.9015 0.0272 0.6534 0.0848 0.3942 0.3755 0.3944 0.7642 0.1767 0.8730 0.6316 0.3319 0.0936 0.7564 0.4216 0.1344 0.1215 0.1360 0.2356 0.1898 0.4668 0.9118 0.6550 0.9504 0.3174 0.2620 0.5731 0.9952 0.7447 0.5518 0.0291 0.2041 0.7543 0.2133 0.6372 0.7927 0.3300 0.6997 0.4981 0.0503 0.1060 0.4157 0.3973 0.9644 0.0873 0.2040 0.7161 0.3374 0.9804 0.6648 0.9967 0.9777 0.9874 0.1673 0.5072 0.6902 0.7153 0.1727 0.9650 0.8172 0.7204 0.9148 0.9816 0.0339 0.4406 0.4037 0.7764 0.5481 0.7877 0.9740 0.9207 0.8353 0.1799 0.4172 0.7419 0.0359 0.0791 spike_snippets(:,:,10) = 0.2730 0.7100 0.6650 0.3350 0.8313 0.4063 0.1754 0.6795 0.5598 0.4724 0.7245 0.4546 0.4243 0.5273 0.5692 0.6355 0.8517 0.4811 0.5781 0.4010 0.3721 0.4324 0.8047 0.1457 0.1022 0.8810 0.7334 0.6187 0.9501 0.0273 0.3221 0.8350 0.9969 0.8764 0.8014 0.4712 0.8010 0.2724 0.7597 0.1771 0.0340 0.8375 0.0911 0.5032 0.4280 0.5019 0.6836 0.0951 0.1445 0.4880 0.4560 0.3868 0.9883 0.1536 0.2826 0.9204 0.7479 0.2890 0.0829 0.0899 0.9542 0.8585 0.8478 0.7554 0.7902 0.7821 0.0584 0.4732 0.6280 0.4970 0.0973 0.5866 0.2204 0.1064 0.8124 0.9218 0.3019 0.0151 0.6404 0.2850 0.0858 0.0060 0.4500 0.4342 0.6315 0.3986 0.4241 0.0528 0.1402 0.4760 0.1294 0.1814 0.2664 0.0504 0.2418 0.3423 0.9561 0.9551 0.1565 0.5866 0.7832 0.5342 0.5290 0.0301 0.2380 0.2475 0.3738 0.9124 0.3574 0.1211 0.2690 0.6359 0.0579 0.1300 0.9555 0.7202 0.6187 0.9668 0.6651 0.7906 spike_snippets(:,:,11) = 0.4552 0.2518 0.8249 0.0155 0.4963 0.6799 0.4754 0.7603 0.1911 0.6341 0.6839 0.8067 0.4248 0.4342 0.6700 0.6439 0.4729 0.0509 0.1556 0.1116 0.8344 0.1801 0.8205 0.5009 0.8576 0.5546 0.3599 0.1614 0.7571 0.0658 0.8586 0.0634 0.0399 0.9359 0.6480 0.0506 0.0811 0.0104 0.4813 0.9152 0.2603 0.5316 0.6497 0.3006 0.0866 0.0136 0.2089 0.4217 0.6607 0.6042 0.6090 0.9624 0.4014 0.3064 0.4627 0.0339 0.1767 0.4546 0.0251 0.3949 0.0313 0.0696 0.3428 0.8736 0.6131 0.4805 0.3823 0.1687 0.7995 0.8354 0.3539 0.5606 0.9936 0.7356 0.7970 0.4970 0.1702 0.4641 0.6865 0.8939 0.8408 0.5140 0.4789 0.3372 0.5532 0.8096 0.6476 0.9394 0.9270 0.6588 0.7857 0.5153 0.3119 0.2256 0.6283 0.2444 0.7223 0.5115 0.4889 0.4329 0.0630 0.3687 0.5034 0.3499 0.0790 0.9831 0.2466 0.2275 0.3611 0.3169 0.1122 0.5310 0.3300 0.0256 0.1923 0.7115 0.8745 0.6676 0.8762 0.2300 spike_snippets(:,:,12) = 0.2302 0.6301 0.4700 0.9931 0.4911 0.3318 0.0031 0.5847 0.0120 0.4526 0.4216 0.0713 0.6475 0.7289 0.7721 0.3581 0.0684 0.2277 0.8828 0.6725 0.9818 0.8133 0.2430 0.7629 0.3101 0.3063 0.3922 0.7441 0.1114 0.1159 0.5806 0.3896 0.7311 0.4649 0.3515 0.0828 0.2095 0.2088 0.0117 0.3598 0.9676 0.7764 0.9613 0.1234 0.7949 0.8738 0.4092 0.6687 0.4453 0.2036 0.6252 0.0303 0.1278 0.9754 0.2795 0.3343 0.6507 0.6751 0.5247 0.8481 0.9592 0.0580 0.9579 0.5061 0.6563 0.0682 0.5022 0.6691 0.7148 0.9205 0.6910 0.0678 0.4682 0.1326 0.4265 0.5026 0.4605 0.5364 0.9746 0.4886 0.0177 0.7635 0.5963 0.0768 0.5423 0.4407 0.2524 0.6413 0.5576 0.9485 0.8814 0.8368 0.5532 0.7908 0.5579 0.9331 0.2472 0.7849 0.3395 0.5118 0.3795 0.7591 0.4796 0.9883 0.6733 0.4135 0.9126 0.9788 0.4029 0.0625 0.9626 0.2478 0.9640 0.6727 0.8952 0.9116 0.4830 0.6497 0.0820 0.2586 spike_snippets(:,:,13) = 0.4519 0.7405 0.4489 0.0264 0.2702 0.8831 0.7678 0.5995 0.6169 0.5891 0.3483 0.4144 0.8259 0.7094 0.0349 0.3697 0.2601 0.4832 0.7362 0.4522 0.7713 0.1019 0.8022 0.2802 0.8328 0.9042 0.3244 0.0931 0.5174 0.4579 0.5652 0.1727 0.2022 0.7989 0.3892 0.4189 0.5648 0.8190 0.0274 0.9328 0.1229 0.3266 0.8625 0.1616 0.8158 0.5273 0.0451 0.7698 0.7937 0.3788 0.6850 0.9604 0.9163 0.4078 0.7034 0.6213 0.0688 0.5315 0.4212 0.2980 0.8958 0.2151 0.7849 0.1357 0.1947 0.6666 0.1897 0.9722 0.6984 0.9010 0.7252 0.5884 0.2902 0.1922 0.9654 0.0259 0.4403 0.6301 0.6138 0.7995 0.2096 0.8161 0.6281 0.3466 0.5966 0.0548 0.5681 0.8906 0.5351 0.9122 0.0789 0.3722 0.8024 0.5180 0.9846 0.5402 0.1291 0.9728 0.5184 0.9957 0.7150 0.1856 0.8818 0.6592 0.1271 0.1123 0.2347 0.2144 0.7885 0.7141 0.2330 0.8744 0.8645 0.0399 0.1745 0.8655 0.9251 0.0351 0.4784 0.6786 spike_snippets(:,:,14) = 0.7952 0.1619 0.6301 0.9239 0.9209 0.2923 0.2705 0.7300 0.2747 0.2730 0.7219 0.1755 0.2483 0.4585 0.1676 0.0479 0.1408 0.8048 0.9544 0.0320 0.0292 0.2449 0.9650 0.3298 0.3442 0.2298 0.8580 0.7812 0.6950 0.7709 0.5130 0.5035 0.0985 0.1763 0.3672 0.5041 0.2782 0.2955 0.6494 0.6255 0.7382 0.6417 0.8193 0.4694 0.0975 0.8021 0.0280 0.2162 0.9382 0.0685 0.0152 0.0008 0.0109 0.5472 0.9406 0.9345 0.3422 0.6736 0.8125 0.5123 0.9255 0.6324 0.5230 0.5219 0.0628 0.4195 0.7015 0.8469 0.8494 0.2589 0.0907 0.0447 0.5631 0.2416 0.5488 0.0113 0.0596 0.4179 0.2162 0.1635 0.9930 0.2039 0.6061 0.4390 0.1874 0.9775 0.6180 0.2134 0.2084 0.4583 0.5149 0.9612 0.7399 0.3790 0.1341 0.2476 0.1684 0.4531 0.8106 0.9753 0.1750 0.5517 0.8170 0.4059 0.8448 0.4250 0.1909 0.1111 0.5232 0.4596 0.5057 0.9890 0.4907 0.8099 0.6029 0.5007 0.5037 0.3349 0.2985 0.5274 spike_snippets(:,:,15) = 0.1532 0.8094 0.4460 0.8166 0.7126 0.8274 0.5762 0.5124 0.3932 0.7768 0.6805 0.3972 0.7677 0.8370 0.9179 0.0165 0.8907 0.7687 0.1992 0.7091 0.4747 0.5167 0.1899 0.8383 0.1327 0.6116 0.0784 0.2311 0.9376 0.6298 0.7024 0.6093 0.3375 0.0938 0.1714 0.1469 0.9469 0.1150 0.8280 0.9998 0.8850 0.9216 0.9260 0.2016 0.2223 0.8148 0.3500 0.5679 0.8104 0.9778 0.4043 0.8466 0.9989 0.9862 0.8161 0.4530 0.3664 0.5228 0.8016 0.0691 0.9189 0.1249 0.7971 0.8887 0.6162 0.4995 0.3448 0.3371 0.6123 0.7429 0.4395 0.7420 0.7961 0.2327 0.0629 0.5840 0.3284 0.2015 0.4358 0.0271 0.7103 0.8134 0.6329 0.1657 0.1692 0.5428 0.8054 0.1441 0.9211 0.6704 0.7682 0.3255 0.0551 0.6557 0.6621 0.5588 0.6450 0.6097 0.3590 0.3203 0.5681 0.4577 0.6717 0.4715 0.5969 0.0492 0.5429 0.6275 0.9199 0.7636 0.1837 0.3884 0.8181 0.1989 0.5731 0.3094 0.2752 0.8680 0.9220 0.5985 spike_snippets(:,:,16) = 0.2666 0.1083 0.7954 0.8144 0.5805 0.9129 0.4172 0.8916 0.1177 0.9244 0.4455 0.3971 0.9639 0.9888 0.2357 0.5563 0.7205 0.0393 0.5243 0.4717 0.0399 0.7826 0.1775 0.4026 0.5235 0.1508 0.5544 0.4388 0.0758 0.1280 0.6734 0.5241 0.6162 0.2907 0.3915 0.4487 0.6732 0.5663 0.3725 0.0390 0.7822 0.1664 0.4134 0.7131 0.0881 0.4929 0.5646 0.6301 0.9922 0.0883 0.5063 0.1232 0.4720 0.1982 0.8544 0.9022 0.0677 0.3764 0.5517 0.2157 0.9954 0.2783 0.5277 0.1991 0.2969 0.8135 0.9669 0.3435 0.9309 0.5375 0.9753 0.1436 0.8520 0.2718 0.1304 0.5096 0.4100 0.4075 0.8421 0.2268 0.1249 0.7560 0.9439 0.8515 0.1431 0.0701 0.8344 0.2331 0.0632 0.0263 0.7482 0.7277 0.8519 0.4667 0.5723 0.9887 0.0666 0.0297 0.3495 0.4710 0.9101 0.4599 0.7983 0.5293 0.8805 0.2686 0.8589 0.2491 0.9464 0.6149 0.6990 0.4899 0.1802 0.7923 0.1711 0.3071 0.1641 0.4078 0.5878 0.2553 spike_snippets(:,:,17) = 0.5728 0.2783 0.9604 0.9503 0.1952 0.9313 0.6364 0.8817 0.3846 0.6734 0.2641 0.5571 0.2475 0.0520 0.6725 0.4525 0.2827 0.0951 0.5464 0.7265 0.5980 0.1174 0.6978 0.7444 0.6699 0.3192 0.9200 0.8035 0.7715 0.8844 0.5847 0.5426 0.7272 0.1072 0.5736 0.4591 0.0925 0.3469 0.0261 0.9836 0.1773 0.3506 0.1026 0.0964 0.4590 0.9173 0.8778 0.0152 0.3698 0.2780 0.6437 0.0620 0.0553 0.7908 0.8746 0.9258 0.6235 0.2749 0.3504 0.2799 0.6183 0.4695 0.7160 0.6003 0.1984 0.8818 0.4697 0.5599 0.5940 0.5600 0.3097 0.0615 0.3651 0.0751 0.7954 0.2324 0.9134 0.6722 0.5065 0.6889 0.4275 0.2370 0.1305 0.3818 0.2371 0.5678 0.3174 0.8807 0.9282 0.7523 0.5560 0.0137 0.9639 0.8290 0.9343 0.8165 0.8799 0.1221 0.6556 0.8146 0.0078 0.1145 0.1693 0.4729 0.6801 0.4113 0.2638 0.1325 0.6774 0.2419 0.2965 0.3059 0.6723 0.5881 0.8006 0.9311 0.2772 0.0148 0.9562 0.3382 spike_snippets(:,:,18) = 0.2447 0.5622 0.3198 0.8011 0.0949 0.7630 0.4455 0.7674 0.0797 0.8066 0.7385 0.4715 0.5203 0.6748 0.3170 0.7049 0.3774 0.4973 0.1649 0.2615 0.2671 0.2320 0.8460 0.5759 0.2708 0.3055 0.3161 0.0585 0.0536 0.7174 0.0342 0.7895 0.8694 0.6977 0.3541 0.5419 0.2702 0.5671 0.1408 0.6261 0.6155 0.6693 0.7968 0.1514 0.2405 0.9084 0.7495 0.6356 0.2633 0.3608 0.3302 0.5210 0.1566 0.8720 0.6958 0.2049 0.9545 0.8628 0.8083 0.9930 0.6387 0.7493 0.8583 0.2290 0.9724 0.6963 0.1949 0.9766 0.2198 0.0261 0.0365 0.4331 0.3940 0.0345 0.2422 0.1148 0.8197 0.0159 0.9841 0.2999 0.5970 0.2916 0.5259 0.0568 0.4842 0.4254 0.9782 0.6525 0.3252 0.4892 0.1828 0.5336 0.5430 0.4208 0.4712 0.1924 0.5385 0.0565 0.1487 0.1376 0.9059 0.3607 0.9991 0.6692 0.6554 0.5010 0.5005 0.7243 0.5604 0.6295 0.9576 0.3715 0.7993 0.0637 0.1888 0.3476 0.8958 0.6303 0.0657 0.3269 spike_snippets(:,:,19) = 0.9197 0.6717 0.4528 0.0377 0.6187 0.6188 0.5387 0.3419 0.2361 0.8453 0.1492 0.7228 0.9458 0.6480 0.6237 0.6780 0.8552 0.6936 0.1251 0.1004 0.2071 0.1838 0.2822 0.6302 0.3836 0.7830 0.6902 0.2847 0.3436 0.1595 0.3685 0.1525 0.5415 0.8274 0.6325 0.4152 0.2535 0.2956 0.0574 0.9890 0.7571 0.1376 0.8888 0.9891 0.0983 0.6159 0.9910 0.3625 0.8900 0.4215 0.8522 0.7635 0.4034 0.5899 0.0323 0.2470 0.4107 0.6003 0.9522 0.8557 0.6043 0.5940 0.1214 0.5573 0.9360 0.0057 0.1590 0.2362 0.8142 0.7453 0.7446 0.2327 0.1912 0.3240 0.6003 0.8628 0.2963 0.7651 0.9248 0.8691 0.3682 0.9663 0.3015 0.0675 0.5285 0.7778 0.5937 0.9730 0.9058 0.7368 0.8969 0.0982 0.9797 0.5839 0.9927 0.2066 0.3587 0.4039 0.3999 0.5598 0.8218 0.4245 0.7274 0.3126 0.1869 0.8615 0.7875 0.2879 0.8029 0.1438 0.5210 0.0290 0.1990 0.2136 0.0185 0.4521 0.3630 0.2587 0.1287 0.3433 spike_snippets(:,:,20) = 0.0624 0.2310 0.2884 0.4794 0.7418 0.2947 0.0593 0.7780 0.7104 0.2272 0.1904 0.1341 0.8887 0.2581 0.8569 0.2548 0.4860 0.2235 0.6241 0.7389 0.2536 0.0542 0.5232 0.3767 0.2614 0.5655 0.1634 0.4915 0.0485 0.3867 0.2362 0.8383 0.6335 0.7190 0.1761 0.0244 0.2363 0.4062 0.0452 0.6368 0.1457 0.3871 0.2535 0.6027 0.9738 0.8102 0.7271 0.2021 0.6117 0.0738 0.3399 0.7657 0.5437 0.9440 0.4767 0.3951 0.9549 0.7470 0.1633 0.1775 0.1959 0.4153 0.0151 0.0548 0.0786 0.9610 0.1205 0.4466 0.1781 0.9961 0.0545 0.1732 0.0688 0.1145 0.6425 0.4629 0.9654 0.8124 0.5313 0.9066 0.1742 0.5560 0.4936 0.4682 0.6259 0.6859 0.3590 0.7523 0.2908 0.7008 0.7097 0.2139 0.5416 0.4346 0.1660 0.7733 0.3656 0.9635 0.6335 0.4512 0.6889 0.5008 0.1045 0.8343 0.7024 0.4937 0.6143 0.8978 0.6438 0.6317 0.4213 0.2350 0.7923 0.6601 0.8975 0.2984 0.4584 0.4754 0.8335 0.2761
 
% Create electrode table region referencing electrodes 0, 1, and 2
shank0_table_region = types.hdmf_common.DynamicTableRegion( ...
'table', types.untyped.ObjectView(electrodesDynamicTable), ...
'description', 'shank0', ...
'data', (0:2)');
 
% Define spike event series for unsorted spike times
spike_events = types.core.SpikeEventSeries( ...
'data', spike_snippets, ...
'timestamps', (0:19)', ... % Timestamps for each event
'description', 'events detected with 100uV threshold', ...
'electrodes', shank0_table_region ...
);
 
% Add spike event series to NWB file acquisition
nwb.acquisition.set('SpikeEvents_Shank0', spike_events);

Detected Events

If you need to store the complete, continuous raw voltage traces, along with unsorted spike times, you should store the traces in ElectricalSeries objects in the acquisition group, and use the EventDetection class to identify the spike events in your raw traces.
% Create the EventDetection object
event_detection = types.core.EventDetection( ...
'detection_method', 'thresholding, 1.5 * std', ...
'source_electricalseries', types.untyped.SoftLink(raw_electrical_series), ...
'source_idx', [1000; 2000; 3000], ...
'times', [.033, .066, .099] ...
);
 
% Add the EventDetection object to the ecephys module
ecephys_module.nwbdatainterface.set('ThresholdEvents', event_detection);

Storing Spike Features (e.g Principal Components)

NWB also provides a way to store features of spikes, such as principal components, using the FeatureExtraction class.
% Generate random feature data (time x channel x feature)
features = rand(3, 12, 4); % 3 time points, 12 channels, 4 features
features = permute(features, [3,2,1]); % reverse dimension order for matnwb
 
% Create the FeatureExtraction object
feature_extraction = types.core.FeatureExtraction( ...
'description', {'PC1', 'PC2', 'PC3', 'PC4'}, ... % Feature descriptions
'electrodes', electrode_table_region, ... % DynamicTableRegion referencing the electrodes table
'times', [.033; .066; .099], ... % Column vector for times
'features', features ...
);
 
% Add the FeatureExtraction object to the ecephys module (if required)
ecephys_module.nwbdatainterface.set('PCA_features', feature_extraction);

Choosing NWB-Types for Electrophysiology Data (A Summary)

As mentioned above, ElectricalSeries objects are meant for storing electrical timeseries data like raw voltage signals or processed signals like LFP or other filtered signals. In addition to the ElectricalSeries class, NWB provides some more classes for storing event-based electropysiological data. We will briefly discuss them here, and refer the reader to the API documentation and the section on Extracellular Physiology in the "NWB Format Specification" for more details on using these objects.
For storing unsorted spiking data, there are two options. Which one you choose depends on what data you have available. If you need to store complete and/or continuous raw voltage traces, you should store the traces with ElectricalSeries objects as acquisition data, and use the EventDetection class for identifying the spike events in your raw traces. If you do not want to store the entire raw voltage traces, only the waveform ‘snippets’ surrounding spike events, you should use SpikeEventSeries objects.
The results of spike sorting (or clustering) should be stored in the top-level Units table. The Units table can hold just the spike times of sorted units or, optionally, include additional waveform information. You can use the optional predefined columns waveform_mean, waveform_sd, and waveforms in the Units table to store individual and mean waveform data.

Writing the NWB File

nwbExport(nwb, 'ecephys_tutorial.nwb')

Reading NWB Data

Data arrays are read passively from the file. Calling TimeSeries.data does not read the data values, but presents an HDF5 object that can be indexed to read data. This allows you to conveniently work with datasets that are too large to fit in RAM all at once. load with no input arguments reads the entire dataset:
nwb2 = nwbRead('ecephys_tutorial.nwb', 'ignorecache');
nwb2.processing.get('ecephys'). ...
nwbdatainterface.get('LFP'). ...
electricalseries.get('ElectricalSeries'). ...
data.load;

Accessing Data Regions

If all you need is a data region, you can index a DataStub object like you would any normal array in MATLAB, as shown below. When indexing the dataset this way, only the selected region is read from disk into RAM. This allows you to handle very large datasets that would not fit entirely into RAM.
% read section of LFP
nwb2.processing.get('ecephys'). ...
nwbdatainterface.get('LFP'). ...
electricalseries.get('ElectricalSeries'). ...
data(1:5, 1:10)
ans = 5×10
0.1819 -0.2465 0.6816 1.3952 0.4457 0.1669 1.5490 1.6078 0.3151 0.9513 -0.0743 -0.1750 1.0688 -1.5109 -0.9000 -0.2888 -0.7786 1.6026 -0.3550 -0.1655 -0.2510 -2.4219 1.8592 -1.4672 0.6872 0.3096 1.0881 0.7342 -1.4525 -0.6090 -0.4141 1.2920 0.9821 1.0815 1.3037 0.1962 1.4406 0.3505 1.0192 -0.4334 1.5505 1.1969 0.0549 1.2202 0.2010 -0.1484 0.0228 -0.4535 -0.5823 -0.0484
 
% You can use the getRow method of the table to load spike times of a specific unit.
% To get the values, unpack from the returned table.
nwb.units.getRow(1).spike_times{1}
ans = 19×1
0.0232 0.1476 0.2262 0.4041 0.4174 0.4817 0.4834 0.5164 0.5493 0.5517

Learn more!

See the API documentation to learn what data types are available.

MATLAB tutorials

Python tutorials

See our tutorials for more details about your data type:
Check out other tutorials that teach advanced NWB topics: