A team using Matlab to manage experimental scenarios needed to generate participant-specific images, store them in a database and reference them later. Between the database product, the Matlab license and other constraints, there was no clean way to do it. A colleague named Jude volunteered to hack something together.
The result is a loop over trigger codes with a switch on a counter variable that cycles through states 1, 2, 3 and 0, a for-case antipattern where the state machine resets itself depending on which stimuli showed up. The comments are the real documentation: one stimulus is "an almost reliable stimulus", another is "usually reliable", and the response itself is addressed only "by elision".
The standout comment confesses: "this overwrites the same positions several time, but the important part is to get the preceding two, because I don't know which one of them is correct one, so I delete the whole trial." Duplicate or missing triggers are handled by zeroing out durations across whole ranges, sometimes repeatedly.
After the submitter reverted the latest way the script corrupted the data, he discovered that 20 percent of the delivered logs corresponded to entirely different, unknown experiments. The code is not just parsing noise, it is parsing the wrong experiment.
Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.