Esempio n. 1
0
        # trial.test_signal = test_tone (matlab)
        sine_ampl = np.sqrt(2)*10**(trial.variable/20)
        m_test = gensin(sine_freq, sine_ampl, sine_dur, 0,
                                   trial.sample_rate)
        m_test = hanwin(m_test, np.round(
            ramp_dur*trial.sample_rate))

        # generate new instance of running noise
        m_ref = np.random.randn(np.round(noise_dur*trial.sample_rate))
        m_ref = fft_rect_filt(m_ref, noise_freq-noise_band_width/2,
                              noise_freq+noise_band_width/2, trial.sample_rate)

        # adjust its level
        m_ref = m_ref/rms(m_ref)*10**(trial.noise_level/20)
        # apply onset/offset ramps
        m_ref = hanwin(m_ref, np.round(ramp_dur*trial.sample_rate))


        pause_zeros = np.zeros(np.round(pause_dur*trial.sample_rate))
        sine_zeros = np.zeros(np.round(sine_dur*trial.sample_rate))
        trial.reference_signal = np.concatenate((m_ref, pause_zeros, sine_zeros))
        trial.test_signal = np.concatenate((m_ref, pause_zeros, m_test))



if __name__ == "__main__":
    earyx.start(SineAfterNoise)

    

Esempio n. 2
0
    def init_experiment(self, exp):
        exp.add_parameter("noise_level", [-40, -60], 'dB')
        exp.set_variable("sine_level", -20, 'dB')
        exp.add_adapt_setting('1up2down', max_reversals = 8,
                              start_step = 5, min_step = 1)

        exp.num_afc = 3
        exp.discard_unfinished_runs = False
        exp.pre_signal = 0.3
        exp.between_signal = 0.3
        exp.post_signal = 0.2

        exp.description = """This is the description
        of the experiment"""

    def init_run(self, run):
        ref = np.random.randn(np.round(0.3*run.sample_rate))
        ref = ref/rms(ref)*10**(run.noise_level/20)
        run.reference_signal = ref

    def init_trial(self, trial):
        ampl = np.sqrt(2)*10**(trial.variable/20)
        test = gensin(1600, ampl, 0.03, trial.sample_rate)
        pos = np.round((len(trial.reference_signal) - len(test))/2)
        trial.test_signal = trial.reference_signal.copy()
        trial.test_signal[pos:pos+len(test)] += test

if __name__ == '__main__':
    earyx.start(SineInNoise)
Esempio n. 3
0
    def init_run(self, cur_run):
        """Set signals for reference and pauses between them."""

        ramp_dur_htc = 0.05
        cur_run.reference_signal = htc(75, cur_run.sample_rate, 0.32,
                                      cur_run.signal_freq/10,
                                      0.4*cur_run.signal_freq,
                                      1.6*cur_run.signal_freq,
                                       cur_run.C, cur_run.calib)
        cur_run.reference_signal = hanwin(cur_run.reference_signal,
                                          np.round(ramp_dur_htc*
                                                   cur_run.sample_rate))

    def init_trial(self, trial):
        """Set signal for variable."""

        sine_dur = 0.26
        ramp_dur_sine = 0.03
        ampl = np.sqrt(2)*10**((trial.variable-trial.calib)/20)
        start_phase = np.random.randint(0, 361)
        test_tone = gensin(trial.signal_freq, ampl, sine_dur, start_phase,
                           trial.sample_rate)
        test_tone = hanwin(test_tone,
                           np.round(ramp_dur_sine*trial.sample_rate))
        trial.test_signal = trial.reference_signal.copy()
        start_sample = np.round((len(trial.reference_signal)-len(test_tone))/2)
        trial.test_signal[start_sample:start_sample+len(test_tone)] += test_tone

if __name__ == '__main__':
    earyx.start(PhaseCurvature)
Esempio n. 4
0
        exp.description = """This is the description of matching experiment"""

        ref = gensin(1000, 1, 0.6, 0, exp.sample_rate)
        srms = rms(ref)
        exp.reference_signal = ref/srms*10**(-30/20)
        exp.reference_signal = hanwin(exp.reference_signal, 0.05)
        exp.pre_signal = 0.1
        exp.between_signal = 0.2
        exp.post_signal = 0.3

    def init_run(self, cur_run):
        """Set signals for reference and pauses between them."""

        cur_run.variable = np.random.randint((-30-10), (-30+10))
        return cur_run

    def init_trial(self, trial):
        """Set signal for variable."""
        trial.test_signal = np.random.randn(0.6*trial.sample_rate)
        trial.test_signal = fft_rect_filt(trial.test_signal,
                                          trial.frequency-50,
                                          trial.frequency+50,
                                          trial.sample_rate)
        
        trial.test_signal = trial.test_signal/rms(trial.test_signal)*10**(trial.variable/20)
        trial.test_signal = hanwin(trial.test_signal, 0.05)
        return trial

if __name__ == '__main__':
    earyx.start(NoiseSineMatch)
Esempio n. 5
0
        exp.gain = 1.0
        exp.calib = 0
        exp.task = "The second tone needs to go (u)p/(d)own"
        exp.ui = "Tui"
        exp.debug = False
        exp.discard_unfinished_runs = False
        exp.allow_debug = True
        exp.feedback = True
        exp.description = """This is the description of matching experiment"""
        exp.visual_indicator = True

    def init_run(self, cur_run):
        """Set signals for reference and pauses between them."""
        print(self.parameters['frequency']['values'][0])
        ref = gensin(self.parameters['frequency']['values'][0],1,1,0,cur_run.sample_rate)
        rms = np.sqrt(np.mean(np.square(ref)))
        cur_run.reference_signal = ref/rms*10**(-30/20)
        cur_run.pre_signal = np.zeros(0.5*cur_run.sample_rate)
        cur_run.between_signal = cur_run.pre_signal
        cur_run.post_signal = cur_run.pre_signal
        return cur_run

    def init_trial(self, trial):
        """Set signal for variable."""
        gain = 2**0.5*10**(trial.variable/20)
        trial.test_signal = gensin(trial.frequency,gain,1,0,trial.sample_rate)
        return trial

if __name__ == '__main__':
    earyx.start(LoudnessMatching)