sweetbean.util.data_process
parse_autora_observations(observations, *, flatten_bot_detection=True, bot_detection_key=DEFAULT_BOT_DETECTION_KEY)
Flatten autora-collected observations into a one-row-per-trial frame.
subject_id is assigned by input order (0-indexed). prolific_pid
and slot_key are pulled from the envelope when present (the patched
firebase-prolific runner). bot_detection.<field> is unfolded to
bot_detection_<field> columns when flatten_bot_detection=True
(the default).
No filtering is applied here — that is the job of
:func:participant_quality_report + :func:split_by_quality.
Source code in sweetbean/util/data_process.py
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 | |
participant_quality_report(trials_df, *, subject_col='subject_id', response_col='bean_response', rt_col='bean_rt', valid_responses=None, single_key_threshold=0.95, min_mean_rt_ms=1200.0, alternation_threshold=0.95, drop_on_bot_flag=True, drop_on_suspicious_browser=True, drop_on_honeypot_filled=True)
Per-subject quality report with drop flags.
The report has one row per subject and includes prolific_pid /
slot_key (when available on the trials frame) so that downstream
code can pay every recruited participant — including those marked as
drop=True — and correlate drops with their Prolific id.
Drop signals (any one true → drop=True, with the specific reason
appended to drop_reason):
* suspicious_browser (BotDetection)
* honeypot (BotDetection)
* bot_flag (BotDetection composite)
* single_key — dominant_response_rate >= single_key_threshold
* fast_rt — mean_rt_ms < min_mean_rt_ms
* strict_alternation — strict_alternation_rate >= alternation_threshold
valid_responses, if given, restricts response-based stats (single-key
rate, alternation rate, mean RT) to trials whose response_col value is
in the set — i.e. screens out instructions / consent / feedback rows.
Source code in sweetbean/util/data_process.py
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 | |
process(stimulus_data, n_stims, idx=None)
Process list of stimulus to list of trials. For example, if the stimulus sequence is [Fixation, Text, Feedback] a list of all stimuli will be processed so that Fixation, Text and Feedback are bundled into one trial. Arguments: stimulus_data: the list of stimulus data n_stims: the number of stimuli in a sequence (3 in the above example)
Source code in sweetbean/util/data_process.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 | |
process_autora(data, n_stims, as_dict=True)
Process data when using AutoRA experiment runner (https://autoresearch.github.io/autora/) Arguments: data: the data to process n_stims: the number of stimuli in a sequence (3 in the above example) as_dict: whether to return a dictionary (can be used for pandas dataframe)
Source code in sweetbean/util/data_process.py
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 | |
split_by_quality(trials_df, report_df, *, subject_col='subject_id')
Split trials_df into (kept, dropped) based on report_df.drop.
The dropped frame gets a drop_reason column propagated from the
report so per-trial audit records carry the reason for exclusion.
Source code in sweetbean/util/data_process.py
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 | |