trials = types.core.TimeIntervals( ...
'colnames', {'start_time', 'stop_time', 'correct'}, ...
'description', 'trial data and properties');
trials.addRow('start_time', 0.1, 'stop_time', 1.0, 'correct', false)
trials.addRow('start_time', 1.5, 'stop_time', 2.0, 'correct', true)
trials.addRow('start_time', 2.5, 'stop_time', 3.0, 'correct', false)
trials.toTable() % visualize the table
ans = 3×4 table
| id | start_time | stop_time | correct |
---|
1 | 0 | 0.1000 | 1 | 0 |
---|
2 | 1 | 1.5000 | 2 | 1 |
---|
3 | 2 | 2.5000 | 3 | 0 |
---|
nwb.intervals_trials = trials;
% If you have multiple trials tables, you will need to use custom names for
nwb.intervals.set('custom_intervals_table_name', trials);
read_spatial_series.data.load
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091 1.0101 1.1111 1.2121 1.3131 1.4141 1.5152 1.6162 1.7172 1.8182 1.9192 2.0202 2.1212 2.2222 2.3232 2.4242 2.5253 2.6263 2.7273 2.8283 2.9293 3.0303 3.1313 3.2323 3.3333 3.4343 3.5354 3.6364 3.7374 3.8384 3.9394 4.0404 4.1414 4.2424 4.3434 4.4444 4.5455 4.6465 4.7475 4.8485 4.9495
+
This allows you to conveniently work with datasets that are too large to fit in RAM all at once. Access all the data in the matrix using the load method with no arguments.
read_spatial_series.data.load
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091 1.0101 1.1111 1.2121 1.3131 1.4141 1.5152 1.6162 1.7172 1.8182 1.9192 2.0202 2.1212 2.2222 2.3232 2.4242 2.5253 2.6263 2.7273 2.8283 2.9293 3.0303 3.1313 3.2323 3.3333 3.4343 3.5354 3.6364 3.7374 3.8384 3.9394 4.0404 4.1414 4.2424 4.3434 4.4444 4.5455 4.6465 4.7475 4.8485 4.9495
0 0.0808 0.1616 0.2424 0.3232 0.4040 0.4848 0.5657 0.6465 0.7273 0.8081 0.8889 0.9697 1.0505 1.1313 1.2121 1.2929 1.3737 1.4545 1.5354 1.6162 1.6970 1.7778 1.8586 1.9394 2.0202 2.1010 2.1818 2.2626 2.3434 2.4242 2.5051 2.5859 2.6667 2.7475 2.8283 2.9091 2.9899 3.0707 3.1515 3.2323 3.3131 3.3939 3.4747 3.5556 3.6364 3.7172 3.7980 3.8788 3.9596
-
If you only need a section of the data, you can read only that section by indexing the DataStub object like a normal array in MATLAB. This will just read the selected region from disk into RAM. This technique is particularly useful if you are dealing with a large dataset that is too big to fit entirely into your available RAM.
read_spatial_series.data(:, 1:10)
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091
+
If you only need a section of the data, you can read only that section by indexing the DataStub object like a normal array in MATLAB. This will just read the selected region from disk into RAM. This technique is particularly useful if you are dealing with a large dataset that is too big to fit entirely into your available RAM.
read_spatial_series.data(:, 1:10)
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091
0 0.0808 0.1616 0.2424 0.3232 0.4040 0.4848 0.5657 0.6465 0.7273
Next Steps
This concludes the introductory tutorial. Please proceed to one of the specialized tutorials, which are designed to follow this one.
@@ -256,13 +256,13 @@
% followed by value. Ellipses are used for clarity.
nwb = NwbFile( ...
- 'session_description', 'mouse in open exploration',...
- 'identifier', 'Mouse5_Day3', ...
- 'session_start_time', datetime(2018, 4, 25, 2, 30, 3, 'TimeZone', 'local'), ...
- 'general_experimenter', 'Last, First', ... % 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
+ session_description='mouse in open exploration',...
+ identifier='Mouse5_Day3', ...
+ session_start_time=datetime(2018, 4, 25, 2, 30, 3, 'TimeZone', 'local'), ...
+ general_experimenter='Last, First', ... % 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
%% Subject Information
% You can also provide information about your subject in the NWB file. Create
@@ -283,11 +283,11 @@
% * For |sex|, we recommend using F (female), M (male), U (unknown), and O (other)
subject = types.core.Subject( ...
- 'subject_id', '001', ...
- 'age', 'P90D', ...
- 'description', 'mouse 5', ...
- 'species', 'Mus musculus', ...
- 'sex', 'M' ...
+ subject_id='001', ...
+ age='P90D', ...
+ description='mouse 5', ...
+ species='Mus musculus', ...
+ sex='M' ...
);
nwb.general_subject = subject;
@@ -309,20 +309,20 @@
% and sampled every second (1 Hz):
time_series_with_rate = types.core.TimeSeries( ...
- 'description', 'an example time series', ...
- 'data', linspace(0, 100, 10), ...
- 'data_unit', 'm', ...
- 'starting_time', 0.0, ...
- 'starting_time_rate', 1.0);
+ description='an example time series', ...
+ data=linspace(0, 100, 10), ...
+ data_unit='m', ...
+ starting_time=0.0, ...
+ starting_time_rate=1.0);
%%
% For irregularly sampled recordings, we need to provide the |timestamps| for
% the |data|:
time_series_with_timestamps = types.core.TimeSeries( ...
- 'description', 'an example time series', ...
- 'data', linspace(0, 100, 10), ...
- 'data_unit', 'm', ...
- 'timestamps', linspace(0, 1, 10));
+ description='an example time series', ...
+ data=linspace(0, 100, 10), ...
+ data_unit='m', ...
+ timestamps=linspace(0, 1, 10));
%%
% The
class serves as the foundation for all other time series types
@@ -347,13 +347,13 @@
% Create an AnnotationSeries object with annotations for airpuff stimuli
annotations = types.core.AnnotationSeries( ...
- 'description', 'Airpuff events delivered to the animal', ...
- 'data', {'Left Airpuff', 'Right Airpuff', 'Right Airpuff'}, ...
- 'timestamps', [1.0, 3.0, 8.0] ...
+ description='Airpuff events delivered to the animal', ...
+ data={'Left Airpuff', 'Right Airpuff', 'Right Airpuff'}, ...
+ timestamps=[1.0, 3.0, 8.0] ...
);
% Add the AnnotationSeries to the NWBFile's stimulus group
-nwb.stimulus_presentation.set('Airpuffs', annotations)
+nwb.stimulus_presentation.set(Airpuffs=annotations)
%% Behavior
% SpatialSeries and Position
% Many types of data have special data types in NWB. To store the spatial position
@@ -383,10 +383,10 @@
% create SpatialSeries object
spatial_series_ts = types.core.SpatialSeries( ...
- 'data', [linspace(0,10,100); linspace(0,8,100)], ...
- 'reference_frame', '(0,0) is bottom left corner', ...
- 'starting_time', 0, ...
- 'starting_time_rate', 200 ...
+ data=[linspace(0,10,100); linspace(0,8,100)], ...
+ reference_frame='(0,0) is bottom left corner', ...
+ starting_time=0, ...
+ starting_time_rate=200 ...
);
% create Position object and add SpatialSeries
@@ -406,14 +406,14 @@
% |*Position*|> object to the module.
% create processing module
-behavior_module = types.core.ProcessingModule('description', 'contains behavioral data');
+behavior_module = types.core.ProcessingModule(description='contains behavioral data');
% add the Position object (that holds the SpatialSeries object) to the module
% and name the Position object "Position"
-behavior_module.nwbdatainterface.set('Position', position);
+behavior_module.nwbdatainterface.set(Position=position);
% add the processing module to the NWBFile object, and name the processing module "behavior"
-nwb.processing.set('behavior', behavior_module);
+nwb.processing.set(behavior=behavior_module);
% Trials
% Trials are stored in a object which is a subclass of class serves as the foundation for all other time series types
@@ -107,13 +107,13 @@
% Create an AnnotationSeries object with annotations for airpuff stimuli
annotations = types.core.AnnotationSeries( ...
- 'description', 'Airpuff events delivered to the animal', ...
- 'data', {'Left Airpuff', 'Right Airpuff', 'Right Airpuff'}, ...
- 'timestamps', [1.0, 3.0, 8.0] ...
+ description='Airpuff events delivered to the animal', ...
+ data={'Left Airpuff', 'Right Airpuff', 'Right Airpuff'}, ...
+ timestamps=[1.0, 3.0, 8.0] ...
);
% Add the AnnotationSeries to the NWBFile's stimulus group
-nwb.stimulus_presentation.set('Airpuffs', annotations)
+nwb.stimulus_presentation.set(Airpuffs=annotations)
%% Behavior
% SpatialSeries and Position
% Many types of data have special data types in NWB. To store the spatial position
@@ -143,10 +143,10 @@
% create SpatialSeries object
spatial_series_ts = types.core.SpatialSeries( ...
- 'data', [linspace(0,10,100); linspace(0,8,100)], ...
- 'reference_frame', '(0,0) is bottom left corner', ...
- 'starting_time', 0, ...
- 'starting_time_rate', 200 ...
+ data=[linspace(0,10,100); linspace(0,8,100)], ...
+ reference_frame='(0,0) is bottom left corner', ...
+ starting_time=0, ...
+ starting_time_rate=200 ...
);
% create Position object and add SpatialSeries
@@ -166,14 +166,14 @@
% |*Position*|> object to the module.
% create processing module
-behavior_module = types.core.ProcessingModule('description', 'contains behavioral data');
+behavior_module = types.core.ProcessingModule(description='contains behavioral data');
% add the Position object (that holds the SpatialSeries object) to the module
% and name the Position object "Position"
-behavior_module.nwbdatainterface.set('Position', position);
+behavior_module.nwbdatainterface.set(Position=position);
% add the processing module to the NWBFile object, and name the processing module "behavior"
-nwb.processing.set('behavior', behavior_module);
+nwb.processing.set(behavior=behavior_module);
% Trials
% Trials are stored in a object which is a subclass of