NetworkFunctions

Advanced Analysis Library Only

AnalysisLibErrType NetworkFunctions (void *stimulus, void *response, int samplesPerFrame, int numberOfFrames, double dt, double magSxy[], double phaseSxy[], double magHf[], double phaseHf[], double coherence[], double impulse[], double *df);

Purpose

Calculates the single-sided coherence function along with the averaged single-sided cross power spectrum, averaged single-sided frequency response, or transfer function, and impulse response, from a 2D array of stimulus signals and a 2D array of response signals.

NetworkFunctions calculates the network functions as follows:

avg cross power = average(Sxy(f))

average impulse response = ReInvFFT(avg two-sided transfer function)

where Sxy(f) is the two-sided cross power spectrum of x and y
Sxx(f) is the two-sided auto power spectrum of x
Syy(f) is the two-sided auto power spectrum of y
x is the stimulus signal
y is the response signal

stimulus is a 2D array that contains a time-domain signal, usually the network stimulus. response is a 2D array that contains a time-domain signal, usually the network response.

Each row in the stimulus array represents one frame of the network stimulus and is associated with one row of the response array, which represents one frame of the network response.

Parameters

Input
Name Type Description
stimulus double-precision array Contains the time-domain signal, usually the network stimulus. The number of rows should equal numberOfFrames, and the number of columns should equal samplesPerFrame. The size of this array must be at least numberOfFrames × samplesPerFrame.
response double-precision array Contains the time-domain signal, usually the network response. The number of rows should equal numberOfFrames, and the number of columns should equal samplesPerFrame. The size of this array must be at least numberOfFrames × samplesPerFrame.
samplesPerFrame integer Number of elements in one frame of the input stimulus and response arrays.
numberOfFrames integer Number of frames, or rows, the input stimulus and response arrays contain.

Default Value: 1.
dt double-precision Sampling period of the time-domain signal, usually in seconds. dt = 1/fs, where fs is the sampling frequency of the time-domain signal.

Default Value: 1.
Output
Name Type Description
magSxy double-precision array Averaged single-sided cross power spectrum between the stimulus and response, in volts rms square if the input signals are in volts. If the input signals are not in volts, the results are in input signal units rms square. This array must be at least samplesPerFrame/2 elements long. The output is two arrays:

magSxy (Vrms2) and phaseSxy (radians)
phaseSxy double-precision array Averaged single-sided phase spectrum in radians showing the difference between the phases of the response signal and the stimulus signal. This array must be at least samplesPerFrame/2 elements long.
magHf double-precision array Magnitude of the averaged single-sided transfer function between the stimulus and response signals. This array must be at least samplesPerFrame/2 elements long. The output is two arrays:

magtransfer (gain) and phasetransfer (radians)
phaseHf double-precision array Phase, in radians of the averaged single-sided transfer function between the stimulus and response signals. This array must be at least samplesPerFrame/2 elements long.
coherence double-precision array Averaged single-sided coherence function spectrum. coherence is unitless and ranges from 0 (no coherence) to 1 (complete coherence). The coherence function shows the frequency content of the response as a result of the stimulus and measures the validity of the network frequency response measurement. This array must be at least samplesPerFrame/2 elements long.

NetworkFunctions requires more than one set of data for both the stimulusArray and the responseArray to calculate the coherence function properly. If the input arrays contain only one reading, that is, one row of data each, the coherence function registers unity at all frequencies.
impulse double-precision array The impulse response of the network based on time-domain signals stimulus and response. NetworkFunctions calculates the impulse from the averaged frequency response of the stimulus and response signals. The size of this array must be at least samplesPerFrame.
df double-precision Points to the frequency interval, in Hertz, if dt is in seconds. df = 1/(n × dt)

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.