Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 2.6 KB

File metadata and controls

53 lines (35 loc) · 2.6 KB

Stimuli Preprocessing Steps

1. Download the stimuli

  • Visual Stimuli : Download line drawings using Creative Commons BY-SA.

    [!NOTE]
    For the images you donot find line drawings, you can use the GIMP software to convert the images to line drawings, using its edge detection feature. The files were in png format.

  • Audio Stimuli : Digital audio was generated using this online utility with voice profile of 'David' and a playback speed of '0.8x'.

2. Preprocess the stimuli

The stimuli collected needed to be preprocessed before they could be used in the experiment. The preprocessing steps are as follows:

  1. Resizing the line drawings into 256x256 pixels. The OpenCV library was was used to read and resize the images.

    Code

        img = cv2.resize(img, size)
  2. Converting the audio files to .wav format. The audio files were generated in .mp3 format.

    Code

            for file in $DIRPATH/*.mp3; do
                filename=$(basename "$file")
                filename="${filename%.*}"
                ffmpeg -i $file $OUTDIR/$filename.wav
            done
  3. A trailing silence after each audio was observed which would affect the response time of the participants. The silence was removed using the pydub library.

    Code

        def detect_leading_silence(sound, silence_threshold, chunk_size=10):
                trim_ms = 0 # ms
                while sound[trim_ms:trim_ms+chunk_size].dBFS < silence_threshold:
                    trim_ms += chunk_size
                return trim_ms

    The function analyzes an audio snippet to find the duration of the silence at the beginning of the signal. It iterates over chunks of the audio and measuring the volume (dBFS) in each chunk until the volume exceeds the provided silence threshold. The accumulated time of trimmed silence is then returned as the result and then removed using the sound[trim_ms:] function, spectifying the start and the end trim duration.

  4. The sampling rate of all the audio samples was also made equal to work with the PsychoPy backend. The sampling rate was changed to 48Hz.

  5. Run all.

This will generate the preprocessed stimuli in the stimuli folder.