Package: m2-runAudioExperiment
Run Audio ExperimentrunAudioExperimentis an utility to run an experimental setup where input
times must be recorded with precision synchronized to an audio stimulus. The
utility was developed in the context of"Simple and cheap setup for measuring
timed responses to auditory stimuli"(Miguel et. al., under review).The utility works by executing several trials that consist of reproducing an
auditory stimulus while simultaneously recording the signal of an input device.
As an output, the utility saves an audio file for each trial. With the expected
setup, each audio file has the input signal in one channel and the stimulus
signal in another. Recording both signals (the input and the stimulus loopback)
allows extracting the input times relative to the stimulus signal by
synchronizing the recording with the orignal stimulus (see utilityrec2taps).For details on how to create the setup, please see Miguel et. al., under review.InstallationFrom pypi:pip install m2-runAudioExperimentFrom sources:git clone https://github.com/m2march/runAudioExperiment.git
    cd runAudioExperiment
    python setup.py installOnce installation is done, the scriptrunAudioExperimentshould be available
in the command line interface.UsagerunAudioExperiment trial_config stimuli_list output_dirtrial_configis a path to a yaml format file describing the configuration
of the executionstimuli_listis a path to a txt file declaring the path to the stimuli
audios, one per line, relative to the current diroutput_diris a path to a directory where output from the experiment
will be written. In case the directory does not exists, it will be created.
If the directory exists, it must be empty.TrialsEach trial execution consists of the following steps:A black screen is shown for a specified durationScreen changes color and white noise with a tone is playedA black screen is shown and the stimulus is played while recording the
input device. A silence time after the stimulus ended can be configured.Screen changes color and white noise with a tone is playedTrials are executed back to back.ConfigurationThe following is an example of a trial configuration file:black_duration: 600         # Duration of black screen (in ms)
c1_duration: [1500, 3000]   # Duration of first noise screen (in ms)
c1_color: "#afd444"         # Color of first noise screen
c2_duration: 000            # Duration of second noise screen (in ms)
c2_color: "#afd444"         # Color of second noise screen
randomize: false            # Whether trial order should be randomized
sound_device: "USB Audio"   # String or int identifying the sound deviced used
silence_duration: 1500      # Duration of silence after stimuli playbackDurations may be specified as a single number or as a list of two numbers. If
it is a single number, it specifies the duration of the section. Otherwise, the
duration will be a random number between the two defined ones. If the duration
is 0, the section is skipped.sound_deviceis a string used to locate the sound device to be used. In our
proposed setup, an external USB card is usted. A list of available devices
can be obtained by executing:`runAudioExperiment -l`OutputAfter the experiment is executed, the following files are generated inoutput_dir:experiment_settings.json: a copy of the configuration defined intrial_configin json format. The configuration is extended with the
complete information of the selected sound device.trial_settings.csv: a csv formatted table describing the executed trials.
This table allows knowing the duration of the sections where duration was
specified as an interval. It also presents the order in which the stimulus
were presented in case therandomizesetting was set totrue.*.rec.*: a serie of audio files are generated, one per trial, with the
recording of the input signal and the stimulus lookback. The files are
prefixed with the basename of the stimulus file and end with a.recextension continued with the original extension of the stimulus file.Example executionThe directoryexamplecontains example data to test run the utility and see
its workings and results. A test run can be done as so:$> cd example
$> runAudioExperiment test_config.yaml stimuli_3.txt outputThis will run the experiment with three stimuli and create a new folder namedoutputwere recordings andtrial_settings.csvwill be output.Before using the utility it may be necessary to configure thesound_deviceconfiguration intest_config.yamlto refer to a sound card available in the
computer. UserunAudioExperiment -lto list options.Caveat in the duration of the sectionsThe duration of the sections may differ slightly from the specifications,
mainly due to the delay in starting playback in the soundcard. Added delay is
around 20ms. The--debug-durationsflag instructs the utility to write ohe
actual duration of the sections in an extratrial_durtions.csvfile.