BIDSError Reference¶
psychopy-bids validates event fields early and raises explicit error classes when values are invalid.
Practical Debugging Pattern¶
Use explicit exception handling around event creation in Coder workflows:
from psychopy_bids import bids
try:
event = bids.BIDSTaskEvent(onset=0.0, duration=0.5, trial_type="stimulus")
except bids.BIDSError as exc:
print(f"BIDS validation failed: {exc}")
raise
Typical Causes¶
OnsetError: onset is missing or not numeric.DurationError: duration is negative or otherwise invalid.TrialTypeError:trial_typedoes not meet expected constraints.SampleError: sample value is invalid for the requested event.ResponseTimeError: response time is negative or malformed.HedError: invalid HED payload format.StimFileError: malformed stimulus path metadata.IdentifierError: invalid identifier field.DatabaseError: invalid database field.
API Details¶
BIDSError¶
Bases: Exception
Base class for all BIDS-related exceptions.
This class serves as the base exception class for all exceptions related to BIDS (Brain Imaging Data Structure) specifications and operations.
OnsetError¶
Bases: BIDSError
Exception raised when onset value is incorrect.
This exception is raised when the provided onset value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(onset, msg="Property 'onset' MUST be a number")
¶
Initialize the OnsetError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
onset
|
object
|
The onset value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'onset' MUST be a number"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the onset value and the error message. |
DurationError¶
Bases: BIDSError
Exception raised when duration value is incorrect.
This exception is raised when the provided duration value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(duration, msg="Property 'duration' MUST be either zero or positive (or n/a if unavailable)")
¶
Initialize the DurationError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration
|
object
|
The duration value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'duration' MUST be either zero or positive (or n/a if unavailable)"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the duration value and the error message. |
TrialTypeError¶
Bases: BIDSError
Exception raised when trial_type value is incorrect.
This exception is raised when the provided trial_type value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(trial_type, msg="Property 'trial_type' MUST be a string")
¶
Initialize the TrialTypeError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trial_type
|
object
|
The trial_type value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'trial_type' MUST be a string"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the trial_type value and the error message. |
SampleError¶
Bases: BIDSError
Exception raised when sample value is incorrect.
This exception is raised when the provided sample value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(sample, msg="Property 'sample' MUST be an integer")
¶
Initialize the SampleError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
object
|
The sample value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'sample' MUST be an integer"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the sample value and the error message. |
ResponseTimeError¶
Bases: BIDSError
Exception raised when response_time value is incorrect.
This exception is raised when the provided response_time value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(response_time, msg="Property 'response_time' MUST be a number (or n/a if unavailable)")
¶
Initialize the ResponseTimeError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response_time
|
object
|
The response_time value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'response_time' MUST be a number (or n/a if unavailable)"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the response_time value and the error message. |
HedError¶
Bases: BIDSError
Exception raised when hed value is incorrect.
This exception is raised when the provided hed value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(hed, msg="Property 'hed' MUST be a string")
¶
Initialize the HEDError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hed
|
object
|
The hed value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'hed' MUST be a string"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the hed value and the error message. |
StimFileError¶
Bases: BIDSError
Exception raised when stim_file value is incorrect.
This exception is raised when the provided stim_file value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(stim_file, msg="Property 'stim_file' MUST be a string")
¶
Initialize the StimFileError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stim_file
|
object
|
The stim_file value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'stim_file' MUST be a string"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the stim_file value and the error message. |
IdentifierError¶
Bases: BIDSError
Exception raised when identifier value is incorrect.
This exception is raised when the provided identifier value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(identifier, msg="Property 'identifier' MUST be a string")
¶
Initialize the IdentifierError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
object
|
The identifier value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'identifier' MUST be a string"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the identifier value and the error message. |
DatabaseError¶
Bases: BIDSError
Exception raised when database value is incorrect.
This exception is raised when the provided database value does not meet the expected criteria for correctness according to BIDS (Brain Imaging Data Structure) specifications.
Source code in psychopy_bids/bids/bidserror.py
__init__(database, msg="Property 'database' MUST be a string")
¶
Initialize the DatabaseError instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database
|
object
|
The database value that caused the error. |
required |
msg
|
str
|
Explanation of the error. |
"Property 'database' MUST be a string"
|
Source code in psychopy_bids/bids/bidserror.py
__str__()
¶
Return a string representation of the error.
Returns:
| Type | Description |
|---|---|
str
|
A string containing the database value and the error message. |