-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathdynamic_tables.html
More file actions
627 lines (577 loc) · 162 KB
/
dynamic_tables.html
File metadata and controls
627 lines (577 loc) · 162 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB 2024b"><title>DynamicTables Tutorial</title><link rel="stylesheet" href="css/livescript.css">
<style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(192, 76, 11); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left; }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; }
.S2 { margin-bottom: 20px; padding-bottom: 4px; }
.S3 { margin: 0px; padding: 10px 0px 10px 5px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 700; text-align: start; }
.S4 { margin: -1px 0px 0px; padding: 10px 0px 10px 7px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: start; }
.S5 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; }
.CodeBlock { background-color: #F5F5F5; margin: 10px 15px 10px 0; display: inline-block }
.S6 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 1px solid rgb(217, 217, 217); border-bottom: 0px none rgb(33, 33, 33); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S7 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 0px none rgb(33, 33, 33); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S8 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S9 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; }
.eoOutputWrapper { width: calc(90vw - 10px) !important; }
.S10 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S11 { color: rgb(33, 33, 33); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px; }
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsErrorElement { min-height: 18px; max-height: 550px;}
.embeddedOutputsErrorElement .diagnosticMessage-errorType { overflow: auto;}
.embeddedOutputsErrorElement.activeOutput .eoOutputContent { user-select: text; -webkit-user-select: text;}
.embeddedOutputsErrorElement.activeOutput .eoOutputContent button { user-select: none; -webkit-user-select: none;}
.embeddedOutputsErrorElement .eoOutputContent ::selection {}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsWarningElement { min-height: 18px; max-height: 550px;}
.embeddedOutputsWarningElement .diagnosticMessage-warningType { overflow: auto;}
.embeddedOutputsWarningElement.activeOutput .eoOutputContent { user-select: text; -webkit-user-select: text;}
.embeddedOutputsWarningElement .eoOutputContent ::selection {}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
/* Copyright 2015-2023 The MathWorks, Inc. *//* In this file, styles are not scoped to rtcContainer since they could be in the Dojo Tooltip */.diagnosticMessage-wrapper { font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType { /*This fallback value will be used for appdesigner warnings*/ color: var(--rtc-warning-output-color, var(--mw-color-matlabWarning));}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a { /*This fallback value will be used for appdesigner warnings*/ color: var(--rtc-warning-output-color, var(--mw-color-matlabWarning)); text-decoration: underline;}
.rtcThemeDefaultOverride .diagnosticMessage-wrapper.diagnosticMessage-warningType,.rtcThemeDefaultOverride .diagnosticMessage-wrapper.diagnosticMessage-warningType a { color: var(--mw-color-matlabWarning) !important;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType { /*This fallback value will be used in appdesigner error tooltip text*/ color: var(--rtc-error-output-color, var(--mw-color-matlabErrors));}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a { /*This fallback value will be used in appdesigner error tooltip text*/ color: var(--rtc-error-output-color, var(--mw-color-matlabErrors)); text-decoration: underline;}
.rtcThemeDefaultOverride .diagnosticMessage-wrapper.diagnosticMessage-errorType,.rtcThemeDefaultOverride .diagnosticMessage-wrapper.diagnosticMessage-errorType a { color: var(--mw-color-matlabErrors) !important;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart { white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart { white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement { white-space: pre; word-wrap: initial; min-height: 18px; max-height: 550px;}
.embeddedOutputsTextElement .textElement,.embeddedOutputsVariableStringElement .textElement { overflow: auto;}
.embeddedOutputsTextElement.activeOutput .eoOutputContent,.embeddedOutputsVariableStringElement.activeOutput .eoOutputContent { user-select: text; -webkit-user-select: text;}
/*embeddedOutputsTextElement has a different dom structure than embeddedOutputsVariableStringElement.Unlike variableString, the text output has both TEXT nodes and elements as children. Hence we needa selector for each.*/.embeddedOutputsTextElement .eoOutputContent::selection,.embeddedOutputsTextElement .eoOutputContent ::selection,.embeddedOutputsVariableStringElement .eoOutputContent ::selection {}
.textElement,.rtcDataTipElement .textElement { padding-top: 2px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement { min-height: 16px;}
.rightPaneElement .textElement { padding-top: 2px; padding-left: 9px;}
.S12 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 1px solid rgb(217, 217, 217); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S13 { margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; }
.embeddedOutputsVariableTableElement .ClientViewDiv table tr { height: 22px; white-space: nowrap;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr td,.embeddedOutputsVariableTableElement .ClientViewDiv table tr th { background-color:white; text-overflow: ellipsis; font-family: 'Arial', sans-serif; font-size: 12px; overflow : hidden;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr span { text-overflow: ellipsis; padding: 3px;}
.embeddedOutputsVariableTableElement .ClientViewDiv table tr th { color: rgba(0,0,0,0.5); padding: 3px; font-size: 9px;}
/* ClientDocument has a summary bar child that takes up 17px, this clashes with overflow on the view which allots space for scrollbars. On print preview, this causes headers from <thead> to overlap on subsequent pages. Displaying Document as flex renders summarybar and view in column format and fixes the issue g2788485 */.embeddedOutputsVariableTableElement .ClientDocument { display: flex; flex-direction: column;}
.S14 { border-left: 1px solid rgb(217, 217, 217); border-right: 1px solid rgb(217, 217, 217); border-top: 1px solid rgb(217, 217, 217); border-bottom: 1px solid rgb(217, 217, 217); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; }
.S15 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; }
.embeddedOutputsMatrixElement,.eoOutputWrapper .matrixElement { min-height: 18px; box-sizing: border-box;}
.embeddedOutputsMatrixElement .matrixElement,.eoOutputWrapper .matrixElement,.rtcDataTipElement .matrixElement { position: relative;}
.matrixElement .variableValue,.rtcDataTipElement .matrixElement .variableValue { white-space: pre; display: inline-block; vertical-align: top; overflow: hidden;}
.embeddedOutputsMatrixElement.inlineElement {}
.embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper { display: none;}
.embeddedOutputsMatrixElement.inlineElement .veTable .body { padding-top: 0 !important; max-height: 100px;}
.inlineElement .matrixElement { max-height: 300px;}
.embeddedOutputsMatrixElement.rightPaneElement {}
.rightPaneElement .matrixElement,.rtcDataTipElement .matrixElement { overflow: hidden; padding-left: 9px;}
.rightPaneElement .matrixElement { margin-bottom: -1px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer,.eoOutputWrapper .matrixElement .valueContainer,.rtcDataTipElement .matrixElement .valueContainer { white-space: nowrap; margin-bottom: 3px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis.hide,.eoOutputWrapper .matrixElement .verticalEllipsis.hide,.rtcDataTipElement .matrixElement .valueContainer .horizontalEllipsis.hide,.rtcDataTipElement .matrixElement .verticalEllipsis.hide { display: none;}
.embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .verticalEllipsis, .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .horizontalEllipsis { display:none;}
.eoOutputWrapper .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer { cursor: default !important;}
.embeddedOutputsVariableElement { white-space: pre-wrap; word-wrap: break-word; min-height: 18px; max-height: 250px; overflow: auto;}
.eoOutputWrapper .variableElement { padding-top: 2px;}
.embeddedOutputsVariableElement.inlineElement {}
.inlineElement .variableElement {}
.embeddedOutputsVariableElement.rightPaneElement { min-height: 16px;}
.rightPaneElement .variableElement { padding-left: 9px;}
.outputsOnRight .embeddedOutputsVariableElement.rightPaneElement .eoOutputContent { /* Remove extra space allocated for navigation border */ margin-top: 0; margin-bottom: 0;}
.variableNameElement { margin-bottom: 3px; display: inline-block;}
/* * Ellipses as base64 for HTML export. */.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis { display: inline-block; margin-top: 3px; /* base64 encoded version of images-liveeditor/HEllipsis.png */ width: 30px; height: 12px; background-repeat: no-repeat; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAJCAYAAADO1CeCAAAAJUlEQVR42mP4//8/A70xw0i29BUDFPxnAEtTW37wWDqakIa4pQDvOOG89lHX2gAAAABJRU5ErkJggg==");}
.matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis { margin-left: 35px; /* base64 encoded version of images-liveeditor/VEllipsis.png */ width: 12px; height: 30px; background-repeat: no-repeat; background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAZCAYAAAAIcL+IAAAALklEQVR42mP4//8/AzGYgWyFMECMwv8QddRS+P//KyimlmcGUOFoOI6GI/UVAgDnd8Dd4+NCwgAAAABJRU5ErkJggg==");}</style></head><body><div class = rtcContent><h1 class = 'S0' id = 'T_68fc' ><span>DynamicTables Tutorial</span></h1><div class = 'S1'><span>This is a user guide to interacting with</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> objects in MatNWB.</span></div><div class = 'S2'><div class = 'S3'><span style=' font-weight: bold;'>Table of Contents</span></div><div class = 'S4'><a href = "#H_1987"><span>MatNWB setup
</span></a><a href = "#H_869a"><span>Constructing a table with initialized columns
</span></a><a href = "#H_106f"><span>Adding rows
</span></a><a href = "#H_3afc"><span>Adding columns
</span></a><a href = "#H_8036"><span>Create MATLAB table and convert to dynamic table
</span></a><span> </span><a href = "#H_3663"><span>Adding rows
</span></a><span> </span><a href = "#H_34c1"><span>Adding variables (columns)
</span></a><span> </span><a href = "#H_6f53"><span>Convert to dynamic table
</span></a><a href = "#H_5ba4"><span>Enumerated (categorical) data
</span></a><span> </span><a href = "#H_7077"><span>Warning regarding EnumData
</span></a><a href = "#H_2d5c"><span>Ragged array columns
</span></a><span> </span><a href = "#H_4351"><span>Adding ragged array rows
</span></a><a href = "#H_5229"><span>Accessing row elements
</span></a><a href = "#H_0c2a"><span>Accessing column elements
</span></a><a href = "#H_520f"><span>Referencing rows of other tables
</span></a><a href = "#H_395d"><span>Converting a DynamicTable to a MATLAB table
</span></a><a href = "#H_0ea2"><span>Creating an expandable table
</span></a><a href = "#H_3cf3"><span>Multidimensional columns
</span></a><span> </span><a href = "#H_8545"><span>Constructing multidimensional columns
</span></a><span> </span><a href = "#H_1248"><span>Multidimensional ragged array columns
</span></a><span> </span><a href = "#H_9bac"><span>Adding rows to multidimensional array columns
</span></a><a href = "#H_42c6"><span>Learn more!
</span></a><span> </span><a href = "#H_8e0c"><span>Python Tutorial</span></a></div></div><h2 class = 'S5' id = 'H_1987' ><span style=' font-weight: bold;'>MatNWB setup</span></h2><div class = 'S1'><span>Start by setting up your MATLAB workspace. The code below adds the directory containing the MatNWB package to the MATLAB search path. MatNWB works by automatically creating API classes based on a defined schema.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">%{</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">path_to_matnwb = '~/Repositories/matnwb'; % change to your own path location</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">addpath(genpath(pwd));</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span style="color: #008013;">%}</span></span></div></div></div><h2 class = 'S9' id = 'H_869a' ><span>Constructing a table with initialized columns</span></h2><div class = 'S1'><span>The</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> class represents a column-based table to which you can add custom columns. It consists of a description, a list of columns , and a list of row IDs. You can create a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> by first defining the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> objects that will make up the columns of the table. Each</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> object must contain the same number of rows. A list of rows IDs may be passed to the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> using the id argument. Row IDs are a useful way to access row information independent of row location index. The list of row IDs must be cast as an</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html"><span style=' font-weight: bold;'>ElementIdentifiers</span></a><span> object before being passed to the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object. If no value is passed to id, an</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html"><span style=' font-weight: bold;'>ElementIdentifiers</span></a><span> object with 0-indexed row IDs will be created for you automatically.</span></div><div class = 'S1'><span style=' font-weight: bold;'>MATLAB Syntax Note</span><span>: Using column vectors is crucial to properly build vectors and tables. When defining individual values, make sure to use semi-colon (;) instead of instead of comma (,) when defining the data fields of these.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >col1 = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #1'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [1;2] </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >col2 = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #2'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, {</span><span style="color: #a709f5;">'a'</span><span >;</span><span style="color: #a709f5;">'b'</span><span >} </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >row_ids = types.hdmf_common.ElementIdentifiers(</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [0;1]); </span><span style="color: #008013;">% 0-indexed, for compatibility with Python</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >my_table = types.hdmf_common.DynamicTable( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'an example table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, {</span><span style="color: #a709f5;">'col1'</span><span >, </span><span style="color: #a709f5;">'col2'</span><span >}, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'col1'</span><span >, col1, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'col2'</span><span >, col2, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, row_ids </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper outputs"><div class = 'S10'><span style="white-space: pre"><span >my_table</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableStringElement" uid="E88684E0" prevent-scroll="true" data-testid="output_0" tabindex="-1" style="width: 1137px; white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="textElement eoOutputContent" tabindex="-1" data-previous-available-width="1100" data-previous-scroll-height="108" data-hashorizontaloverflow="false" role="article" aria-roledescription="Use Browse Mode to explore " aria-description="variable output " style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;">my_table = </span></div><div style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"> DynamicTable with properties:
colnames: {'col1' 'col2'}
description: 'an example table'
id: [1×1 types.hdmf_common.ElementIdentifiers]
vectordata: [2×1 types.untyped.Set]
</div></div></div></div></div></div><h2 class = 'S9' id = 'H_106f' ><span>Adding rows</span></h2><div class = 'S1'><span>You can add rows to an existing</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> using the object's</span><span> </span><span style=' font-family: monospace;'>addRow</span><span> method. One way of using this method is to pass in the names of columns as parameter names followed by the elements to append. The class of the elements of the column must match the elements to append.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S12'><span style="white-space: pre"><span >my_table.addRow(</span><span style="color: #a709f5;">'col1'</span><span >, 3, </span><span style="color: #a709f5;">'col2'</span><span >, {</span><span style="color: #a709f5;">'c'</span><span >}, </span><span style="color: #a709f5;">'id'</span><span >, 2);</span></span></div></div></div><h2 class = 'S9' id = 'H_3afc' ><span>Adding columns</span></h2><div class = 'S1'><span>You can add new columns to an existing</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object using the</span><span> </span><span style=' font-family: monospace;'>addColumn</span><span> method. One way of using this method is to pass in the names of each new column followed by the corresponding values for each new column. The height of the new columns must match the height of the table.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >col3 = types.hdmf_common.VectorData(</span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #3'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [100; 200; 300]);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >col4 = types.hdmf_common.VectorData(</span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #4'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, {</span><span style="color: #a709f5;">'a1'</span><span >; </span><span style="color: #a709f5;">'b2'</span><span >; </span><span style="color: #a709f5;">'c3'</span><span >});</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >my_table.addColumn(</span><span style="color: #a709f5;">'col3'</span><span >, col3,</span><span style="color: #a709f5;">'col4'</span><span >, col4);</span></span></div></div></div><h2 class = 'S9' id = 'H_8036' ><span>Create MATLAB table and convert to dynamic table</span></h2><div class = 'S1'><span>As an alternative to building a dynamic table using the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> and</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> data types, it is also possible to create a MATLAB table and convert it to a dynamic table. Lets create the same table as before, but using MATLAB's table class:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">% Create a table with two variables (columns):</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >T = table([1;2], {</span><span style="color: #a709f5;">'a'</span><span >;</span><span style="color: #a709f5;">'b'</span><span >}, </span><span style="color: #a709f5;">'VariableNames'</span><span >, {</span><span style="color: #a709f5;">'col1'</span><span >, </span><span style="color: #a709f5;">'col2'</span><span >});</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >T.Properties.VariableDescriptions = {</span><span style="color: #a709f5;">'column #1'</span><span >, </span><span style="color: #a709f5;">'column #2'</span><span >};</span></span></div></div></div><h3 class = 'S13' id = 'H_3663' ><span>Adding rows</span></h3><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S12'><span style="white-space: pre"><span >T(end+1, :) = {3, </span><span style="color: #a709f5;">'c'</span><span >};</span></span></div></div></div><h3 class = 'S13' id = 'H_34c1' ><span>Adding variables (columns)</span></h3><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >T = addvars(T, [100;200;300], </span><span style="color: #a709f5;">'NewVariableNames'</span><span >,{</span><span style="color: #a709f5;">'col3'</span><span >});</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >T.Properties.VariableDescriptions{3} = </span><span style="color: #a709f5;">'column #3'</span><span >;</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Alternatively, a new variable can be added directly using dot syntax.</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >T.col4 = {</span><span style="color: #a709f5;">'a1'</span><span >; </span><span style="color: #a709f5;">'b2'</span><span >; </span><span style="color: #a709f5;">'c3'</span><span >};</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >T.Properties.VariableDescriptions{4} = </span><span style="color: #a709f5;">'column #4'</span><span >;</span></span></div></div><div class="inlineWrapper outputs"><div class = 'S10'><span style="white-space: pre"><span >T</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="954BD291" prevent-scroll="true" data-testid="output_1" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_0" widgetid="variableeditor_client_Document_0" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_0"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>T = </span><span style="color: rgb(179, 179, 179); font-style: normal;">3×4 table </span></div><div id="variableeditor_TableViewModel_0" widgetid="variableeditor_TableViewModel_0" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col2</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col3</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col4</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>100</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a1'</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>200</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b2'</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>3</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>3</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'c'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>300</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'c3'</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output starting with T =
col1 col2 col3 col4
____ _____ ____ ______
1 {'a'} 100"></div></div></div></div></div><h3 class = 'S13' id = 'H_6f53' ><span>Convert to dynamic table</span></h3><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >dynamic_table = util.table2nwb(T, </span><span style="color: #a709f5;">'A MATLAB table that was converted to a dynamic table'</span><span >)</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableStringElement" uid="9DAB9288" prevent-scroll="true" data-testid="output_2" tabindex="-1" style="width: 1137px; white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="textElement eoOutputContent" tabindex="-1" data-previous-available-width="1100" data-previous-scroll-height="108" data-hashorizontaloverflow="false" role="article" aria-roledescription="Use Browse Mode to explore " aria-description="variable output " style="max-height: 261px; white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><span class="variableNameElement" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;">dynamic_table = </span></div><div style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"> DynamicTable with properties:
colnames: {'col1' 'col2' 'col3' 'col4'}
description: "A MATLAB table that was converted to a dynamic table"
id: [1×1 types.hdmf_common.ElementIdentifiers]
vectordata: [4×1 types.untyped.Set]
</div></div></div></div></div></div><h2 class = 'S9' id = 'H_5ba4' ><span>Enumerated (categorical) data</span></h2><div class = 'S1'><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_experimental/EnumData.html"><span style=' font-weight: bold; font-family: monospace;'>EnumData</span></a><span> is a special type of column for storing an enumerated data type. This way each unique value is stored once, and the data references those values by index. Using this method is more efficient than storing a single value many times, and has the advantage of communicating to downstream tools that the data is categorical in nature.</span></div><h3 class = 'S13' id = 'H_7077' ><span>Warning regarding EnumData</span><span> </span></h3><div class = 'S1'><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_experimental/EnumData.html"><span style=' font-weight: bold; font-family: monospace;'>EnumData</span></a><span> is currently an experimental feature and as such should not be used in a production environment.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >cell_type_elements = types.hdmf_common.VectorData(</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'fixed set of elements referenced by cell_type'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, {</span><span style="color: #a709f5;">'aa'</span><span >, </span><span style="color: #a709f5;">'bb'</span><span >, </span><span style="color: #a709f5;">'cc'</span><span >} </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> % the enumerated elements</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >cell_type = types.hdmf_experimental.EnumData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'this column holds categorical variables'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [0; 1; 2; 1; 0], </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> % zero-indexed offset to elements.</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'elements'</span><span >, types.untyped.ObjectView(cell_type_elements) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >cell_type_table = types.hdmf_common.DynamicTable(</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'an example table with enum cell types'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">%Please note: the *_elements format is required for compatibility with pynwb:</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >cell_type_table.vectordata.set(</span><span style="color: #a709f5;">'cell_type_elements'</span><span >, cell_type_elements);</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >cell_type_table.addColumn(</span><span style="color: #a709f5;">'cell_type'</span><span >, cell_type);</span></span></div></div></div><h2 class = 'S9' id = 'H_2d5c' ><span>Ragged array columns</span></h2><div class = 'S1'><span>A table column with a different number of elements for each row is called a "ragged array column." To define a table with a ragged array column, pass both the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> and the corresponding</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span> as columns of the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object. The</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> columns will contain the data values. The</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span> column serves to indicate how to arrange the data across rows. By convention the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span> object corresponding to a particular column must have have the same name with the addition of the '_index' suffix.</span></div><div class = 'S1'><span>Below, the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span> values indicate to place the 1st to 3rd (inclusive) elements of the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> into the first row and 4th element into the second row. The resulting table will have the cell {'1a'; '1b'; '1c'} in the first row and the cell {'2a'} in the second row.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >col1 = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #1'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, {</span><span style="color: #a709f5;">'1a'</span><span >; </span><span style="color: #a709f5;">'1b'</span><span >; </span><span style="color: #a709f5;">'1c'</span><span >; </span><span style="color: #a709f5;">'2a'</span><span >} </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >col1_index = types.hdmf_common.VectorIndex( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'column #1 index'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'target'</span><span >,types.untyped.ObjectView(col1), </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> % object view of target column</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [3; 4] </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >row_ids = types.hdmf_common.ElementIdentifiers(</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [0; 1]); </span><span style="color: #008013;">% 0-indexed, for compatibility with Python</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >table_ragged_col = types.hdmf_common.DynamicTable( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'an example table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, {</span><span style="color: #a709f5;">'col1'</span><span >}, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'col1'</span><span >, col1, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'col1_index'</span><span >, col1_index, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, row_ids </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >);</span></span></div></div></div><h3 class = 'S13' id = 'H_4351' ><span>Adding ragged array rows</span></h3><div class = 'S1'><span>You can add a new row to the ragged array column. Under the hood, the </span><span style=' font-family: monospace;'>addRow</span><span> method will add the appropriate value to the </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span> column to maintain proper formatting.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S12'><span style="white-space: pre"><span >table_ragged_col.addRow(</span><span style="color: #a709f5;">'col1'</span><span >, {</span><span style="color: #a709f5;">'3a'</span><span >; </span><span style="color: #a709f5;">'3b'</span><span >; </span><span style="color: #a709f5;">'3c'</span><span >}, </span><span style="color: #a709f5;">'id'</span><span >, 2);</span></span></div></div></div><h2 class = 'S9' id = 'H_5229' ><span>Accessing row elements</span></h2><div class = 'S1'><span>You can access data from entire rows of a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object by calling the</span><span> </span><span style=' font-family: monospace;'>getRow</span><span> method for the corresponding object. You can supply either an individual row number or a list of row numbers.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >my_table.getRow(1)</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="FE1BF884" prevent-scroll="true" data-testid="output_3" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_1" widgetid="variableeditor_client_Document_1" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_1"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">1×4 table </span></div><div id="variableeditor_TableViewModel_1" widgetid="variableeditor_TableViewModel_1" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col2</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col3</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col4</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>100</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a1'</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output starting with ans =
col1 col2 col3 col4
____ _____ ____ ______
1 {'a'} "></div></div></div></div></div><div class = 'S15'><span>If you want to access values for just a subset of columns you can pass in the 'columns' argument along with a cell array with the desired column names</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >my_table.getRow(1:3, </span><span style="color: #a709f5;">'columns'</span><span >, {</span><span style="color: #a709f5;">'col1'</span><span >})</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="F7D495B2" prevent-scroll="true" data-testid="output_4" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_2" widgetid="variableeditor_client_Document_2" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_2"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">3×1 table </span></div><div id="variableeditor_TableViewModel_2" widgetid="variableeditor_TableViewModel_2" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>3</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>3</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output ans =
col1
____
1
2
3
"></div></div></div></div></div><div class = 'S15'><span>You can also access specific rows by their corresponding row ID's, if they have been defined, by supplying a 'true' Boolean to the 'useId' parameter</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >my_table.getRow(1, </span><span style="color: #a709f5;">'useId'</span><span >, true)</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="3C1A78C7" prevent-scroll="true" data-testid="output_5" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_3" widgetid="variableeditor_client_Document_3" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_3"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">1×4 table </span></div><div id="variableeditor_TableViewModel_3" widgetid="variableeditor_TableViewModel_3" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col2</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col3</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col4</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>200</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b2'</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output starting with ans =
col1 col2 col3 col4
____ _____ ____ ______
2 {'b'} "></div></div></div></div></div><div class = 'S15'><span>For a ragged array columns, the</span><span> </span><span style=' font-family: monospace;'>getRow</span><span> method will return a cell with different number of elements for each row</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >table_ragged_col.getRow(1:2)</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="2266836D" prevent-scroll="true" data-testid="output_6" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_4" widgetid="variableeditor_client_Document_4" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_4"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">2×1 table </span></div><div id="variableeditor_TableViewModel_4" widgetid="variableeditor_TableViewModel_4" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>3×1 cell</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>1×1 cell</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output ans =
col1
__________
{3×1 cell}
{1×1 cell}
"></div></div></div></div></div><h2 class = 'S9' id = 'H_0c2a' ><span>Accessing column elements</span></h2><div class = 'S1'><span>To access all rows from a particular column use the .get method on the vectordata field of the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >my_table.vectordata.get(</span><span style="color: #a709f5;">'col2'</span><span >).data</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsTextMatrixElement embeddedOutputsVariableMatrixElement" uid="B2B76D08" prevent-scroll="true" data-testid="output_7" data-width="1107" tabindex="-1" style="width: 1137px; white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="matrixElement veSpecifier saveLoad eoOutputContent" role="article" aria-roledescription="Use Browse Mode to explore " aria-description="variable output " style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="veVariableName variableNameElement" style="width: 1107px; white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="headerElementClickToInteract" style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><span style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;">ans = </span><span class="veVariableValueSummary headerElement" style="white-space: normal; font-style: italic; color: rgb(97, 97, 97); font-size: 12px;">3×1 cell</span></div></div><div class="valueContainer" data-layout="{"totalRows":3,"totalColumns":1}" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><div class="variableValue" style="width: 82px; white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;">'a' <br>'b' <br>'c' <br></div><div class="horizontalEllipsis hide" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><mw-icon icon-id="meatballMenuUI" icon-width="16" icon-height="16" icon-config="{}" svg-path="" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></mw-icon></div><div class="verticalEllipsis hide" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"><mw-icon icon-id="kebabMenuUI" icon-width="16" icon-height="16" icon-config="{}" svg-path="" style="white-space: pre; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></mw-icon></div></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true" style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true" style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true" style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output ans = 3×1 cell
'a'
'b'
'c'
" style="white-space: normal; font-style: normal; color: rgb(33, 33, 33); font-size: 12px;"></div></div></div></div></div><h2 class = 'S9' id = 'H_520f' ><span>Referencing rows of other tables</span></h2><div class = 'S1'><span>You can create a column that references rows of other tables by adding a</span><span> </span><a href = "file:///Users/cesar/Repositories/matnwb/doc/+types/+hdmf_common/DynamicTableRegion.html"><span style=' font-weight: bold;'>DynamicTableRegion</span></a><span> object as a column of a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span>. This is analogous to a foreign key in a relational database. The</span><span> </span><a href = "file:///Users/cesar/Repositories/matnwb/doc/+types/+hdmf_common/DynamicTableRegion.html"><span style=' font-weight: bold;'>DynamicTableRegion</span></a><span> class takes in an</span><span> </span><span style=' font-family: monospace;'>ObjectView</span><span> object as argument.</span><span> </span><span style=' font-family: monospace;'>ObjectView</span><span> objects create links from one object type referencing another.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >dtr_col = types.hdmf_common.DynamicTableRegion( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'references multiple rows of earlier table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [0; 1; 1; 0], </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> # 0-indexed</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'table'</span><span >,types.untyped.ObjectView(my_table) </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> % object view of target table</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >data_col = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'data column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, {</span><span style="color: #a709f5;">'a'</span><span >; </span><span style="color: #a709f5;">'b'</span><span >; </span><span style="color: #a709f5;">'c'</span><span >; </span><span style="color: #a709f5;">'d'</span><span >} </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >dtr_table = types.hdmf_common.DynamicTable( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'test table with DynamicTableRegion'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, {</span><span style="color: #a709f5;">'data_col'</span><span >, </span><span style="color: #a709f5;">'dtr_col'</span><span >}, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'dtr_col'</span><span >, dtr_col, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data_col'</span><span >,data_col, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >,types.hdmf_common.ElementIdentifiers(</span><span style="color: #a709f5;">'data'</span><span >, [0; 1; 2; 3]) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >);</span></span></div></div></div><h2 class = 'S9' id = 'H_395d' ><span>Converting a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> </span><span style=' font-weight: bold;'>to a MATLAB table</span></h2><div class = 'S1'><span>You can convert a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object to a MATLAB table by making use of the object's</span><span> </span><span style=' font-family: monospace;'>toTable</span><span> method. This is a useful way to view the whole table in a human-readable format.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >my_table.toTable()</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="411A42BC" prevent-scroll="true" data-testid="output_8" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_5" widgetid="variableeditor_client_Document_5" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_5"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">3×5 table </span></div><div id="variableeditor_TableViewModel_5" widgetid="variableeditor_TableViewModel_5" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>id</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col1</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col2</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col3</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>col4</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>0</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>100</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a1'</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>200</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b2'</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>3</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>3</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'c'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>300</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'c3'</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output starting with ans =
id col1 col2 col3 col4
__ ____ _____ ____ ______
0 "></div></div></div></div></div><div class = 'S1'><span>When the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object contains a column that references other tables, you can pass in a Boolean to indicate whether to include just the row indices of the referenced table. Passing in</span><span> </span><span style=' font-family: monospace;'>false</span><span> will result in inclusion of the referenced rows as nested tables.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div class = 'S14'><span style="white-space: pre"><span >dtr_table.toTable(false)</span></span></div><div class = 'S11'><div class="inlineElement eoOutputWrapper disableDefaultGestureHandling embeddedOutputsVariableTableElement" uid="19DC6BCC" prevent-scroll="true" data-testid="output_9" tabindex="-1" style="width: calc(100% - 5px);"><div class="ClientDocument veSpecifier table" id="variableeditor_client_Document_6" widgetid="variableeditor_client_Document_6" tabindex="0" aria-labelledby="variableeditor_views_SummaryBar_6"><div class="summaryBar" style="font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;"><span>ans = </span><span style="color: rgb(179, 179, 179); font-style: normal;">4×3 table </span></div><div id="variableeditor_TableViewModel_6" widgetid="variableeditor_TableViewModel_6" class="table lightWeightView ClientViewDiv hasSummaryBar" data-viewid="__1" style="width: 100%; overflow: auto;"><table cellspacing="0" style="border-spacing: 0px; border-collapse: collapse;"><thead><tr><th rowspan="1" style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid rgb(191, 191, 191); text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span> </span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>id</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 102px; min-width: 102px; max-width: 102px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>data_col</span></th><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 94px; min-width: 94px; max-width: 94px; border: 1px solid rgb(191, 191, 191); text-align: center; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>dtr_col</span></th></tr></thead><tbody><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>1</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>0</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 102px; min-width: 102px; max-width: 102px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'a'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 94px; min-width: 94px; max-width: 94px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>1×4 table</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>2</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>1</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 102px; min-width: 102px; max-width: 102px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'b'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 94px; min-width: 94px; max-width: 94px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>1×4 table</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>3</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>2</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 102px; min-width: 102px; max-width: 102px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'c'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 94px; min-width: 94px; max-width: 94px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>1×4 table</span></td></tr><tr><th style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left; background-color: rgb(245, 245, 245); color: rgba(0, 0, 0, 0.75); font-weight: 700; box-sizing: border-box;"><span>4</span></th><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: right;"><span>3</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 102px; min-width: 102px; max-width: 102px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>'d'</span></td><td style="text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 94px; min-width: 94px; max-width: 94px; border-width: 0px 1px 1px; border-style: solid; border-color: rgb(191, 191, 191); border-image: initial; text-align: left;"><span>1×4 table</span></td></tr></tbody></table></div></div><div class="outputLayer selectedOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer activeOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer scrollableOutputDecorationLayer doNotExport" aria-hidden="true"></div><div class="outputLayer navigationFocusLayer doNotExport" aria-hidden="false" tabindex="-1" role="application" aria-label="variable output starting with ans =
id data_col dtr_col
__ ________ ___________
0 {'a'} {1×4"></div></div></div></div></div><h2 class = 'S9' id = 'H_0ea2' ><span>Creating an expandable table</span></h2><div class = 'S1'><span>When using the default HDF5 backend, each column of these tables is an HDF5 Dataset, which by default are set to an unchangeable size. This means that once a file is written, it is not possible to add a new row. If you want to be able to save this file, load it, and add more rows to the table, you will need to set this up when you create the</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html"><span style=' font-weight: bold;'>VectorData</span></a><span> and</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html"><span style=' font-weight: bold;'>ElementIdentifiers</span></a><span> columns of a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span>. Specifically, you must wrap the column data with a</span><span> </span><span style=' font-weight: bold;'>DataPipe</span><span> object. The</span><span> </span><span style=' font-weight: bold;'>DataPipe</span><span> class takes in </span><span style=' font-family: monospace;'>maxSize</span><span> and </span><span style=' font-family: monospace;'>axis</span><span> as arguments to indicate the maximum desired size for each axis and the axis to which to append to, respectively. For example, creating a</span><span> </span><span style=' font-weight: bold;'>DataPipe</span><span> object with a</span><span> </span><span style=' font-style: italic;'>maxSize</span><span> value equal to</span><span> </span><span style=' font-family: monospace;'>[Inf, 1]</span><span> indicates that the number of rows may increase indefinitely. In contrast, setting</span><span> </span><span style=' font-style: italic;'>maxSize</span><span> equal to</span><span> </span><span style=' font-family: monospace;'>[8, 1]</span><span> would allow the column to grow to a maximum height of 8.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">% create NwbFile object with required fields</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >file = NwbFile( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'session_start_time'</span><span >, datetime(</span><span style="color: #a709f5;">'2021-01-01 00:00:00'</span><span >, </span><span style="color: #a709f5;">'TimeZone'</span><span >, </span><span style="color: #a709f5;">'local'</span><span >), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'identifier'</span><span >, </span><span style="color: #a709f5;">'ident1'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'session_description'</span><span >, </span><span style="color: #a709f5;">'ExpandableTableTutorial' </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% create VectorData objects with DataPipe objects</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >start_time_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'start times column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [1, 2], </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> # data must be numerical</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >stop_time_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'stop times column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, [2, 3], </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> #data must be numerical</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >random_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'random data column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, rand(5, 2), </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> #data must be numerical</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, [5, Inf], </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'axis'</span><span >, 2 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >ids_exp = types.hdmf_common.ElementIdentifiers( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, int32([0; 1]), </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> # data must be numerical</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% create expandable table</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >colnames = {</span><span style="color: #a709f5;">'start_time'</span><span >, </span><span style="color: #a709f5;">'stop_time'</span><span >, </span><span style="color: #a709f5;">'randomvalues'</span><span >};</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >file.intervals_trials = types.core.TimeIntervals( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'test expdandable dynamic table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, colnames, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, start_time_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, stop_time_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, random_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, ids_exp </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% export file</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >nwbExport(file, </span><span style="color: #a709f5;">'expandableTableTestFile.nwb'</span><span >);</span></span></div></div></div><div class = 'S15'><span>Now, you can read in the file, add more rows, and save again to file</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span >read_file = nwbRead(</span><span style="color: #a709f5;">'expandableTableTestFile.nwb'</span><span >, </span><span style="color: #a709f5;">'ignorecache'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >read_file.intervals_trials.addRow( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, 3, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, 4, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, rand(5,1), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, 2 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > )</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >nwbExport(read_file, </span><span style="color: #a709f5;">'expandableTableTestFile.nwb'</span><span >);</span></span></div></div></div><div class = 'S15'><span style=' font-weight: bold;'>Note: DataPipe</span><span> objects change how the dimension of the datasets for each column map onto the shape of HDF5 datasets. See</span><span> the </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/concepts/dimension_ordering.html"><span>documentation</span></a><span> for more details.</span></div><h2 class = 'S9' id = 'H_3cf3' ><span>Multidimensional columns</span></h2><div class = 'S1'><span>The order of dimensions of multidimensional columns in MatNWB is reversed relative to the Python HDMF package (see</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/concepts/dimension_ordering.html"><span>documentation</span></a><span> for detailed explanation). Therefore, the height of a multidimensional column belonging to a</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> object is defined by the shape of its last dimension. A valid</span><span> </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span> must have matched height across columns. </span></div><h3 class = 'S13' id = 'H_8545' ><span>Constructing multidimensional columns</span></h3><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">% Define 1D column</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >simple_col = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'1D column'</span><span >,</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, rand(10,1) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Define ND column</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >multi_col = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'multidimensional column'</span><span >,</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, rand(3,2,10) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% construct table</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >multi_dim_table = types.hdmf_common.DynamicTable( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >,</span><span style="color: #a709f5;">'test table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, {</span><span style="color: #a709f5;">'simple'</span><span >,</span><span style="color: #a709f5;">'multi'</span><span >}, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'simple'</span><span >, simple_col, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'multi'</span><span >, multi_col, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, types.hdmf_common.ElementIdentifiers(</span><span style="color: #a709f5;">'data'</span><span >, (0:9)') </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >);</span></span></div></div></div><h3 class = 'S13' id = 'H_1248' ><span>Multidimensional ragged array columns</span></h3><div class = 'S1'><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span style=' font-weight: bold;'> </span><span>objects with multidimensional ragged array columns can be constructed by passing in the corresponding </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html"><span style=' font-weight: bold;'>VectorIndex</span></a><span style=' font-weight: bold;'> </span><span>column</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">% Define column with data</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >multi_ragged_col = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'multidimensional ragged array column'</span><span >,</span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, rand(2,3,5) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Define column with VectorIndex</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >multi_ragged_index = types.hdmf_common.VectorIndex( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'index to multi_ragged_col'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'target'</span><span >, types.untyped.ObjectView(multi_ragged_col),</span><span style="color: #a709f5;">'data'</span><span >, [2; 3; 5] </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >multi_ragged_table = types.hdmf_common.DynamicTable( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >,</span><span style="color: #a709f5;">'test table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, {</span><span style="color: #a709f5;">'multi_ragged'</span><span >}, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'multi_ragged'</span><span >, multi_ragged_col, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'multi_ragged_index'</span><span >, multi_ragged_index, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, types.hdmf_common.ElementIdentifiers(</span><span style="color: #a709f5;">'data'</span><span >, [0; 1; 2]) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >);</span></span></div></div></div><h3 class = 'S13' id = 'H_9bac' ><span>Adding rows to multidimensional array columns</span></h3><div class = 'S1'><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span style=' font-weight: bold;'> </span><span>objects with multidimensional array columns can also be constructed by adding a single row at a time. This method makes use of </span><span style=' font-weight: bold;'>DataPipe</span><span> objects due to the fact that MATLAB doesn't support singleton dimensions for arrays with more than 2 dimensions. The code block below demonstrates how to build a </span><a href = "https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html"><span style=' font-weight: bold;'>DynamicTable</span></a><span style=' font-weight: bold;'> </span><span>object with a multidimensional ragged array column in this manner.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div class = 'S6'><span style="white-space: pre"><span style="color: #008013;">% Create file</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >file = NwbFile( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'session_start_time'</span><span >, datetime(</span><span style="color: #a709f5;">'2021-01-01 00:00:00'</span><span >, </span><span style="color: #a709f5;">'TimeZone'</span><span >, </span><span style="color: #a709f5;">'local'</span><span >), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'identifier'</span><span >, </span><span style="color: #a709f5;">'ident1'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'session_description'</span><span >, </span><span style="color: #a709f5;">'test_file' </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'> </div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Define Vector Data Objects with first row of table</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >start_time_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'start times column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, 1, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >stop_time_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'stop times column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, 10, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >random_exp = types.hdmf_common.VectorData( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'random data column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, rand(3,2,5), </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> #random data</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, [3, 2, Inf], </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'axis'</span><span >, 3 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >random_exp_index = types.hdmf_common.VectorIndex( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'index to random data column'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'target'</span><span >, types.untyped.ObjectView(random_exp), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, uint64(5), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >ids_exp = types.hdmf_common.ElementIdentifiers( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, types.untyped.DataPipe( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'data'</span><span >, int64(0), </span><span style="color: #0e00ff;">...</span><span style="color: #008013;"> # data must be numerical</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'maxSize'</span><span >, Inf </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > ) </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Create expandable table</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >colnames = {</span><span style="color: #a709f5;">'start_time'</span><span >, </span><span style="color: #a709f5;">'stop_time'</span><span >, </span><span style="color: #a709f5;">'randomvalues'</span><span >};</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >file.intervals_trials = types.core.TimeIntervals( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'description'</span><span >, </span><span style="color: #a709f5;">'test expdandable dynamic table'</span><span >, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'colnames'</span><span >, colnames, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, start_time_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, stop_time_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, random_exp, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues_index'</span><span >, random_exp_index, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, ids_exp </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Export file</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >nwbExport(file, </span><span style="color: #a709f5;">'multiRaggedExpandableTableTest.nwb'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% Read in file</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >read_file = nwbRead(</span><span style="color: #a709f5;">'multiRaggedExpandableTableTest.nwb'</span><span >, </span><span style="color: #a709f5;">'ignorecache'</span><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span style="color: #008013;">% add individual rows</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >read_file.intervals_trials.addRow( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, 2, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, 20, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, rand(3,2,6), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, 1 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >read_file.intervals_trials.addRow( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, 3, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, 30, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, rand(3,2,3), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, 2 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >);</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span >read_file.intervals_trials.addRow( </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'start_time'</span><span >, 4, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'stop_time'</span><span >, 40, </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'randomvalues'</span><span >, rand(3,2,8), </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S7'><span style="white-space: pre"><span > </span><span style="color: #a709f5;">'id'</span><span >, 3 </span><span style="color: #0e00ff;">...</span></span></div></div><div class="inlineWrapper"><div class = 'S8'><span style="white-space: pre"><span >);</span></span></div></div></div><h2 class = 'S9' id = 'H_42c6' ><span>Learn more!</span></h2><h3 class = 'S13' id = 'H_8e0c' ><span>Python Tutorial</span></h3><div class = 'S1'><a href = "https://hdmf.readthedocs.io/en/stable/tutorials/plot_dynamictable_tutorial.html#sphx-glr-tutorials-plot-dynamictable-tutorial-py"><span>DynamicTable Tutorial</span></a></div><div class = 'S1'></div>
<br>
<!--
##### SOURCE BEGIN #####
%% DynamicTables Tutorial
% This is a user guide to interacting with <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> objects in MatNWB.
%% *MatNWB setup*
% Start by setting up your MATLAB workspace. The code below adds the directory
% containing the MatNWB package to the MATLAB search path. MatNWB works by automatically
% creating API classes based on a defined schema.
%{
path_to_matnwb = '~/Repositories/matnwb'; % change to your own path location
addpath(genpath(pwd));
%}
%% Constructing a table with initialized columns
% The <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> class represents a column-based table to which you can add custom
% columns. It consists of a description, a list of columns , and a list of row
% IDs. You can create a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> by first defining the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> objects that will make up the columns of the table. Each <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> object must contain the same number of rows. A list of rows IDs
% may be passed to the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> using the id argument. Row IDs are a useful way to access row
% information independent of row location index. The list of row IDs must be cast
% as an <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html
% *ElementIdentifiers*> object before being passed to the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object. If no value is passed to id, an <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html
% *ElementIdentifiers*> object with 0-indexed row IDs will be created for you
% automatically.
%
% *MATLAB Syntax Note*: Using column vectors is crucial to properly build vectors
% and tables. When defining individual values, make sure to use semi-colon (;)
% instead of instead of comma (,) when defining the data fields of these.
col1 = types.hdmf_common.VectorData( ...
'description', 'column #1', ...
'data', [1;2] ...
);
col2 = types.hdmf_common.VectorData( ...
'description', 'column #2', ...
'data', {'a';'b'} ...
);
row_ids = types.hdmf_common.ElementIdentifiers(...
'data', [0;1]); % 0-indexed, for compatibility with Python
my_table = types.hdmf_common.DynamicTable( ...
'description', 'an example table', ...
'colnames', {'col1', 'col2'}, ...
'col1', col1, ...
'col2', col2, ...
'id', row_ids ...
);
my_table
%% Adding rows
% You can add rows to an existing <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> using the object's |addRow| method. One way of using this method
% is to pass in the names of columns as parameter names followed by the elements
% to append. The class of the elements of the column must match the elements to
% append.
my_table.addRow('col1', 3, 'col2', {'c'}, 'id', 2);
%% Adding columns
% You can add new columns to an existing <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object using the |addColumn| method. One way of using this method
% is to pass in the names of each new column followed by the corresponding values
% for each new column. The height of the new columns must match the height of
% the table.
col3 = types.hdmf_common.VectorData('description', 'column #3', ...
'data', [100; 200; 300]);
col4 = types.hdmf_common.VectorData('description', 'column #4', ...
'data', {'a1'; 'b2'; 'c3'});
my_table.addColumn('col3', col3,'col4', col4);
%% Create MATLAB table and convert to dynamic table
% As an alternative to building a dynamic table using the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> and <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> data types, it is also possible to create a MATLAB table and convert
% it to a dynamic table. Lets create the same table as before, but using MATLAB's
% table class:
% Create a table with two variables (columns):
T = table([1;2], {'a';'b'}, 'VariableNames', {'col1', 'col2'});
T.Properties.VariableDescriptions = {'column #1', 'column #2'};
% Adding rows
T(end+1, :) = {3, 'c'};
% Adding variables (columns)
T = addvars(T, [100;200;300], 'NewVariableNames',{'col3'});
T.Properties.VariableDescriptions{3} = 'column #3';
% Alternatively, a new variable can be added directly using dot syntax.
T.col4 = {'a1'; 'b2'; 'c3'};
T.Properties.VariableDescriptions{4} = 'column #4';
T
% Convert to dynamic table
dynamic_table = util.table2nwb(T, 'A MATLAB table that was converted to a dynamic table')
%% Enumerated (categorical) data
% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_experimental/EnumData.html
% |*EnumData*|> is a special type of column for storing an enumerated data type.
% This way each unique value is stored once, and the data references those values
% by index. Using this method is more efficient than storing a single value many
% times, and has the advantage of communicating to downstream tools that the data
% is categorical in nature.
% Warning regarding EnumData
% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_experimental/EnumData.html
% |*EnumData*|> is currently an experimental feature and as such should not be
% used in a production environment.
cell_type_elements = types.hdmf_common.VectorData(...
'description', 'fixed set of elements referenced by cell_type', ...
'data', {'aa', 'bb', 'cc'} ... % the enumerated elements
);
cell_type = types.hdmf_experimental.EnumData( ...
'description', 'this column holds categorical variables', ...
'data', [0; 1; 2; 1; 0], ... % zero-indexed offset to elements.
'elements', types.untyped.ObjectView(cell_type_elements) ...
);
cell_type_table = types.hdmf_common.DynamicTable(...
'description', 'an example table with enum cell types');
%Please note: the *_elements format is required for compatibility with pynwb:
cell_type_table.vectordata.set('cell_type_elements', cell_type_elements);
cell_type_table.addColumn('cell_type', cell_type);
%% Ragged array columns
% A table column with a different number of elements for each row is called
% a "ragged array column." To define a table with a ragged array column, pass
% both the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> and the corresponding <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> as columns of the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object. The <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> columns will contain the data values. The <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> column serves to indicate how to arrange the data across rows.
% By convention the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> object corresponding to a particular column must have have the
% same name with the addition of the '_index' suffix.
%
% Below, the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> values indicate to place the 1st to 3rd (inclusive) elements
% of the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> into the first row and 4th element into the second row. The resulting
% table will have the cell {'1a'; '1b'; '1c'} in the first row and the cell {'2a'}
% in the second row.
col1 = types.hdmf_common.VectorData( ...
'description', 'column #1', ...
'data', {'1a'; '1b'; '1c'; '2a'} ...
);
col1_index = types.hdmf_common.VectorIndex( ...
'description', 'column #1 index', ...
'target',types.untyped.ObjectView(col1), ... % object view of target column
'data', [3; 4] ...
);
row_ids = types.hdmf_common.ElementIdentifiers(...
'data', [0; 1]); % 0-indexed, for compatibility with Python
table_ragged_col = types.hdmf_common.DynamicTable( ...
'description', 'an example table', ...
'colnames', {'col1'}, ...
'col1', col1, ...
'col1_index', col1_index, ...
'id', row_ids ...
);
% Adding ragged array rows
% You can add a new row to the ragged array column. Under the hood, the |addRow|
% method will add the appropriate value to the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> column to maintain proper formatting.
table_ragged_col.addRow('col1', {'3a'; '3b'; '3c'}, 'id', 2);
%% Accessing row elements
% You can access data from entire rows of a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object by calling the |getRow| method for the corresponding
% object. You can supply either an individual row number or a list of row numbers.
my_table.getRow(1)
%%
% If you want to access values for just a subset of columns you can pass in
% the 'columns' argument along with a cell array with the desired column names
my_table.getRow(1:3, 'columns', {'col1'})
%%
% You can also access specific rows by their corresponding row ID's, if they
% have been defined, by supplying a 'true' Boolean to the 'useId' parameter
my_table.getRow(1, 'useId', true)
%%
% For a ragged array columns, the |getRow| method will return a cell with different
% number of elements for each row
table_ragged_col.getRow(1:2)
%% Accessing column elements
% To access all rows from a particular column use the .get method on the vectordata
% field of the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object
my_table.vectordata.get('col2').data
%% Referencing rows of other tables
% You can create a column that references rows of other tables by adding a <file:///Users/cesar/Repositories/matnwb/doc/+types/+hdmf_common/DynamicTableRegion.html
% *DynamicTableRegion*> object as a column of a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*>. This is analogous to a foreign key in a relational database.
% The <file:///Users/cesar/Repositories/matnwb/doc/+types/+hdmf_common/DynamicTableRegion.html
% *DynamicTableRegion*> class takes in an |ObjectView| object as argument. |ObjectView|
% objects create links from one object type referencing another.
dtr_col = types.hdmf_common.DynamicTableRegion( ...
'description', 'references multiple rows of earlier table', ...
'data', [0; 1; 1; 0], ... # 0-indexed
'table',types.untyped.ObjectView(my_table) ... % object view of target table
);
data_col = types.hdmf_common.VectorData( ...
'description', 'data column', ...
'data', {'a'; 'b'; 'c'; 'd'} ...
);
dtr_table = types.hdmf_common.DynamicTable( ...
'description', 'test table with DynamicTableRegion', ...
'colnames', {'data_col', 'dtr_col'}, ...
'dtr_col', dtr_col, ...
'data_col',data_col, ...
'id',types.hdmf_common.ElementIdentifiers('data', [0; 1; 2; 3]) ...
);
%% Converting a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html *DynamicTable*> *to a MATLAB table*
% You can convert a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object to a MATLAB table by making use of the object's |toTable|
% method. This is a useful way to view the whole table in a human-readable format.
my_table.toTable()
%%
% When the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object contains a column that references other tables, you can
% pass in a Boolean to indicate whether to include just the row indices of the
% referenced table. Passing in |false| will result in inclusion of the referenced
% rows as nested tables.
dtr_table.toTable(false)
%% Creating an expandable table
% When using the default HDF5 backend, each column of these tables is an HDF5
% Dataset, which by default are set to an unchangeable size. This means that once
% a file is written, it is not possible to add a new row. If you want to be able
% to save this file, load it, and add more rows to the table, you will need to
% set this up when you create the <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorData.html
% *VectorData*> and <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/ElementIdentifiers.html
% *ElementIdentifiers*> columns of a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*>. Specifically, you must wrap the column data with a *DataPipe*
% object. The *DataPipe* class takes in |maxSize| and |axis| as arguments to indicate
% the maximum desired size for each axis and the axis to which to append to, respectively.
% For example, creating a *DataPipe* object with a _maxSize_ value equal to |[Inf,
% 1]| indicates that the number of rows may increase indefinitely. In contrast,
% setting _maxSize_ equal to |[8, 1]| would allow the column to grow to a maximum
% height of 8.
% create NwbFile object with required fields
file = NwbFile( ...
'session_start_time', datetime('2021-01-01 00:00:00', 'TimeZone', 'local'), ...
'identifier', 'ident1', ...
'session_description', 'ExpandableTableTutorial' ...
);
% create VectorData objects with DataPipe objects
start_time_exp = types.hdmf_common.VectorData( ...
'description', 'start times column', ...
'data', types.untyped.DataPipe( ...
'data', [1, 2], ... # data must be numerical
'maxSize', Inf ...
) ...
);
stop_time_exp = types.hdmf_common.VectorData( ...
'description', 'stop times column', ...
'data', types.untyped.DataPipe( ...
'data', [2, 3], ... #data must be numerical
'maxSize', Inf ...
) ...
);
random_exp = types.hdmf_common.VectorData( ...
'description', 'random data column', ...
'data', types.untyped.DataPipe( ...
'data', rand(5, 2), ... #data must be numerical
'maxSize', [5, Inf], ...
'axis', 2 ...
) ...
);
ids_exp = types.hdmf_common.ElementIdentifiers( ...
'data', types.untyped.DataPipe( ...
'data', int32([0; 1]), ... # data must be numerical
'maxSize', Inf ...
) ...
);
% create expandable table
colnames = {'start_time', 'stop_time', 'randomvalues'};
file.intervals_trials = types.core.TimeIntervals( ...
'description', 'test expdandable dynamic table', ...
'colnames', colnames, ...
'start_time', start_time_exp, ...
'stop_time', stop_time_exp, ...
'randomvalues', random_exp, ...
'id', ids_exp ...
);
% export file
nwbExport(file, 'expandableTableTestFile.nwb');
%%
% Now, you can read in the file, add more rows, and save again to file
read_file = nwbRead('expandableTableTestFile.nwb', 'ignorecache');
read_file.intervals_trials.addRow( ...
'start_time', 3, ...
'stop_time', 4, ...
'randomvalues', rand(5,1), ...
'id', 2 ...
)
nwbExport(read_file, 'expandableTableTestFile.nwb');
%%
% *Note: DataPipe* objects change how the dimension of the datasets for each
% column map onto the shape of HDF5 datasets. See the <https://matnwb.readthedocs.io/en/latest/pages/concepts/dimension_ordering.html
% documentation> for more details.
%% Multidimensional columns
% The order of dimensions of multidimensional columns in MatNWB is reversed
% relative to the Python HDMF package (see <https://matnwb.readthedocs.io/en/latest/pages/concepts/dimension_ordering.html
% documentation> for detailed explanation). Therefore, the height of a multidimensional
% column belonging to a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object is defined by the shape of its last dimension. A valid
% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> must have matched height across columns.
% Constructing multidimensional columns
% Define 1D column
simple_col = types.hdmf_common.VectorData( ...
'description', '1D column',...
'data', rand(10,1) ...
);
% Define ND column
multi_col = types.hdmf_common.VectorData( ...
'description', 'multidimensional column',...
'data', rand(3,2,10) ...
);
% construct table
multi_dim_table = types.hdmf_common.DynamicTable( ...
'description','test table', ...
'colnames', {'simple','multi'}, ...
'simple', simple_col, ...
'multi', multi_col, ...
'id', types.hdmf_common.ElementIdentifiers('data', (0:9)') ...
);
% Multidimensional ragged array columns
% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> objects with multidimensional ragged array columns can be constructed
% by passing in the corresponding <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/VectorIndex.html
% *VectorIndex*> column
% Define column with data
multi_ragged_col = types.hdmf_common.VectorData( ...
'description', 'multidimensional ragged array column',...
'data', rand(2,3,5) ...
);
% Define column with VectorIndex
multi_ragged_index = types.hdmf_common.VectorIndex( ...
'description', 'index to multi_ragged_col', ...
'target', types.untyped.ObjectView(multi_ragged_col),'data', [2; 3; 5] ...
);
multi_ragged_table = types.hdmf_common.DynamicTable( ...
'description','test table', ...
'colnames', {'multi_ragged'}, ...
'multi_ragged', multi_ragged_col, ...
'multi_ragged_index', multi_ragged_index, ...
'id', types.hdmf_common.ElementIdentifiers('data', [0; 1; 2]) ...
);
% Adding rows to multidimensional array columns
% <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> objects with multidimensional array columns can also be constructed
% by adding a single row at a time. This method makes use of *DataPipe* objects
% due to the fact that MATLAB doesn't support singleton dimensions for arrays
% with more than 2 dimensions. The code block below demonstrates how to build
% a <https://matnwb.readthedocs.io/en/latest/pages/neurodata_types/hdmf_common/DynamicTable.html
% *DynamicTable*> object with a multidimensional ragged array column in this manner.
% Create file
file = NwbFile( ...
'session_start_time', datetime('2021-01-01 00:00:00', 'TimeZone', 'local'), ...
'identifier', 'ident1', ...
'session_description', 'test_file' ...
);
% Define Vector Data Objects with first row of table
start_time_exp = types.hdmf_common.VectorData( ...
'description', 'start times column', ...
'data', types.untyped.DataPipe( ...
'data', 1, ...
'maxSize', Inf ...
) ...
);
stop_time_exp = types.hdmf_common.VectorData( ...
'description', 'stop times column', ...
'data', types.untyped.DataPipe( ...
'data', 10, ...
'maxSize', Inf ...
) ...
);
random_exp = types.hdmf_common.VectorData( ...
'description', 'random data column', ...
'data', types.untyped.DataPipe( ...
'data', rand(3,2,5), ... #random data
'maxSize', [3, 2, Inf], ...
'axis', 3 ...
) ...
);
random_exp_index = types.hdmf_common.VectorIndex( ...
'description', 'index to random data column', ...
'target', types.untyped.ObjectView(random_exp), ...
'data', types.untyped.DataPipe( ...
'data', uint64(5), ...
'maxSize', Inf ...
) ...
);
ids_exp = types.hdmf_common.ElementIdentifiers( ...
'data', types.untyped.DataPipe( ...
'data', int64(0), ... # data must be numerical
'maxSize', Inf ...
) ...
);
% Create expandable table
colnames = {'start_time', 'stop_time', 'randomvalues'};
file.intervals_trials = types.core.TimeIntervals( ...
'description', 'test expdandable dynamic table', ...
'colnames', colnames, ...
'start_time', start_time_exp, ...
'stop_time', stop_time_exp, ...
'randomvalues', random_exp, ...
'randomvalues_index', random_exp_index, ...
'id', ids_exp ...
);
% Export file
nwbExport(file, 'multiRaggedExpandableTableTest.nwb');
% Read in file
read_file = nwbRead('multiRaggedExpandableTableTest.nwb', 'ignorecache');
% add individual rows
read_file.intervals_trials.addRow( ...
'start_time', 2, ...
'stop_time', 20, ...
'randomvalues', rand(3,2,6), ...
'id', 1 ...
);
read_file.intervals_trials.addRow( ...
'start_time', 3, ...
'stop_time', 30, ...
'randomvalues', rand(3,2,3), ...
'id', 2 ...
);
read_file.intervals_trials.addRow( ...
'start_time', 4, ...
'stop_time', 40, ...
'randomvalues', rand(3,2,8), ...
'id', 3 ...
);
%% Learn more!
% Python Tutorial
% <https://hdmf.readthedocs.io/en/stable/tutorials/plot_dynamictable_tutorial.html#sphx-glr-tutorials-plot-dynamictable-tutorial-py
% DynamicTable Tutorial>
%
%
##### SOURCE END #####
-->
</div>
<script src="js/iframe-link-handler.js"></script>
<script src="js/copy-buttons.js"></script></body></html>