Launch an fMRI experiment: Test or Scan

Software fMRI machine emulator.

Idea: Run or debug an experiment script using exactly the same code, i.e., for both testing and online data acquisition. To debug timing, you can emulate sync pulses and user responses.

Limitations: pyglet only; keyboard events only.

These are optional components that can be obtained by installing the psychopy-mri-emulator extension into the current environment.

class psychopy.hardware.emulator.ResponseEmulator(simResponses=None)[source]

Class to allow simulation of a user’s keyboard responses during a scan.

Given a list of response tuples (time, key), the thread will simulate a user pressing a key at a specific time (relative to the start of the run).

Author: Jeremy Gray; Idea: Mike MacAskill

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

class psychopy.hardware.emulator.SyncGenerator(TR=1.0, TA=1.0, volumes=10, sync='5', skip=0, sound=False, **kwargs)[source]

Class for a character-emitting metronome thread (emulate MR sync pulse).

Aim: Allow testing of temporal robustness of fMRI scripts by emulating a hardware sync pulse. Adds an arbitrary ‘sync’ character to the key buffer, with sub-millisecond precision (less precise if CPU is maxed). Recommend: TR=1.000 or higher and less than 100% CPU. Shorter TR –> higher CPU load.

Parameters:
  • TR – seconds between volume acquisitions

  • TA – seconds to acquire one volume

  • volumes – number of 3D volumes to obtain in a given scanning run

  • sync – character used as flag for sync timing, default=’5’

  • skip – how many frames to silently omit initially during T1 stabilization, no sync pulse. Not needed to test script timing, but will give more accurate feel to start of run. aka “discdacqs”.

  • sound – simulate scanner noise

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.


Back to top