Utility Functions
Prediction related functions
TinnitusReconstructor.subject_selection_process — Methodsubject_selection_process(stimuli_matrix::AbstractVecOrMat{T}, target_signal::AbstractVector{T}) where {T<:Real}Perform the synthetic subject decision process, given a matrix of precomputed stimuli stimuli_matrix and a target_signal. The stimuli_matrix is of size m x n where m is the number of trials and n is the number of samples in the signal. The target_signal is a flat vector of size n or an n x 1 matrix. Return the n-dimensional response vector y as well as the stimuli_matrix as well as nothing for the binned representation.
Reconstruction related functions
TinnitusReconstructor.gs — Functiongs(responses, Φ)Linear reverse correlation.
References
- Gosselin, F. and Schyns, P.G., 2003. Superstitious perceptions reveal properties of internal representations. Psychological science, 14(5), pp.505-509.
TinnitusReconstructor.cs — Functioncs(responses, Φ, Γ::Integer=32)One-bit compressed sensing reverse correlation with basis.
References
- Plan, Y. and Vershynin, R., 2012. Robust 1-bit compressed sensing and sparse logistic regression: A convex programming approach. IEEE Transactions on Information Theory, 59(1), pp.482-494. 
- Zhang, L., Yi, J. and Jin, R., 2014, June. Efficient algorithms for robust one-bit compressive sensing. In International Conference on Machine Learning (pp. 820-828). PMLR. 
TinnitusReconstructor.zhangpassivegamma — Functionzhangpassivegamma(Φ::AbstractArray{T}, y, Γ::Integer) where {T<:Real}Passive algorithm for 1-bit compressed sensing with no basis.
References
- Zhang, L., Yi, J. and Jin, R., 2014, June. Efficient algorithms for robust one-bit compressive sensing. In International Conference on Machine Learning (pp. 820-828). PMLR.
TinnitusReconstructor.soft_threshold — Functionsoft_threshold(α, γ)Soft thresholding operator for use in compressed sensing.
Audio manipulation
TinnitusReconstructor.synthesize_audio — Functionsynthesize_audio(spect::AbstractVecOrMat, nfft::Integer)Synthesize audio from a frequency spectrum spect using a number of FFT points nfft.
Arguments
- spect::AbstractVecOrMat: frequency spectrum
- nfft::Integer: number of FFT points
TinnitusReconstructor.crop_signal! — Functioncrop_signal!(audio::SampleBuf{T, I}; start=0, stop=1) where {T, I}Crops an audio buffer to between start and stop in seconds.
TinnitusReconstructor.crop_signal — Functioncrop_signal(audio::SampleBuf{T, I}; start=0, stop=1) where {T, I}Returns an audio buffer cropped to between start and stop in seconds.
See also crop_signal!.
TinnitusReconstructor.wav2spect — FunctionCrops a signal from 0:duration, where duration is in seconds, computes the short-time Fourier transform, converts to decibels, and then averages across STFT windows.
Arguments
- audio::Union{AbstractSampleBuf, Matrix}
- duration::Real: duration in seconds
Example Usage
audio = load(audio_file_path)
spect = wav2spect(audio; duration = 1.0)TinnitusReconstructor.dB — FunctiondB(x)Convert from amplitude-scale to decibel-scale via
$\mathrm{dB}(x) = 10 \mathrm{log10}(x)$
Examples
```jldoctest
julia> TinnitusReconstructor.dB.([1, 2, 100]) 3-element Vector{Float64}: 0.0 3.010299956639812 20.0 ````
See also
TinnitusReconstructor.invdB — FunctioninvdB(x)Convert from decibel-scale to amplitude-scale via
$\mathrm{invdB}(x) = 10^{x/10}$
Examples
julia> TinnitusReconstructor.invdB.([-100, 0, 1, 2, 100])
5-element Vector{Float64}:
 1.0e-10
 1.0
 1.2589254117941673
 1.5848931924611136
 1.0e10See also