Ultrasession.py

From Phonlab
Jump to navigationJump to search

ultrasession.py is a Python script that acquires ultrasound data via the ultracomm utility while simultaneously acquiring an audio signal and the ultrasound synchronization signal. In addition it creates timestamped acquisition directories and logs various acquisition parameters so that they are available for postprocessing.

The favored method of calling ultrasession.py is by including it in an Opensesame experiment.

ultrasession.py is one of the scripts included in the ultratils github repository.

Usage

ultrasession.py requires a parameter file that it passes to ultracomm. It also requires you to specify an output data directory:

 python C:\Anaconda\Scripts\ultrasession.py --params \path\to\params.cfg --datadir \path\to\output\dir

Since ultracomm is a Windows-only utility ultrasession.py must run under Windows. The path to ultrasession.py shown here is its standard location on the PhonLab's ultrasound acquisition workstation.

For a full listing of options, use:

 python C:\Anaconda\Scripts\ultrasession.py --help

Output files

Each time ultrasession.py runs it creates a timestamped subdirectory in the directory identified by --datadir. This subdirectory contains:

  • a *.bpr file that contains the ultrasound image data. (The * indicates a timestamp.)
  • a *.bpr.idx.txt file that contains a list of frame indexes corresponding to the frames of data in the .bpr file. This list of indexes is important for detecting dropped frames in the .bpr data. At high acquisition rates some images will be missed.
  • a two-channel *.bpr.wav file containing audio data captured from a microphone in the first channel and the ultrasound synchronization signal in the second channel.
  • a copy of the imaging parameter file specified by --params
  • if the --stim or --stims option is used, a file named stim.txt that contains the stimulus item used for the acquisition.
  • if the --log-versions option is used, a file named versions.txt that contains information related to the version of ultracomm used in the acquisition.

The first two items are created by ultracomm directly, and the remaining files are added by ultrasession.py. The last two optional files are created if you use ultrasession.py in an Opensesame experiment in the recommended way.