Stimgen Methods

All stimgen

TinnitusReconstructor.generate_stimulusFunction
generate_stimulus(s::Stimgen)

Generate one stimulus sound.

Returns waveform, sample rate, spectral representation, binned representation, and a frequency vector (the last two empty if s >: BinnedStimgen). Methods are specialized for each concrete subtype of Stimgen.

source
TinnitusReconstructor.nsamplesFunction
nsamples(s::SG) where {SG<:Stimgen}

Return the number of samples as an Integer. This means that the product fs(s) * s.duration must be an Integer or an InexactError will be thrown.

Examples

```jldoctest julia> s = UniformPrior(; Fs=44.1e3, duration=0.5); nsamples(s) 22050

julia> s = UniformPrior(; Fs=44.1e3, duration=0.7); nsamples(s) ERROR: InexactError: Int64(30869.999999999996)

source
TinnitusReconstructor.subject_selection_processMethod
subject_selection_process(s::SG, target_signal::AbstractVector{T}, n_trials::I) where {SG<:Stimgen,T<:Real,I<:Integer}

Perform the synthetic subject decision process, generating the stimuli on-the-fly using the stimulus generation method s.

source
TinnitusReconstructor.generate_stimuli_matrixMethod
generate_stimuli_matrix(s::SG, n_trials::I) where {SG<:Stimgen, I<:Integer}

Generate n_trials of stimuli based on specifications in the stimgen type.

Returns stimuli_matrix, Fs, spect_matrix, binned_repr_matrix. binned_repr_matrix = nothing if s >: BinnedStimgen.

source

Binned only

TinnitusReconstructor.generate_stimuli_matrixMethod
generate_stimuli_matrix(s::BS, n_trials::I) where {BS<:BinnedStimgen, I<:Integer}

Generate n_trials of stimuli based on specifications in the stimgen type.

Returns stimuli_matrix, Fs, spect_matrix, binned_repr_matrix.

source
TinnitusReconstructor.freq_binsFunction
freq_bins(s::BS; n_bins::I = 0) where {BS<:BinnedStimgen, I<:Integer}

Generates a vector indicating which frequencies belong to the same bin, following a tonotopic map of audible frequency perception. The number of bins can be specified with the n_bins parameter. s.n_bins is used by default.

source
TinnitusReconstructor.spect2binnedreprFunction
spect2binnedrepr(s::BinnedStimgen, spect::AbstractVecOrMat{T}; n_bins::I = 0) where {BS<:BinnedStimgen,T,I<:Integer}

Convert a spectral representation into a binned representation. The number of bins can be specified with the n_bins parameter. s.n_bins is used by default.

Returns an n_trials x n_bins array containing the amplitude of the spectrum in each frequency bin, where n_trials = size(binned_repr, 2).

source
TinnitusReconstructor.binnedrepr2spectFunction
binnedrepr2spect(s::BinnedStimgen, binned_repr::AbstractArray{T}) where {BS<:BinnedStimgen,T}

Convert the binned representation into a spectral representation. The number of bins can be specified with the n_bins parameter. s.n_bins is used by default.

Returns an n_frequencies x n_trials spectral array, where n_trials = size(binned_repr, 2).

source
TinnitusReconstructor.binnedrepr2wavFunction
binnedrepr2wav(s::BS, binned_repr::AbstractVecOrMat{T}, mult, binrange,
new_n_bins::I = 256) where {BS <: BinnedStimgen, I <: Integer, T}

Converts a binned spectral representation into a waveform by enhancing the resolution (to new_n_bins) via interpolation, sharpening the peaks (mult), and rescaling the dynamic range (binrange).

Returns a waveform and the associated frequency spectrum.

source
TinnitusReconstructor.build_distributionFunction
build_distribution(s::PowerDistribution; save_path::AbstractString=@__DIR__)

Builds the default power distribution from ATA tinnitus sample files. Saves the distribution as a vector in dB at save_path.

source