bidsaid.events.EPrimeEventExtractor.extract_accuracies
- EPrimeEventExtractor.extract_accuracies(subject_response_column, correct_response_column, valid_correct_responses=None, response_required_only=False)[source]
Extract the accuracy (correct or incorrect) for each event.
Parameters
- subject_response_column
str The name of the column containing the subject’s response. Usually the column name ending in “.RESP”.
- correct_response_column
str The name of the column containing the correct response. Trials where the subject should not respond should be NaN. Usually column name ending in “.CRESP”.
- valid_correct_responses
Iterable[str | int | float]orNone, default=None Specific values in the
correct_response_columnto include in the computation. If provided, only trials where the correct response matches one of these values will be evaluated. This is useful for fixing the denominator to specific target trials (e.g., passing [“1”] to evaluate only Hit Rate, ignoring commission errors on NoGo trials that E-Prime might have encoded as “0”). If None, all non-NaN values are evaluated.- response_required_only
bool, default=False Compute accuracy only for trials that expect a subject response. When True, the script assumes that trials not requiring a response (e.g., NoGo trials) are encoded as NaN in the
correct_response_column, and assigns them NaN instead of a binary accuracy score. This isolates accuracy metrics to active responses. Set to False to evaluate all trials (where a correct withhold evaluates to 1).Important
This parameter relies strictly on the presence of a non-NaN value in the
correct_response_columnto determine if a trial expects a response. If the log file explicitly assigns a value (e.g., “0”) to a trial that should not be responded to, the script will treat it as a valid, response-required trial and assign it an accuracy score. Ensure withhold/NoGo trials are represented as NaN.
Returns
- list[int]
A list of accuracy values for each event (0 = incorrect, 1 = correct, NaN = trial did not require response when
response_required_only=True).
- subject_response_column