Difference between revisions of "Ultrasound acquisition"

From Phonlab
Jump to navigationJump to search
Line 35: Line 35:
   
 
Each acquisition resides in its own timestamped directory. If you follow the normal Opensesame script conventions these directories are created in per-subject subdirectories of your base data directory. Normal output includes a <code>.bpr</code> file containing ultrasound image data, a <code>.wav</code> containing speech data and the ultrasound synchronization signal in separate channels, and a <code>.idx.txt</code> file containing the frame indexes of each frame of data in the <code>.bpr</code> file.
 
Each acquisition resides in its own timestamped directory. If you follow the normal Opensesame script conventions these directories are created in per-subject subdirectories of your base data directory. Normal output includes a <code>.bpr</code> file containing ultrasound image data, a <code>.wav</code> containing speech data and the ultrasound synchronization signal in separate channels, and a <code>.idx.txt</code> file containing the frame indexes of each frame of data in the <code>.bpr</code> file.
  +
  +
=== Synchronizing audio and ultrasound images ===
   
 
The first task in postprocessing is to find the synchronization pulses in the <code>.wav</code> file and relate them to the frame indexes in the <code>.idx.txt</code> file. You can do this with the <code>psync</code> script, which you can call on the data acquisition workstation like this:
 
The first task in postprocessing is to find the synchronization pulses in the <code>.wav</code> file and relate them to the frame indexes in the <code>.idx.txt</code> file. You can do this with the <code>psync</code> script, which you can call on the data acquisition workstation like this:
Line 41: Line 43:
   
 
Where <datadir> is your data acquisition directory (or a per-subject directory if you prefer). When invoked with <code>--seek</code>, <code>psync</code> finds all acquisitions that need postprocessing and creates corresponding <code>.sync.txt</code> and <code>.sync.TextGrid</code> files. These files contain time-aligned pulse indexes and frame indexes in columnar and Praat textgrid formats, respectively. Here 'pulse index' refers to the synchronization pulse that is sent for every frame acquired by the ultrasound system; 'frame index' refers to the frame of image data actually received by the data acquisition workstation. Ideally these indexes would always be the same, but at high frame rates the ultrasound machine cannot send data fast enough, and some frames are not received. These missing frames are not present in the <code>.bpr</code> file and have 'NA' in the frame index of the <code>psync</code> output files. For frames that are present in the <code>.bpr</code> you use the synchronization output files to find their corresponding times in the audio file.
 
Where <datadir> is your data acquisition directory (or a per-subject directory if you prefer). When invoked with <code>--seek</code>, <code>psync</code> finds all acquisitions that need postprocessing and creates corresponding <code>.sync.txt</code> and <code>.sync.TextGrid</code> files. These files contain time-aligned pulse indexes and frame indexes in columnar and Praat textgrid formats, respectively. Here 'pulse index' refers to the synchronization pulse that is sent for every frame acquired by the ultrasound system; 'frame index' refers to the frame of image data actually received by the data acquisition workstation. Ideally these indexes would always be the same, but at high frame rates the ultrasound machine cannot send data fast enough, and some frames are not received. These missing frames are not present in the <code>.bpr</code> file and have 'NA' in the frame index of the <code>psync</code> output files. For frames that are present in the <code>.bpr</code> you use the synchronization output files to find their corresponding times in the audio file.
  +
  +
=== Separating audio channels ===
   
 
If you wish you can also separate the audio channels of the <code>.wav</code> file into <code>.ch1.wav</code> and <code>.ch2.wav</code> with the <code>sepchan</code> script:
 
If you wish you can also separate the audio channels of the <code>.wav</code> file into <code>.ch1.wav</code> and <code>.ch2.wav</code> with the <code>sepchan</code> script:
Line 47: Line 51:
   
 
This step takes a little longer than <code>psync</code> and is optional.
 
This step takes a little longer than <code>psync</code> and is optional.
  +
  +
  +
=== In development ===
   
 
Additional postprocessing utilities are under development. Most of these are in the [https://github.com/rsprouse/ultratils <code>ultratils</code> github repository].
 
Additional postprocessing utilities are under development. Most of these are in the [https://github.com/rsprouse/ultratils <code>ultratils</code> github repository].

Revision as of 14:00, 19 August 2015

The Phonology Lab has a SonixTablet system from Ultrasonix for performing ultrasound studies. Consult with Susan Lin for permission to use this system.

Data acquisition workflow

The standard way to acquire ultrasound data is to run an Opensesame experiment on a data acquisition computer that controls the ultrasound system and saves timestamped data and metadata for each acquisition.

Prepare the experiment

The first step is to prepare your experiment. You will need to create an Opensesame script with a series of speaking prompts and data acquisition commands. In simple situations you can simply edit a few variables in our sample script and be ready to go.

Run the experiment

These are the steps you take when you are ready to run your experiment:

Start the ultrasound system

  1. Turn on the ultrasound system's power supply, found on the floor beneath the system.
  2. Turn on the ultrasound system with the pushbutton on the left side of the machine.
  3. Start the Sonix RP software.

Start the data acquisition system

  1. Turn on the data acquisition computer next to the ultrasound system and use the LingGuest account.
  2. Check your hardware connections and settings:
    1. The Steinberg UR22 USB audio device should be connected to the data acquisition computer.
    2. The subject microphone should be connected to 'Mic/Line 1' of the audio device. Use the patch panel if your subject will be in the soundbooth.
    3. Make sure the '+48V' switch on the back of the audio device is set to 'On' if you are using a condenser mic (usually recommended).
    4. Make a test audio recording of your subject and adjust the audio device's 'Input 1 Gain' setting as needed.
    5. The synchronization signal cable should be connected to the BNC connector labelled '25' on the ultrasound system, and the other end should be connected to 'Mic/Line 2' of the audio device.
    6. The audio device's 'Input 2 Hi-Z' button should be selected (pressed in).
    7. The audio device's 'Input 2 Gain' setting should be at the dial's midpoint.
  3. Open and run your Opensesame experiment.

Postprocessing

Each acquisition resides in its own timestamped directory. If you follow the normal Opensesame script conventions these directories are created in per-subject subdirectories of your base data directory. Normal output includes a .bpr file containing ultrasound image data, a .wav containing speech data and the ultrasound synchronization signal in separate channels, and a .idx.txt file containing the frame indexes of each frame of data in the .bpr file.

Synchronizing audio and ultrasound images

The first task in postprocessing is to find the synchronization pulses in the .wav file and relate them to the frame indexes in the .idx.txt file. You can do this with the psync script, which you can call on the data acquisition workstation like this:

 python C:\Anaconda\Scripts\psync --seek <datadir>

Where <datadir> is your data acquisition directory (or a per-subject directory if you prefer). When invoked with --seek, psync finds all acquisitions that need postprocessing and creates corresponding .sync.txt and .sync.TextGrid files. These files contain time-aligned pulse indexes and frame indexes in columnar and Praat textgrid formats, respectively. Here 'pulse index' refers to the synchronization pulse that is sent for every frame acquired by the ultrasound system; 'frame index' refers to the frame of image data actually received by the data acquisition workstation. Ideally these indexes would always be the same, but at high frame rates the ultrasound machine cannot send data fast enough, and some frames are not received. These missing frames are not present in the .bpr file and have 'NA' in the frame index of the psync output files. For frames that are present in the .bpr you use the synchronization output files to find their corresponding times in the audio file.

Separating audio channels

If you wish you can also separate the audio channels of the .wav file into .ch1.wav and .ch2.wav with the sepchan script:

 python C:\Anaconda\Scripts\sepchan --seek <datadir>

This step takes a little longer than psync and is optional.


In development

Additional postprocessing utilities are under development. Most of these are in the ultratils github repository.

Troubleshooting

Early versions of ultracomm and ultrasession.py had issues with occasional hangs when run in an Opensesame experiment. These problems are believed to have been resolved as of the Summer 2015 0.2.1-alpha release of ultracomm when used with an up-to-date ultrasession.py and following the inline scripts used in the sample experiment. Nevertheless, it is good form to check for instances of sox and ultracomm that continue to run after your experiment has concluded, as they may continue to write data to disk until they are terminated. To do this press Ctrl-Alt-Delete and open the Task Manager. Check the Processes tab for instances of rec.exe (an alias for sox.exe) and ultracomm.exe and use the End Process button to terminate these programs if they are present.

A known issue is that the ultrasound system sometimes starts imaging but never sends data to the acquisition computer. This situation occurs in about 1% of acquisitions and results in empty .bpr and .bpr.idx.txt files.