|
177 | 177 | experiment_description="I went on an adventure to reclaim vast treasures.", # optional |
178 | 178 | related_publications="DOI:10.1016/j.neuron.2016.12.011", # optional |
179 | 179 | ) |
180 | | -print(nwbfile) |
| 180 | +nwbfile |
181 | 181 |
|
182 | 182 | #################### |
183 | 183 | # .. note:: |
|
212 | 212 | # The fields in the :py:class:`~pynwb.file.Subject` object are all free-form text (any format will be valid), |
213 | 213 | # however it is recommended to follow particular conventions to help software tools interpret the data: |
214 | 214 | # |
215 | | -# * **age**: `ISO 8601 Duration format <https://en.wikipedia.org/wiki/ISO_8601#Durations>`_, e.g., ``"P90D"`` for 90 days old |
| 215 | +# * **age**: `ISO 8601 Duration format <https://en.wikipedia.org/wiki/ISO_8601#Durations>`_, e.g., ``"P90D"`` for 90 |
| 216 | +# days old |
216 | 217 | # * **species**: The formal Latin binomial nomenclature, e.g., ``"Mus musculus"``, ``"Homo sapiens"`` |
217 | 218 | # * **sex**: Single letter abbreviation, e.g., ``"F"`` (female), ``"M"`` (male), ``"U"`` (unknown), and ``"O"`` (other) |
218 | 219 | # |
219 | 220 | # Add the subject information to the :py:class:`~pynwb.file.NWBFile` |
220 | 221 | # by setting the ``subject`` field to the new :py:class:`~pynwb.file.Subject` object. |
221 | 222 |
|
222 | | -nwbfile.subject = Subject( |
| 223 | +subject = Subject( |
223 | 224 | subject_id="001", |
224 | 225 | age="P90D", |
225 | 226 | description="mouse 5", |
226 | 227 | species="Mus musculus", |
227 | 228 | sex="M", |
228 | 229 | ) |
229 | 230 |
|
| 231 | +nwbfile.subject = subject |
| 232 | +subject |
| 233 | + |
230 | 234 | #################### |
231 | 235 | # .. _basic_timeseries: |
232 | 236 | # |
|
254 | 258 | starting_time=0.0, |
255 | 259 | rate=1.0, |
256 | 260 | ) |
| 261 | +time_series_with_rate |
257 | 262 |
|
258 | 263 | #################### |
259 | 264 | # For irregularly sampled recordings, we need to provide the ``timestamps`` for the ``data``: |
|
265 | 270 | unit="m", |
266 | 271 | timestamps=timestamps, |
267 | 272 | ) |
| 273 | +time_series_with_timestamps |
268 | 274 |
|
269 | 275 | #################### |
270 | 276 | # :py:class:`~pynwb.base.TimeSeries` objects can be added directly to :py:class:`~pynwb.file.NWBFile` using: |
|
316 | 322 | # create fake data with shape (50, 2) |
317 | 323 | # the first dimension should always represent time |
318 | 324 | position_data = np.array([np.linspace(0, 10, 50), np.linspace(0, 8, 50)]).T |
319 | | -position_timestamps = np.linspace(0, 50) / 200 |
| 325 | +position_timestamps = np.linspace(0, 50).astype(float) / 200 |
320 | 326 |
|
321 | 327 | spatial_series_obj = SpatialSeries( |
322 | 328 | name="SpatialSeries", |
|
325 | 331 | timestamps=position_timestamps, |
326 | 332 | reference_frame="(0,0) is bottom left corner", |
327 | 333 | ) |
328 | | -print(spatial_series_obj) |
| 334 | +spatial_series_obj |
329 | 335 |
|
330 | 336 | #################### |
331 | 337 | # To help data analysis and visualization tools know that this :py:class:`~pynwb.behavior.SpatialSeries` object |
332 | 338 | # represents the position of the subject, store the :py:class:`~pynwb.behavior.SpatialSeries` object inside |
333 | | -# of a :py:class:`~pynwb.behavior.Position` object, which can hold one or more :py:class:`~pynwb.behavior.SpatialSeries` objects. |
| 339 | +# of a :py:class:`~pynwb.behavior.Position` object, which can hold one or more :py:class:`~pynwb.behavior.SpatialSeries` |
| 340 | +# objects. |
334 | 341 | # |
335 | 342 | # .. only:: html |
336 | 343 | # |
|
350 | 357 |
|
351 | 358 | # name is set to "Position" by default |
352 | 359 | position_obj = Position(spatial_series=spatial_series_obj) |
| 360 | +position_obj |
353 | 361 |
|
354 | 362 | #################### |
355 | 363 | # Behavior Processing Module |
|
395 | 403 | # Once the behavior processing module is added to the :py:class:`~pynwb.file.NWBFile`, |
396 | 404 | # you can access it with: |
397 | 405 |
|
398 | | -print(nwbfile.processing["behavior"]) |
| 406 | +nwbfile.processing["behavior"] |
399 | 407 |
|
400 | 408 | #################### |
401 | 409 | # .. _basic_writing: |
|
559 | 567 | # :py:class:`~hdmf.common.table.DynamicTable` and its subclasses can be converted to a pandas |
560 | 568 | # :py:class:`~pandas.DataFrame` for convenient analysis using :py:meth:`.DynamicTable.to_dataframe`. |
561 | 569 |
|
562 | | -print(nwbfile.trials.to_dataframe()) |
| 570 | +nwbfile.trials.to_dataframe() |
563 | 571 |
|
564 | 572 | #################### |
565 | 573 | # .. _basic_epochs: |
|
587 | 595 | timeseries=[time_series_with_timestamps], |
588 | 596 | ) |
589 | 597 |
|
| 598 | +nwbfile.epochs.to_dataframe() |
| 599 | + |
590 | 600 | #################### |
591 | 601 | # Other time intervals |
592 | 602 | # ^^^^^^^^^^^^^^^^^^^^ |
|
0 commit comments