Skip to content

Pipeline for processing multi-channel bat echolocation audio to analyze intensity and spatial characteristics.

Notifications You must be signed in to change notification settings

systemcarl/grayson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 

Repository files navigation

Project Grayson

Quantification of Big Brown Bat (Eptesicus Fuscus) pup's vocalisation duration, frequency, source level and directionality.

Assumptions

Important: Carefully consider the following before recording your audio data.

Currently, these MATLAB scripts and functions make a number of assumptions. If these assumptions are not true, additional challenges may be encountered when processing the audio data, or the results may be inaccurate.

This project assumes the following:

  • Calibration recordings are made using a 94 dB SPL calibrator.
  • There is only one applicable set of calibration values for all recordings on a given recording date.
  • All microphonse have the same directionality.
  • The microphone array is a cross array, with a center microphone.
  • All microphones are aligned parrellel to the arrays directional axis (x-axis).
  • An individual recording contains less than 300 calls.
  • The calls are recorded at an approximate temperature of 20°C and a humidity of 50%.
  • Calls are recorded from both both adult Big Brown Bats and Big Brown Bat pups.

Preprocessing Audio Data

Compiling the audio data assumes that the provided call recordings is in a compatible format. Additional funtions are provided to solve common issues with the data.

Multi-Channel Files

All concurrent recordings for calculating spatial information from the recorded calls must be in a single file. The stitch function can be used to combine multiple files into a single multi-channel file.

stitch( ...
    [ 'channel1.wav', 'channel2.wav', 'channel3.wav' ], ...
    'all_channels.wav' ...
);

Calibration

The calibration of the microphone array is required to calculate the source level of the recorded calls. The calibration files are expected to be seperate calibration audio for each microphone in the array. Each file should end in the channel number to be calibrated, all located in the same directory.

calibrate('calibration_recordings/', outfile='calibration.txt');

Compiling Audio Data

The data used to generate results is stored in compiled .mat files, to reduce processing overhead of generating figures and reports. The compiled data attempts to calculate the following for each detected call:

  • ipi
  • duration
  • source position & orientation
  • source level
  • directivity index
  • power spectrum
  • spectrogram data

To process the audio data, microphone poistion, arrangement, calibration and directionality must also be provided.

compile( ...
    'audio.wav', ...
    'array.txt', ...
    'mics.txt', ...
    'calibration.txt', ...
    'mic_directionality.txt', ...
    'output.mat' ...
    % additional meta data
);

array.txt

The array file should contain the 3-dementional position of each microphone channel in the array, with x being the forward direction of the array, and z being the vertical direction. By convention, the position of the left most (looking into the array) microphone is (0, 0, 0). The file should be in the format:

x1 y1 z1
x2 y2 z2
...

mics.txt

The microphone file should list the microphone channels numbers for the current cross array, starting with the center microphone, then the horizontal plane microphones from left to right (looking into the array), and finally the vertical plane microphones from top to bottom.

4 1 2 3 5 6 7 8 9 10 11

calibration.txt

The calibration file should contain the calibration values for each microphone channel in the array, each row being the response of a 20 µPa absolute sound pressure level:

calibration1
calibration2
...

mic_directionality.txt

The microphone directionality file should contain the directional response of the microphones used. GRAS40BF directionality files are provided, but should only be used if the microphones are GRAS 40BF microphones.

Additional meta data can be provided to store along with the compiled data, for convenience:

  • subject: the subject name
  • date: the date of the recording
  • age: the age of the subject
  • sex: the sex of the subject
  • parent: the name of the subject parent

Configuration

The complile funtion currently assumes the following about the audio data:

  • A temperature of 20°C
  • A humidity of 50%
  • Recordings contain less than 300 calls
  • The first call has the same inter call interval as the the following call
  • A frequency range of 5 kHz to 100 kHz
  • A minimum inter call interval of 3 ms
  • A call detection threshold of 0.03 Pa

If these assumptions are not true, the lsd function may be used directly. The lsd function also allows for the specification of other analytical prameters that may affect the results of the compiled data:

  • Cross correlation of calls using segments starting 2 ms before and ending 4 ms after the start of the call
  • An RMS window:
    • begining 2 ms before and ending 4 ms after the start of the call, if the call IPI is greater than 10 ms
    • begining 0.5 ms before and ending 1.5 ms after the start of the call, if the call IPI is less than 10 ms
  • An 95 % RMS interval
  • An optimal call sweeprate of 12.5e6 Hz/s
  • An off-plane directional tolerance of 20°

Batch Compilation

Audio may be compiled in batches using the scan_dates function, which can compile a directory of audio files, sorted by date and subject.

scan_dates( 'audio/', 'data/' );

The scan_dates function assumes the following directory structure:

audio/
    yyyy.MM.dd/
        PARENT-S-C~SUBJECT/
            trail_001.wav
            trail_002.wav
        cal.txt
        array.txt
        mics.txt
    days.txt

The days.txt file is expected to contain a list of subject birth dates, one per line, in the format:

SUBJ1  yyyy-MM-dd
SUBJ2  yyyy-MM-dd
...

Individual call calculation can be visualised by passing the option visualise_call = true. A series of figures will be generated for each call, one at a time, after the compilation of each file. Previously c ompiled calls will be skipped, unless visualise_all = true is also passed.

Visualisation of the calls will display the call osciligram, spectrogram, and directional source levels. The figures will include information for the various RMS windows, the frequency band, fundamental frequency estimates, and estimated beams based on each RMS window.

Call Aggregation

Once the audio data has been compiled, the structured folder data can be reduced to a single file matrix file, formatting the call data to be tested and analysed. The aggregate_calls function can be used to aggregate a directory of compiled call data, and save the results to a single .mat file.

aggregate_calls( ...
    'compiled_data/', ...
    'output/compiled_calls.mat' ...
);

The aggregate_calls function takes an optional third argument, filter, which can be used to filter the calls. The filter function should take a complied Data structure as input, and return a logical array of the same length as the number of calls in the Data structure.

Once the calls have been aggregated into a single file, the data can be formatted into a smaller, more manageable, table using the aggregate aggregate_call_data and aggregate_strobe_data functions. These functions will generate a table of the call data or strobe group data, respectively.

aggregate_call_data( ...
    'compiled_calls.mat', ...
    outfile = 'call_table.mat', ...
);

Visualisation

Various visualization functions are provided to generate figures from the compiled data tables:

  • analyse_ipi,
  • analyse_strobe_group,
  • analyse_duration,
  • analyse_frequency,
  • analyse_sl,
  • analyse_di. These functions each compare the respective metrics(s) across subject age, grouping by subject or other specified grouping variables.

Cross-metric comparisons can also be visualised using the clustering functions. cluster_calls will cluster and plot the calls based on the specified metrics, using a k-means clustering algorithm. Also, cluster_by_age will cluster the calls within age groups, and visualise the optimal clustering for each age group.

About

Pipeline for processing multi-channel bat echolocation audio to analyze intensity and spatial characteristics.

Resources

Stars

Watchers

Forks

Languages