|
14 | 14 | 'general_related_publications', 'DOI:10.1016/j.neuron.2016.12.011'); % optional
|
15 | 15 | nwb
|
16 | 16 | %% SpatialSeries: Storing continuous spatial data
|
17 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
18 |
| -% |SpatialSeries|> is a subclass of <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeSeries.html |
| 17 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
| 18 | +% |SpatialSeries|> is a subclass of <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/TimeSeries.html |
19 | 19 | % |TimeSeries|> that represents data in space, such as the spatial direction e.g.,
|
20 | 20 | % of gaze or travel or position of an animal over time.
|
21 | 21 | %
|
22 | 22 | % Create data that corresponds to x, y position over time.
|
23 | 23 |
|
24 | 24 | position_data = [linspace(0, 10, 50); linspace(0, 8, 50)]; % 2 x nT array
|
25 | 25 | %%
|
26 |
| -% In <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
| 26 | +% In <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
27 | 27 | % |SpatialSeries|> data, the first dimension is always time (in seconds), the
|
28 | 28 | % second dimension represents the x, y position. However, as described in the
|
29 |
| -% <https://neurodatawithoutborders.github.io/matnwb/tutorials/html/dimensionMapNoDataPipes.html |
30 |
| -% dimensionMapNoDataPipes> tutorial, when a MATLAB array is exported to HDF5, |
31 |
| -% the array is transposed. Therefore, in order to correctly export the data, in |
32 |
| -% MATLAB the last dimension of an array should be time. <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
| 29 | +% <./dimensionMapNoDataPipes.mlx dimensionMapNoDataPipes> tutorial, when a MATLAB |
| 30 | +% array is exported to HDF5, the array is transposed. Therefore, in order to correctly |
| 31 | +% export the data, in MATLAB the last dimension of an array should be time. <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
33 | 32 | % |SpatialSeries|> data should be stored as one continuous stream as it is acquired,
|
34 | 33 | % not by trials as is often reshaped for analysis. Data can be trial-aligned on-the-fly
|
35 | 34 | % using the trials table. See the trials tutorial for further information.
|
|
44 | 43 | 'data', position_data, ...
|
45 | 44 | 'timestamps', timestamps, ...
|
46 | 45 | 'reference_frame', '(0,0) is the bottom left corner.' ...
|
47 |
| -) |
| 46 | + ) |
48 | 47 | %% Position: Storing position measured over time
|
49 |
| -% To help data analysis and visualization tools know that this <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
50 |
| -% |SpatialSeries|> object represents the position of the subject, store the <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
51 |
| -% |SpatialSeries|> object inside a <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/Position.html |
52 |
| -% |Position|> object, which can hold one or more <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
| 48 | +% To help data analysis and visualization tools know that this <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
| 49 | +% |SpatialSeries|> object represents the position of the subject, store the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
| 50 | +% |SpatialSeries|> object inside a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/Position.html |
| 51 | +% |Position|> object, which can hold one or more <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
53 | 52 | % |SpatialSeries|> objects.
|
54 | 53 |
|
55 | 54 | position = types.core.Position();
|
56 | 55 | position.spatialseries.set('SpatialSeries', position_spatial_series);
|
57 | 56 | %% Create a Behavior Processing Module
|
58 | 57 | % Create a processing module called "behavior" for storing behavioral data in
|
59 |
| -% the NWBFile, then add the <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/Position.html |
| 58 | +% the NWBFile, then add the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/Position.html |
60 | 59 | % |Position|> object to the processing module.
|
61 | 60 |
|
62 | 61 | behavior_processing_module = types.core.ProcessingModule('description', 'stores behavioral data.');
|
63 | 62 | behavior_processing_module.nwbdatainterface.set("Position", position);
|
64 | 63 | nwb.processing.set("behavior", behavior_processing_module);
|
65 | 64 | %% CompassDirection: Storing view angle measured over time
|
66 |
| -% Analogous to how position can be stored, we can create a <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
| 65 | +% Analogous to how position can be stored, we can create a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
67 | 66 | % |SpatialSeries|> object for representing the view angle of the subject.
|
68 | 67 | %
|
69 | 68 | % For direction data |reference_frame| indicates the zero direction, for instance
|
|
76 | 75 | 'timestamps', timestamps, ...
|
77 | 76 | 'reference_frame', 'straight ahead', ...
|
78 | 77 | 'data_unit', 'radians' ...
|
79 |
| -); |
| 78 | + ); |
80 | 79 | direction = types.core.CompassDirection();
|
81 | 80 | direction.spatialseries.set('spatial_series', direction_spatial_series);
|
82 | 81 | %%
|
83 |
| -% We can add a <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/CompassDirection.html |
| 82 | +% We can add a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/CompassDirection.html |
84 | 83 | % |CompassDirection|> object to the behavior processing module the same way we
|
85 | 84 | % have added the position data.
|
86 | 85 |
|
87 | 86 | %behavior_processing_module = types.core.ProcessingModule("stores behavioral data."); % if you have not already created it
|
88 | 87 | behavior_processing_module.nwbdatainterface.set('CompassDirection', direction);
|
89 | 88 | %nwb.processing.set('behavior', behavior_processing_module); % if you have not already added it
|
90 | 89 | %% BehaviorTimeSeries: Storing continuous behavior data
|
91 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralTimeSeries.html |
| 90 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralTimeSeries.html |
92 | 91 | % |BehavioralTimeSeries|> is an interface for storing continuous behavior data,
|
93 | 92 | % such as the speed of a subject.
|
94 | 93 |
|
|
100 | 99 | 'starting_time_rate', 10.0, ... % Hz
|
101 | 100 | 'description', 'he speed of the subject measured over time.', ...
|
102 | 101 | 'data_unit', 'm/s' ...
|
103 |
| -); |
| 102 | + ); |
104 | 103 |
|
105 | 104 | behavioral_time_series = types.core.BehavioralTimeSeries();
|
106 | 105 | behavioral_time_series.timeseries.set('speed', speed_time_series);
|
|
109 | 108 | behavior_processing_module.nwbdatainterface.set('BehavioralTimeSeries', behavioral_time_series);
|
110 | 109 | %nwb.processing.set('behavior', behavior_processing_module); % if you have not already added it
|
111 | 110 | %% BehavioralEvents: Storing behavioral events
|
112 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralEvents.html |
| 111 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralEvents.html |
113 | 112 | % |BehavioralEvents|> is an interface for storing behavioral events. We can use
|
114 | 113 | % it for storing the timing and amount of rewards (e.g. water amount) or lever
|
115 | 114 | % press times.
|
|
122 | 121 | 'timestamps', event_timestamps, ...
|
123 | 122 | 'description', 'The water amount the subject received as a reward.', ...
|
124 | 123 | 'data_unit', 'ml' ...
|
125 |
| -); |
| 124 | + ); |
126 | 125 |
|
127 | 126 | behavioral_events = types.core.BehavioralEvents();
|
128 | 127 | behavioral_events.timeseries.set('lever_presses', time_series);
|
|
136 | 135 | % extension. You can find information about installation and example usage <https://github.com/nwb-extensions/ndx-events-record
|
137 | 136 | % here>.
|
138 | 137 | %% BehavioralEpochs: Storing intervals of behavior data
|
139 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralEpochs.html |
140 |
| -% |BehavioralEpochs|> is for storing intervals of behavior data. <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralEpochs.html |
141 |
| -% |BehavioralEpochs|> uses <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/IntervalSeries.html |
142 |
| -% |IntervalSeries|> to represent the time intervals. Create an <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/IntervalSeries.html |
| 138 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralEpochs.html |
| 139 | +% |BehavioralEpochs|> is for storing intervals of behavior data. <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralEpochs.html |
| 140 | +% |BehavioralEpochs|> uses <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/IntervalSeries.html |
| 141 | +% |IntervalSeries|> to represent the time intervals. Create an <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/IntervalSeries.html |
143 | 142 | % |IntervalSeries|> object that represents the time intervals when the animal
|
144 | 143 | % was running. IntervalSeries uses 1 to indicate the beginning of an interval
|
145 | 144 | % and -1 to indicate the end.
|
|
148 | 147 | 'description', 'Intervals when the animal was running.', ...
|
149 | 148 | 'data', [1, -1, 1, -1, 1, -1], ...
|
150 | 149 | 'timestamps', [0.5, 1.5, 3.5, 4.0, 7.0, 7.3] ...
|
151 |
| -); |
| 150 | + ); |
152 | 151 |
|
153 | 152 | behavioral_epochs = types.core.BehavioralEpochs();
|
154 | 153 | behavioral_epochs.intervalseries.set('running', run_intervals);
|
155 | 154 | %%
|
156 |
| -% You can add more than one <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/IntervalSeries.html |
157 |
| -% |IntervalSeries|> to a <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralEpochs.html |
| 155 | +% You can add more than one <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/IntervalSeries.html |
| 156 | +% |IntervalSeries|> to a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralEpochs.html |
158 | 157 | % |BehavioralEpochs|> object.
|
159 | 158 |
|
160 | 159 | sleep_intervals = types.core.IntervalSeries( ...
|
161 | 160 | 'description', 'Intervals when the animal was sleeping', ...
|
162 | 161 | 'data', [1, -1, 1, -1], ...
|
163 | 162 | 'timestamps', [15.0, 30.0, 60.0, 95.0] ...
|
164 |
| -); |
| 163 | + ); |
165 | 164 | behavioral_epochs.intervalseries.set('sleeping', sleep_intervals);
|
166 | 165 |
|
167 | 166 | % behavior_processing_module = types.core.ProcessingModule("stores behavioral data.");
|
168 | 167 | % behavior_processing_module.nwbdatainterface.set('BehavioralEvents', behavioral_events);
|
169 | 168 | % nwb.processing.set('behavior', behavior_processing_module);
|
170 | 169 | % Another approach: TimeIntervals
|
171 |
| -% Using <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeIntervals.html |
172 |
| -% |TimeIntervals|> to represent time intervals is often preferred over <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/BehavioralEpochs.html |
173 |
| -% |BehavioralEpochs|> and <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/IntervalSeries.html |
174 |
| -% |IntervalSeries|>. <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeIntervals.html |
175 |
| -% |TimeIntervals|> is a subclass of <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+hdmf_common/DynamicTable.html |
| 170 | +% Using <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/TimeIntervals.html |
| 171 | +% |TimeIntervals|> to represent time intervals is often preferred over <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/BehavioralEpochs.html |
| 172 | +% |BehavioralEpochs|> and <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/IntervalSeries.html |
| 173 | +% |IntervalSeries|>. <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/TimeIntervals.html |
| 174 | +% |TimeIntervals|> is a subclass of <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html |
176 | 175 | % |DynamicTable|>, which offers flexibility for tabular data by allowing the addition
|
177 | 176 | % of optional columns which are not defined in the standard DynamicTable class.
|
178 | 177 |
|
179 | 178 | sleep_intervals = types.core.TimeIntervals( ...
|
180 | 179 | 'description', 'Intervals when the animal was sleeping.', ...
|
181 | 180 | 'colnames', {'start_time', 'stop_time', 'stage'} ...
|
182 |
| -); |
| 181 | + ); |
183 | 182 |
|
184 | 183 | sleep_intervals.addRow('start_time', 0.3, 'stop_time', 0.35, 'stage', 1);
|
185 | 184 | sleep_intervals.addRow('start_time', 0.7, 'stop_time', 0.9, 'stage', 2);
|
186 | 185 | sleep_intervals.addRow('start_time', 1.3, 'stop_time', 3.0, 'stage', 3);
|
187 | 186 |
|
188 | 187 | nwb.intervals.set('sleep_intervals', sleep_intervals);
|
189 | 188 | %% EyeTracking: Storing continuous eye-tracking data of gaze direction
|
190 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/EyeTracking.html |
| 189 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/EyeTracking.html |
191 | 190 | % |EyeTracking|> is for storing eye-tracking data which represents direction of
|
192 |
| -% gaze as measured by an eye tracking algorithm. An <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/EyeTracking.html |
193 |
| -% |EyeTracking|> object holds one or more <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/SpatialSeries.html |
| 191 | +% gaze as measured by an eye tracking algorithm. An <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/EyeTracking.html |
| 192 | +% |EyeTracking|> object holds one or more <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/SpatialSeries.html |
194 | 193 | % |SpatialSeries|> objects that represent the gaze direction over time extracted
|
195 | 194 | % from a video.
|
196 | 195 |
|
|
203 | 202 | 'starting_time_rate', 50.0, ... % Hz
|
204 | 203 | 'reference_frame', '(0,0) is middle', ...
|
205 | 204 | 'data_unit', 'degrees' ...
|
206 |
| -); |
| 205 | + ); |
207 | 206 |
|
208 | 207 | left_eye_position = types.core.SpatialSeries( ...
|
209 | 208 | 'description', 'The position of the right eye measured in degrees.', ...
|
|
212 | 211 | 'starting_time_rate', 50.0, ... % Hz
|
213 | 212 | 'reference_frame', '(0,0) is middle', ...
|
214 | 213 | 'data_unit', 'degrees' ...
|
215 |
| -); |
| 214 | + ); |
216 | 215 |
|
217 | 216 | eye_tracking = types.core.EyeTracking();
|
218 | 217 | eye_tracking.spatialseries.set('right_eye_position', right_eye_position);
|
|
222 | 221 | behavior_processing_module.nwbdatainterface.set('EyeTracking', eye_tracking);
|
223 | 222 | % nwb.processing.set('behavior', behavior_processing_module);
|
224 | 223 | %% PupilTracking: Storing continuous eye-tracking data of pupil size
|
225 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/PupilTracking.html |
| 224 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/PupilTracking.html |
226 | 225 | % |PupilTracking|> is for storing eye-tracking data which represents pupil size.
|
227 |
| -% <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/PupilTracking.html |
228 |
| -% |PupilTracking|> holds one or more <https://neurodatawithoutborders.github.io/matnwb/doc/+types/+core/TimeSeries.html |
| 226 | +% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/PupilTracking.html |
| 227 | +% |PupilTracking|> holds one or more <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/core/TimeSeries.html |
229 | 228 | % |TimeSeries|> objects that can represent different features such as the dilation
|
230 | 229 | % of the pupil measured over time by a pupil tracking algorithm.
|
231 | 230 |
|
|
235 | 234 | 'starting_time', 1.0, ... % NB: Important to set starting_time when using starting_time_rate
|
236 | 235 | 'starting_time_rate', 20.0, ... % Hz
|
237 | 236 | 'data_unit', 'meters' ...
|
238 |
| -); |
| 237 | + ); |
239 | 238 |
|
240 | 239 | pupil_tracking = types.core.PupilTracking();
|
241 | 240 | pupil_tracking.timeseries.set('pupil_diameter', pupil_diameter);
|
|
245 | 244 | % nwb.processing.set('behavior', behavior_processing_module);
|
246 | 245 | %% Writing the behavior data to an NWB file
|
247 | 246 | % All of the above commands build an NWBFile object in-memory. To write this
|
248 |
| -% file, use <https://neurodatawithoutborders.github.io/matnwb/doc/nwbExport.html |
249 |
| -% |nwbExport|>|.| |
| 247 | +% file, use <https://matnwb.readthedocs.io/en/latest/pages/functions/nwbExport.html |
| 248 | +% |nwbExport|>. |
250 | 249 |
|
251 | 250 | % Save to tutorials/tutorial_nwb_files folder
|
252 | 251 | nwbFilePath = misc.getTutorialNwbFilePath('behavior_tutorial.nwb');
|
|
0 commit comments