SpHr_CrossingEnvelopeWeights [ Flags ]  CFs, Ns, Xs, Ys


Calculates spatial cue weights from amplitude envelopes or their derivatives previously obtained using the SpHr_CrossingCarrierCues operation. Envelopes or derivatives are first temporally-weighted by accruing activities (see /AC flag) that exceed a user defined neural activity limit raised by the natural exponent (see /Lim and /EAC flags). A higher limit results in slower adaptations whereas a lower limit results in faster adaptations. Weights at the times of spatial cues (see /Wts flag) are next obtained using a sigmoid function computed from running averages (avg) and standard deviations (stdev) of prior, temporally-weighted, envelope values: cue weight = 1 / (1 + exp(-(envelope - avg) / stdev))


Parameters

CFs  Filter bank center frequencies. Individual bands may be excluded by setting values to NaN. See SpHr_FilterCenterFreqs operation


Ns  Number of times and envelope values (Xs and Ys) per frequency band.


Xs  Times corresponding to envelope or envelope derivative values.


Ys  Envelope or envelope derivative values.


Flags

/Lim = limit    Neural activity limit. When limit is exceeded, prior activities are diminish by the same amount. A default value of 5 is used if the /Lim flag is omitted. A higher limit results in slower adaptations to envelope amplitude or envelope derivative fluctuations. Passed values are scaled by the number of crossings obtained previously per cycle (see /CPC flag of SpHr_CrossingCarrierCues operation). The average scaled limit used across all frequency bands is written to the variable V_AvgLimit.


/Wts = [ destWaveName ]

    Weights are written to the wave specified by destWaveName. If destWaveName is omitted, the wave is named "Envelope_Wts" or nameStr + "_Wts" if the /N flag is used. Weights for each center frequency are written across columns. Weights for the first (left) channel are written to layer 0. Weights for the second (right) channel are written to layer 1. destWaveName is single precision and always overwritten. 


/AWts = [ destWaveName ]

    Weights, averaged across the left and right channels, are written to the wave specified by destWaveName. If destWaveName is omitted, the wave is named "Envelope_AvgWts" or nameStr + "_AvgWts" if the /N flag is used. Weights for each center frequency are written across columns. destWaveName is single precision and always overwritten. 


/AC = [ destWaveName ]

    Accrued neural activity in excess of Limit. If destWaveName is omitted, the wave is named "Envelope_Accrual" or nameStr + "_Accrual" if the /N flag is used. Accruals for each center frequency are written across columns. Values for the left channel are written to layer 0. Values for the right channel are written to layer 1. destWaveName is single precision and always overwritten. 


/EAC = [ destWaveName ]

    Accrued neural activity in excess of Limit raised by the base of the natural logarithm (e^Accrual). If destWaveName is omitted, the wave is named "Envelope_ExpAccrual" or nameStr + "_ExpAccrual" if the /N flag is used. Raised accruals for each center frequency are written across columns. Values for the left channel are written to layer 0. Values for the right channel are written to layer 1. destWaveName is double precision and always overwritten. 


/Avg = [ destWaveName ]

    Running averages used to compute sigmoidal weighting functions. If destWaveName is omitted, the wave is named "Envelope_Avgs" or nameStr + "_Avgs" if the /N flag is used. Averages for each center frequency are written across columns. Values for the left channel are written to layer 0. Values for the right channel are written to layer 1. destWaveName is single precision and always overwritten. 


/Dev = [ destWaveName ]

    Running deviations used to compute sigmoidal weighting functions. If destWaveName is omitted, the wave is named "Envelope_Devs" or nameStr + "_Devs" if the /N flag is used. Deviations for each center frequency are written across columns. Values for the left channel are written to layer 0. Values for the right channel are written to layer 1. destWaveName is single precision and always overwritten. 


/Sig = [ destWaveName ]

    Values used to calculate the last spatial cue weight. If destWaveName is omitted, the wave is named "Envelope_FinalSigmaStats" or nameStr + "_FinalSigmaStats" if the /N flag is used. Final averages, deviations, weights, and times are written to rows 0-3, respectively. Values for each center frequency are written across columns. Values for the left channel are written to layer 0. Values for the right channel are written to layer 1. destWaveName is single precision and always overwritten. 


/DF = dfRef    dfRef is an optional datafolder reference. Destination waves are written to this existing datafolder, overriding any datafolder specified by destWaveNames. Waves are written to the current datafolder if not specified here or in destWaveName.


/N = nameStr     is an optional string to take the place of srcWaveName if destWaveNames is not specified.


Example

Function SpHr_CrossingEnvelopeWeights_Example()

    variable fs = 48000

    // identical noise bursts

    SpHr_SignalBinaural/ms=(100)/dB=70/Ramp=20/HP=40/Buff=150 fs, Noises

    // independent noise bursts

    SpHr_SignalBinaural/Sum/ms=(100)/dB=70/Ramp=20/HP=40/Ind=1/Buff={500,0} fs, Noises

    // independent background noise

    SpHr_SignalBinaural/Sum/ms=(800)/dB=30/HP=40/Ind=1 fs, Noises

    SpHr_FilterCenterFreqs /R 314, 750, 3, CFs

    SpHr_FilterBankBiquadCoefs fs, CFs, coefBank

    SpHr_FilterBankBiquad /Dest=FilterBank CFs, coefBank, Noises

    // Envelope derivatives at times of spatial cues

    SpHr_CrossingCarrierCues/X=Xs/XN=Ns/dtEn={0,0,dtEnvs}/En={0,Env} CFs, FilterBank

    killwaves FilterBank

    // Envelope derivative weights

    variable Limit = 5 // neural activity limit

    SpHr_CrossingEnvelopeWeights /Lim=(Limit)/Wts=EnvWts/AWts=AvgEnvWts CFs, Ns, Xs, dtEnvs

    // Display dtEnvs & EnvWts

    Display /W=(50,100,50+800,100+400)/K=1 as "Envelope derivatives and weights"

    AppendToGraph/L=dtEnvs dtEnvs[*][1][0] /TN=left_dtEnv vs Xs[*][1]

    AppendToGraph/L=dtEnvs dtEnvs[*][1][1] /TN=right_dtEnv vs Xs[*][1]

    AppendToGraph/L=EnvWts EnvWts[*][1][0] /TN=left_EnvWts vs Xs[*][1]

    AppendToGraph/L=EnvWts EnvWts[*][1][1] /TN=right_EnvWts vs Xs[*][1]

    ModifyGraph lSize=0.5, rgb(left_dtEnv)=(0,0,65535),rgb(left_EnvWts)=(0,0,65535)

    ModifyGraph nticks(dtEnvs)=3,nticks(EnvWts)=2

    ModifyGraph fSize=10,standoff=0,axThick=0.5,lblPos(dtEnvs)=33,lblPos(EnvWts)=33

    ModifyGraph ZisZ=1,zapTZ=1,zapLZ=1

    ModifyGraph btLen=3,btThick=0.5,stLen=2,stThick=0.5

    ModifyGraph freePos(dtEnvs)=0,freePos(EnvWts)=0

    ModifyGraph axisEnab(dtEnvs)={0.52,0.95},axisEnab(EnvWts)={0,0.48}

    Label dtEnvs "envelope derivatives (\\U)"

    Label bottom "time (\\U)"

    Label EnvWts "envelope weights\\u#2"

    SetAxis EnvWts 0,1

    SetDrawEnv ycoord= EnvWts,linethick= 0.50

    DrawLine 0,0.5,1,0.5

    TextBox/C/N=text0/F=0/H={15,0,5}/B=1/A=LT/X=20.0/Y=-1.5 "\\Z10identical noise bursts"

    TextBox/C/N=text1/F=0/H={15,0,5}/B=1/A=RT/X=23.0/Y=-1.5 "\\Z10independent noise bursts"

    TextBox/C/N=text2/F=0/H={15,0,5}/B=1/A=MC/X=-5.0/Y=10.0 "\\Z10500 Hz   \\s(left_dtEnv) left    \\s(right_dtEnv) right"

End

Contact: Brian