Models¶
Core data models for working with HED data structures.
HedString¶
HedString ¶
Bases: HedGroup
A HED string with its schema and definitions.
Source code in hed/models/hed_string.py
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 |
|
is_group
property
¶
Always False since the underlying string is not a group with parentheses.
copy ¶
Return a deep copy of this string.
Returns:
Name | Type | Description |
---|---|---|
HedString |
'HedString'
|
The copied group. |
expand_defs ¶
Replace def tags with def-expand tags.
This does very minimal validation.
Returns:
Name | Type | Description |
---|---|---|
HedString |
'HedString'
|
self |
Source code in hed/models/hed_string.py
find_top_level_tags ¶
Find top level groups with an anchor tag.
A max of 1 tag located per top level group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anchor_tags
|
container
|
A list/set/etc. of short_base_tags to find groups by. |
required |
include_groups
|
(0, 1 or 2)
|
Parameter indicating what return values to include. If 0: return only tags. If 1: return only groups. If 2 or any other value: return both. |
2
|
Returns: list: The returned result depends on include_groups.
Source code in hed/models/hed_string.py
from_hed_strings
classmethod
¶
Factory for creating HedStrings via combination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_strings
|
list or None
|
A list of HedString objects to combine. This takes ownership of their children. |
required |
Returns:
Name | Type | Description |
---|---|---|
new_string |
HedString
|
The newly combined HedString. |
Source code in hed/models/hed_string.py
get_as_original ¶
Return the original form of this string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The string with all the tags in their original form. |
Notes
Potentially with some extraneous spaces removed on returned string.
Source code in hed/models/hed_string.py
remove_definitions ¶
Remove definition tags and groups from this string.
This does not validate definitions and will blindly removing invalid ones as well.
Source code in hed/models/hed_string.py
remove_refs ¶
Remove any refs(tags contained entirely inside curly braces) from the string.
This does NOT validate the contents of the curly braces. This is only relevant when directly editing sidecar strings. Tools will naturally ignore these.
Source code in hed/models/hed_string.py
shrink_defs ¶
Replace def-expand tags with def tags.
This does not validate them and will blindly shrink invalid ones as well.
Returns:
Type | Description |
---|---|
'HedString'
|
self |
Source code in hed/models/hed_string.py
split_hed_string
staticmethod
¶
Split a HED string into delimiters and tags.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_string
|
str
|
The HED string to split. |
required |
Returns:
Type | Description |
---|---|
list[tuple[bool, tuple[int, int]]]
|
list[tuple[bool, tuple[int, int]]]: A list of tuples where each tuple is (is_hed_tag, (start_pos, end_pos)). |
Notes
-
The tuple format is as follows
- is_hed_tag (bool): A (possible) HED tag if True, delimiter if not.
- start_pos (int): Index of start of string in hed_string.
- end_pos (int): Index of end of string in hed_string.
-
This function does not validate tags or delimiters in any form.
Source code in hed/models/hed_string.py
split_into_groups
staticmethod
¶
Split the HED string into a parse tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_string
|
str
|
A HED string consisting of tags and tag groups to be processed. |
required |
hed_schema
|
HedSchema
|
HED schema to use to identify tags. |
required |
def_dict
|
DefinitionDict
|
The definitions to identify. |
None
|
Returns: list: A list of HedTag and/or HedGroup.
:raises ValueError: - The string is significantly malformed, such as mismatched parentheses.
Notes
- The parse tree consists of tag groups, tags, and delimiters.
Source code in hed/models/hed_string.py
validate ¶
Validate the string using the schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_placeholders
|
bool
|
Allow placeholders in the string. |
True
|
error_handler
|
ErrorHandler or None
|
The error handler to use, creates a default one if none passed. |
None
|
Returns: list[dict]: A list of issues for HED string.
Source code in hed/models/hed_string.py
HedTag¶
HedTag ¶
A single HED tag.
Notes
- HedTag is a smart class in that it keeps track of its original value and positioning as well as pointers to the relevant HED schema information, if relevant.
Source code in hed/models/hed_tag.py
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 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
|
attributes
property
¶
Return a dict of all the attributes this tag has.
Returns empty dict if this is not a value tag.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict of attributes this tag has. |
Notes
- Returns empty dict if this is not a unit class tag.
- The dictionary has unit name as the key and HedSchemaEntry as value.
base_tag
property
¶
Long form without value or extension.
Returns:
Name | Type | Description |
---|---|---|
base_tag |
str
|
The long form of the tag, without value or extension. |
default_unit
property
¶
Get the default unit class unit for this tag.
Only a tag with a single unit class can have default units.
Returns:
Name | Type | Description |
---|---|---|
unit |
UnitEntry or None
|
the default unit entry for this tag, or None |
expandable
property
¶
Return what this expands to.
This is primarily used for Def/Def-expand tags at present.
Lazily set the first time it's called.
Returns:
Type | Description |
---|---|
Union['HedGroup', 'HedTag', None]
|
Union[HedGroup,HedTag,None]: Returns the expanded form of this tag. |
expanded
property
¶
Return if this is currently expanded or not.
Will always be False unless expandable is set. This is primarily used for Def/Def-expand tags at present.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is currently expanded. |
extension
property
writable
¶
Get the extension or value of tag.
Generally this is just the portion after the last slash.
Returns an empty string if no extension or value.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The tag name. |
Notes
- This tag must have been computed first.
long_tag
property
¶
Long form including value or extension.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The long form of this tag. |
org_base_tag
property
¶
Original form without value or extension.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The original form of the tag, without value or extension. |
Notes
- Warning: This could be empty if the original tag had a name_prefix prepended. e.g. a column where "Label/" is prepended, thus the column value has zero base portion.
org_tag
property
¶
Return the original unmodified tag.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The original unmodified tag. |
schema_namespace
property
¶
Library namespace for this tag if one exists.
Returns:
Name | Type | Description |
---|---|---|
namespace |
str
|
The library namespace, including the colon. |
short_base_tag
property
writable
¶
Short form without value or extension.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The short non-extension port of a tag. |
Notes
- ParentNodes/Def/DefName would return just "Def".
short_tag
property
¶
Short form including value or extension.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The short form of the tag, including value or extension. |
tag
property
writable
¶
Returns the tag.
Returns the original tag if no user form set.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The custom set user form of the tag. |
unit_classes
property
¶
Return a dict of all the unit classes this tag accepts.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict of unit classes this tag accepts. |
Notes
- Returns empty dict if this is not a unit class tag.
- The dictionary has unit name as the key and HedSchemaEntry as value.
value_classes
property
¶
Return a dict of all the value classes this tag accepts.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary of HedSchemaEntry value classes this tag accepts. |
Notes
- Returns empty dict if this is not a value class.
- The dictionary has unit name as the key and HedSchemaEntry as value.
base_tag_has_attribute ¶
Check to see if the tag has a specific attribute.
This is primarily used to check for things like TopLevelTag on Definitions and similar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_attribute
|
str
|
A tag attribute. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the tag has the specified attribute. False, if otherwise. |
Source code in hed/models/hed_tag.py
casefold ¶
copy ¶
Return a deep copy of this tag.
Returns:
Name | Type | Description |
---|---|---|
HedTag |
'HedTag'
|
The copied group. |
Source code in hed/models/hed_tag.py
get_stripped_unit_value ¶
Return the extension divided into value and units, if the units are valid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extension_text
|
str
|
The text to split, in case it's a portion of a tag. |
required |
Returns:
Type | Description |
---|---|
Union[str, None]
|
str or None: The extension portion with the units removed or None if invalid units. |
Union[str, None]
|
str or None: The units or None if no units of the right unit class are found. |
Examples:
'Duration/3 ms' will return ('3', 'ms')
Source code in hed/models/hed_tag.py
get_tag_unit_class_units ¶
Get the unit class units associated with a particular tag.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list containing the unit class units associated with a particular tag or an empty list. |
Source code in hed/models/hed_tag.py
has_attribute ¶
Return True if this is an attribute this tag has.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attribute
|
str
|
Name of the attribute. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this tag has the attribute. |
Source code in hed/models/hed_tag.py
is_basic_tag ¶
Return True if a known tag with no extension or value.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a known tag without extension or value. |
is_column_ref ¶
Return if this tag is a column reference from a sidecar.
You should only see these if you are directly accessing sidecar strings, tools should remove them otherwise.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Returns True if this is a column ref. |
Source code in hed/models/hed_tag.py
is_placeholder ¶
Returns if this tag has a placeholder in it.
Returns:
Name | Type | Description |
---|---|---|
has_placeholder |
bool
|
True if it has a placeholder |
is_takes_value_tag ¶
Return True if this is a takes value tag.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a takes value tag. |
Source code in hed/models/hed_tag.py
is_unit_class_tag ¶
Return True if this is a unit class tag.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a unit class tag. |
is_value_class_tag ¶
Return True if this is a value class tag.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this is a tag with a value class. |
Source code in hed/models/hed_tag.py
lower ¶
replace_placeholder ¶
If tag has a placeholder character(#), replace with value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
placeholder_value
|
str
|
Value to replace placeholder with. |
required |
Source code in hed/models/hed_tag.py
tag_exists_in_schema ¶
Return whether the schema entry for this tag exists.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if this tag exists. |
Notes
- This does NOT assure this is a valid tag.
tag_modified ¶
Return True if tag has been modified from original.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Return True if the tag is modified. |
Notes
- Modifications can include adding a column name_prefix.
Source code in hed/models/hed_tag.py
value_as_default_unit ¶
Return the value converted to default units if possible or None if invalid.
Returns:
Type | Description |
---|---|
Union[float, None]
|
float or None: The extension value in default units. If no default units it assumes that the extension value is in default units. |
Examples:
'Duration/300 ms' will return .3
Source code in hed/models/hed_tag.py
HedGroup¶
HedGroup ¶
A single parenthesized HED string.
Source code in hed/models/hed_group.py
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 |
|
span
property
¶
Return the source span.
Return
int: start index of the group (including parentheses) from the source string. int: end index of the group (including parentheses) from the source string.
append ¶
casefold ¶
check_if_in_original ¶
Check if the tag or group in original string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_or_group
|
HedTag or HedGroup
|
The HedTag or HedGroup to be looked for in this group. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if in this group. |
Source code in hed/models/hed_group.py
copy ¶
Return a deep copy of this group.
Returns:
Name | Type | Description |
---|---|---|
HedGroup |
'HedGroup'
|
The copied group. |
Source code in hed/models/hed_group.py
find_def_tags ¶
Find def and def-expand tags.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
recursive
|
bool
|
If true, also check subgroups. |
False
|
include_groups
|
(int, 0, 1, 2, 3)
|
Options for return values. If 0: Return only def and def expand tags/. If 1: Return only def tags and def-expand groups. If 2: Return only groups containing defs, or def-expand groups. If 3 or any other value: Return all 3 as a tuple. |
3
|
Returns: list: A list of tuples. The contents depend on the values of the include_group.
Source code in hed/models/hed_group.py
find_exact_tags ¶
Find the given tags. This will only find complete matches, any extension or value must also match.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exact_tags
|
list of HedTag
|
A container of tags to locate. |
required |
recursive
|
bool
|
If true, also check subgroups. |
False
|
include_groups
|
bool
|
0, 1 or 2. If 0: Return only tags If 1: Return only groups If 2 or any other value: Return both |
1
|
Returns: list: A list of tuples. The contents depend on the values of the include_group.
Source code in hed/models/hed_group.py
find_placeholder_tag ¶
Return a placeholder tag, if present in this group.
Returns:
Type | Description |
---|---|
Union[HedTag, None]
|
Union[HedTag, None]: The placeholder tag if found. |
Notes
- Assumes a valid HedString with no erroneous "#" characters.
Source code in hed/models/hed_group.py
find_tags ¶
Find the base tags and their containing groups. This searches by short_base_tag, ignoring any ancestors or extensions/values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_tags
|
container
|
A container of short_base_tags to locate. |
required |
recursive
|
bool
|
If true, also check subgroups. |
False
|
include_groups
|
(0, 1 or 2)
|
Specify return values. If 0: return a list of the HedTags. If 1: return a list of the HedGroups containing the HedTags. If 2: return a list of tuples (HedTag, HedGroup) for the found tags. |
2
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The contents of the list depends on the value of include_groups. |
Source code in hed/models/hed_group.py
find_tags_with_term ¶
Find any tags that contain the given term.
Note: This can only find identified tags.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
term
|
str
|
A single term to search for. |
required |
recursive
|
bool
|
If true, recursively check subgroups. |
False
|
include_groups
|
(0, 1 or 2)
|
Controls return values If 0: Return only tags. If 1: Return only groups. If 2 or any other value: Return both. |
2
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
|
Source code in hed/models/hed_group.py
find_wildcard_tags ¶
Find the tags and their containing groups.
This searches tag.short_tag.casefold(), with an implicit wildcard on the end.
e.g. "Eve" will find Event, but not Sensory-event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_tags
|
container
|
A container of the starts of short tags to search. |
required |
recursive
|
bool
|
If True, also check subgroups. |
False
|
include_groups
|
(0, 1 or 2)
|
Specify return values. If 0: return a list of the HedTags. If 1: return a list of the HedGroups containing the HedTags. If 2: return a list of tuples (HedTag, HedGroup) for the found tags. |
2
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The contents of the list depends on the value of include_groups. |
Source code in hed/models/hed_group.py
get_all_groups ¶
Return HedGroups, including descendants and self.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
also_return_depth
|
bool
|
If True, yield tuples (group, depth) rather than just groups. |
False
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
The list of all HedGroups in this group, including descendants and self. |
Source code in hed/models/hed_group.py
get_all_tags ¶
Return HedTags, including descendants.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of all the tags in this group including descendants. |
Source code in hed/models/hed_group.py
get_as_form ¶
Get the string corresponding to the specified form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_attribute
|
str
|
The hed_tag property to use to construct the string (usually short_tag or long_tag). |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The constructed string after transformation. |
Source code in hed/models/hed_group.py
get_as_indented ¶
Return the string as a multiline indented format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_attribute
|
str
|
The hed_tag property to use to construct the string (usually short_tag or long_tag). |
'short_tag'
|
Returns:
Name | Type | Description |
---|---|---|
formatted_hed |
str
|
The indented string. |
Source code in hed/models/hed_group.py
get_as_long ¶
Return this HedGroup as a long tag string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The group as a string with all tags as long tags. |
get_as_short ¶
Return this HedGroup as a short tag string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The group as a string with all tags as short tags. |
get_first_group ¶
Return the first group in this HED string or group.
Useful for things like Def-expand where they only have a single group.
Raises a ValueError if there are no groups.
Returns:
Name | Type | Description |
---|---|---|
HedGroup |
HedGroup
|
The first group. |
Source code in hed/models/hed_group.py
get_original_hed_string ¶
Get the original HED string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The original string with no modification. |
groups ¶
Return the direct child groups of this group.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
All groups directly in this group, filtering out HedTag children. |
Source code in hed/models/hed_group.py
lower ¶
remove ¶
Remove any tags/groups in items_to_remove.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items_to_remove
|
list
|
List of HedGroups and/or HedTags to remove by identity. |
required |
Notes
- Any groups that become empty will also be pruned.
- If you pass a child and parent group, the child will also be removed from the parent.
Source code in hed/models/hed_group.py
replace
staticmethod
¶
Replace an existing tag or group.
Note: This is a static method that relies on the parent attribute of item_to_replace.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item_to_replace
|
HedTag or HedGroup
|
The item to replace must exist or this will raise an error. |
required |
new_contents
|
HedTag or HedGroup
|
Replacement contents. |
required |
:raises KeyError: - item_to_replace does not exist.
:raises AttributeError: - item_to_replace has no parent set.
Source code in hed/models/hed_group.py
sort ¶
sorted ¶
Return a sorted copy of this HED group
Returns:
Name | Type | Description |
---|---|---|
sorted_copy |
HedGroup
|
The sorted copy. |
tags ¶
Return the direct child tags of this group.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
All tags directly in this group, filtering out HedGroup children. |
Sidecar¶
Sidecar ¶
Contents of a JSON file or JSON files.
Source code in hed/models/sidecar.py
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 |
|
all_hed_columns
property
¶
Return all columns that are HED compatible.
Returns:
Name | Type | Description |
---|---|---|
column_refs |
list
|
A list of all valid HED columns by name. |
column_data
property
¶
Generate the ColumnMetadata for this sidecar.
Returns:
Name | Type | Description |
---|---|---|
dict |
{str: ColumnMetadata}
|
The column metadata defined by this sidecar. |
def_dict
property
¶
Definitions from this sidecar.
Generally you should instead call get_def_dict to get the relevant definitions.
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
DefinitionDict
|
The definitions for this sidecar. |
extract_definitions ¶
Gather and validate definitions in metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
The schema to used to identify tags. |
required |
error_handler
|
ErrorHandler or None
|
The error handler to use for context, uses a default one if None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
DefinitionDict
|
Contains all the definitions located in the sidecar. |
Source code in hed/models/sidecar.py
get_as_json_string ¶
Return this sidecar's column metadata as a string.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The json string representing this sidecar. |
get_column_refs ¶
Returns a list of column refs found in this sidecar.
This does not validate
Returns:
Name | Type | Description |
---|---|---|
column_refs |
list
|
A list of unique column refs found. |
Source code in hed/models/sidecar.py
get_def_dict ¶
Return the definition dict for this sidecar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
Identifies tags to find definitions. |
required |
extra_def_dicts
|
list, DefinitionDict, or None
|
Extra dicts to add to the list. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
DefinitionDict
|
A single definition dict representing all the data(and extra def dicts). |
Source code in hed/models/sidecar.py
load_sidecar_file ¶
Load column metadata from a given json file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
str or FileLike
|
If a string, this is a filename. Otherwise, it will be parsed as a file-like. |
required |
:raises HedFileError: - If the file was not found or could not be parsed into JSON.
Source code in hed/models/sidecar.py
load_sidecar_files ¶
Load json from a given file or list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files
|
str or FileLike or list
|
A string or file-like object representing a JSON file, or a list of such. |
required |
:raises HedFileError: - If the file was not found or could not be parsed into JSON.
Source code in hed/models/sidecar.py
save_as_json ¶
Save column metadata to a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_filename
|
str
|
Path to save file. |
required |
validate ¶
Create a SidecarValidator and validate this sidecar with the schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
Input data to be validated. |
required |
extra_def_dicts
|
list or DefinitionDict
|
Extra def dicts in addition to sidecar. |
None
|
name
|
str
|
The name to report this sidecar as. |
None
|
error_handler
|
ErrorHandler
|
Error context to use. Creates a new one if None. |
None
|
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of issues associated with each level in the HED string. |
Source code in hed/models/sidecar.py
TabularInput¶
TabularInput ¶
Bases: BaseInput
A BIDS tabular file with sidecar.
Source code in hed/models/tabular_input.py
get_column_refs ¶
Return a list of column refs for this file.
Default implementation returns none.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: A list of unique column refs found. |
Source code in hed/models/tabular_input.py
get_def_dict ¶
Return the definition dict for this sidecar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
Used to identify tags to find definitions. |
required |
extra_def_dicts
|
list, DefinitionDict, or None
|
Extra dicts to add to the list. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
'DefinitionDict'
|
A single definition dict representing all the data(and extra def dicts). |
Source code in hed/models/tabular_input.py
get_sidecar ¶
reset_column_mapper ¶
Change the sidecars and settings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sidecar
|
str or [str] or Sidecar or [Sidecar]
|
A list of json filenames to pull sidecar info from. |
None
|
Source code in hed/models/tabular_input.py
SpreadsheetInput¶
SpreadsheetInput ¶
Bases: BaseInput
A spreadsheet of HED tags.
Source code in hed/models/spreadsheet_input.py
BaseInput¶
BaseInput ¶
Superclass representing a basic columnar file.
Source code in hed/models/base_input.py
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 |
|
columns
property
¶
Returns a list of the column names.
Empty if no column names.
Returns:
Name | Type | Description |
---|---|---|
columns |
list
|
The column names. |
dataframe_a
property
¶
Return the assembled dataframe Probably a placeholder name.
Returns:
Type | Description |
---|---|
DataFrame
|
pd.Dataframe: the assembled dataframe |
needs_sorting
property
¶
Return True if this both has an onset column, and it needs sorting.
series_a
property
¶
Return the assembled dataframe as a series.
Returns:
Type | Description |
---|---|
Series
|
pd.Series: the assembled dataframe with columns merged. |
series_filtered
property
¶
Return the assembled dataframe as a series, with rows that have the same onset combined.
Returns:
Type | Description |
---|---|
Union[Series, None]
|
Union[pd.Series, None] the assembled dataframe with columns merged, and the rows filtered together. |
assemble ¶
Assembles the HED strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapper
|
ColumnMapper or None
|
Generally pass none here unless you want special behavior. |
None
|
skip_curly_braces
|
bool
|
If True, don't plug in curly brace values into columns. |
False
|
Returns: pd.Dataframe: The assembled dataframe.
Source code in hed/models/base_input.py
column_metadata ¶
Return the metadata for each column.
Returns:
Type | Description |
---|---|
dict[int, ColumnMeta]
|
dict[int, 'ColumnMeta']: Number/ColumnMeta pairs. |
combine_dataframe
staticmethod
¶
Combine all columns in the given dataframe into a single HED string series, skipping empty columns and columns with empty strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe
|
Dataframe
|
The dataframe to combine |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The assembled series. |
Source code in hed/models/base_input.py
convert_to_form ¶
Convert all tags in underlying dataframe to the specified form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
The schema to use to convert tags. |
required |
tag_form
|
str
|
HedTag property to convert tags to. Most cases should use convert_to_short or convert_to_long below. |
required |
Source code in hed/models/base_input.py
convert_to_long ¶
Convert all tags in underlying dataframe to long form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema or None
|
The schema to use to convert tags. |
required |
convert_to_short ¶
Convert all tags in underlying dataframe to short form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
The schema to use to convert tags. |
required |
expand_defs ¶
Shrinks any def-expand found in the underlying dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema or None
|
The schema to use to identify defs. |
required |
def_dict
|
DefinitionDict
|
The definitions to expand. |
required |
Source code in hed/models/base_input.py
get_column_refs ¶
Return a list of column refs for this file.
Default implementation returns empty list.
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of unique column refs found. |
get_def_dict ¶
Return the definition dict for this file.
Note: Baseclass implementation returns just extra_def_dicts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
Identifies tags to find definitions(if needed). |
required |
extra_def_dicts
|
list, DefinitionDict, or None
|
Extra dicts to add to the list. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
DefinitionDict
|
A single definition dict representing all the data(and extra def dicts). |
Source code in hed/models/base_input.py
get_worksheet ¶
Get the requested worksheet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
worksheet_name
|
str or None
|
The name of the requested worksheet by name or the first one if None. |
None
|
Returns:
Type | Description |
---|---|
Union[Workbook, None]
|
Union[openpyxl.workbook.Workbook, None]: The workbook request. |
Notes
If None, returns the first worksheet.
:raises KeyError: - The specified worksheet name does not exist.
Source code in hed/models/base_input.py
reset_mapper ¶
Set mapper to a different view of the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_mapper
|
ColumnMapper
|
A column mapper to be associated with this base input. |
required |
Source code in hed/models/base_input.py
set_cell ¶
Replace the specified cell with transformed text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row_number
|
int
|
The row number of the spreadsheet to set. |
required |
column_number
|
int
|
The column number of the spreadsheet to set. |
required |
new_string_obj
|
HedString
|
Object with text to put in the given cell. |
required |
tag_form
|
str
|
Version of the tags (short_tag, long_tag, base_tag, etc.) |
'short_tag'
|
Notes
Any attribute of a HedTag that returns a string is a valid value of tag_form.
:raises ValueError: - There is not a loaded dataframe.
:raises KeyError: - The indicated row/column does not exist.
:raises AttributeError: - The indicated tag_form is not an attribute of HedTag.
Source code in hed/models/base_input.py
shrink_defs ¶
Shrinks any def-expand found in the underlying dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema or None
|
The schema to use to identify defs. |
required |
Source code in hed/models/base_input.py
to_csv ¶
Write to file or return as a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
str, file-like, or None
|
Location to save this file. If None, return as string. |
None
|
Returns: None or str: None if file is given or the contents as a str if file is None.
:raises OSError: - Cannot open the indicated file.
Source code in hed/models/base_input.py
to_excel ¶
Output to an Excel file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file
|
str or file - like
|
Location to save this base input. |
required |
:raises ValueError: - If empty file object was passed.
:raises OSError: - Cannot open the indicated file.
Source code in hed/models/base_input.py
validate ¶
Creates a SpreadsheetValidator and returns all issues with this file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
HedSchema
|
The schema to use for validation. |
required |
extra_def_dicts
|
list of DefDict or DefDict
|
All definitions to use for validation. |
None
|
name
|
str
|
The name to report errors from this file as. |
None
|
error_handler
|
ErrorHandler
|
Error context to use. Creates a new one if None. |
None
|
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of issues for a HED string. |
Source code in hed/models/base_input.py
ColumnMapper¶
ColumnMapper ¶
Mapping of a base input file columns into HED tags.
Notes
- All column numbers are 0 based.
Source code in hed/models/column_mapper.py
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 |
|
column_prefix_dictionary
property
¶
Return the column_prefix_dictionary with numbers turned into names where possible.
Returns:
Name | Type | Description |
---|---|---|
column_prefix_dictionary |
list of str or int
|
A column_prefix_dictionary with column labels as keys. |
sidecar_column_data
property
¶
Pass through to get the sidecar ColumnMetadata.
Returns:
Name | Type | Description |
---|---|---|
dict |
{str: ColumnMetadata}
|
The column metadata defined by this sidecar. |
tag_columns
property
¶
Return the known tag and optional tag columns with numbers as names when possible.
Returns:
Name | Type | Description |
---|---|---|
tag_columns |
list of str or int
|
A list of all tag and optional tag columns as labels. |
check_for_blank_names
staticmethod
¶
Validate there are no blank column names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
column_map
|
iterable
|
A list of column names. |
required |
allow_blank_names
|
bool
|
Only find issues if True. |
required |
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list of dicts, one per issue. |
Source code in hed/models/column_mapper.py
check_for_mapping_issues ¶
Find all issues given the current column_map, tag_columns, etc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
allow_blank_names
|
bool
|
Only flag blank names if False. |
False
|
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: All issues found as a list of dicts. |
Source code in hed/models/column_mapper.py
get_column_mapping_issues ¶
Get all the issues with finalizing column mapping(duplicate columns, missing required, etc.).
Notes
- This is deprecated and now a wrapper for "check_for_mapping_issues()".
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: A list dictionaries of all issues found from mapping column names to numbers. |
Source code in hed/models/column_mapper.py
get_def_dict ¶
Return def dicts from every column description.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_schema
|
Schema
|
A HED schema object to use for extracting definitions. |
required |
extra_def_dicts
|
list, DefinitionDict, or None
|
Extra dicts to add to the list. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DefinitionDict |
DefinitionDict
|
A single definition dict representing all the data(and extra def dicts). |
Source code in hed/models/column_mapper.py
get_tag_columns ¶
Return the column numbers or names that are mapped to be HedTags.
Note: This is NOT the tag_columns or optional_tag_columns parameter, though they set it.
Returns:
Name | Type | Description |
---|---|---|
column_identifiers |
list
|
A list of column numbers or names that are ColumnType.HedTags. 0-based if integer-based, otherwise column name. |
Source code in hed/models/column_mapper.py
get_transformers ¶
Return the transformers to use on a dataframe.
Returns:
Name | Type | Description |
---|---|---|
tuple |
(dict, list)
|
dict({str or int: func}): The functions to use to transform each column. need_categorical(list of int): A list of columns to treat as categorical. |
Source code in hed/models/column_mapper.py
set_column_map ¶
Set the column number to name mapping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_column_map
|
list or dict
|
Either an ordered list of the column names or column_number:column name. dictionary. In both cases, column numbers start at 0. |
None
|
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: List of issues. Each issue is a dictionary. |
Source code in hed/models/column_mapper.py
set_column_prefix_dictionary ¶
Set the column prefix dictionary.
set_tag_columns ¶
Set tag columns and optional tag columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_columns
|
list
|
A list of ints or strings containing the columns that contain the HED tags. If None, clears existing tag_columns |
None
|
optional_tag_columns
|
list
|
A list of ints or strings containing the columns that contain the HED tags, but not an error if missing. If None, clears existing tag_columns |
None
|
finalize_mapping
|
bool
|
Re-generate the internal mapping if True, otherwise no effect until finalize. |
True
|
Source code in hed/models/column_mapper.py
DefinitionDict¶
DefinitionDict ¶
Gathers definitions from a single source.
Source code in hed/models/definition_dict.py
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 |
|
add_definitions ¶
Add definitions from dict(s) or strings(s) to this dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
def_dicts
|
list, DefinitionDict, dict, or str
|
DefinitionDict or list of DefinitionDicts/strings/dicts whose definitions should be added. |
required |
hed_schema
|
HedSchema or None
|
Required if passing strings or lists of strings, unused otherwise. |
None
|
Note - dict form expects DefinitionEntries in the same form as a DefinitionDict Note - str or list of strings will parse the strings using the hed_schema. Note - You can mix and match types, eg [DefinitionDict, str, list of str] would be valid input.
:raises TypeError: - Bad type passed as def_dicts.
Source code in hed/models/definition_dict.py
check_for_definitions ¶
Check string for definition tags, adding them to self.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hed_string_obj
|
HedString
|
A single HED string to gather definitions from. |
required |
error_handler
|
ErrorHandler or None
|
Error context used to identify where definitions are found. |
None
|
Returns:
Type | Description |
---|---|
list[dict]
|
list[dict]: List of issues encountered in checking for definitions. Each issue is a dictionary. |
Source code in hed/models/definition_dict.py
get ¶
Get the definition entry for the definition name.
Not case-sensitive
Parameters:
Name | Type | Description | Default |
---|---|---|---|
def_name
|
str
|
Name of the definition to retrieve. |
required |
Returns:
Type | Description |
---|---|
Union[DefinitionEntry, None]
|
Union[DefinitionEntry, None]: Definition entry for the requested definition. |
Source code in hed/models/definition_dict.py
get_as_strings
staticmethod
¶
Convert the entries to strings of the contents
Parameters:
Name | Type | Description | Default |
---|---|---|---|
def_dict
|
dict
|
A dict of definitions |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str,str]: definition name and contents |
Source code in hed/models/definition_dict.py
get_definition_entry ¶
Get the entry for a given def tag.
Does not validate at all.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
def_tag
|
HedTag
|
Source HED tag that may be a Def or Def-expand tag. |
required |
Returns:
Name | Type | Description |
---|---|---|
def_entry |
DefinitionEntry or None
|
The definition entry if it exists |
Source code in hed/models/definition_dict.py
items ¶
Return the dictionary of definitions.
Alias for .defs.items()
Returns:
Name | Type | Description |
---|---|---|
def_entries |
{str: DefinitionEntry}
|
A list of definitions. |