Example #1
0
void UnhideTrigger::pollMouse()
{
    QPoint pos = QCursor::pos();
    for(int s = 0; s < QApplication::desktop()->numScreens(); s++)
    {
        QRect r = QApplication::desktop()->screenGeometry(s);
        if(pos.x() == r.left())
        {
            if(pos.y() == r.top())
            {
                emitTrigger(TopLeft, s);
            }
            else if(pos.y() == r.bottom())
            {
                emitTrigger(BottomLeft, s);
            }
            else
            {
                emitTrigger(Left, s);
            }
        }
        else if(pos.x() == r.right())
        {
            if(pos.y() == r.top())
            {
                emitTrigger(TopRight, s);
            }
            else if(pos.y() == r.bottom())
            {
                emitTrigger(BottomRight, s);
            }
            else
            {
                emitTrigger(Right, s);
            }
        }
        else if(pos.y() == r.top())
        {
            emitTrigger(Top, s);
        }
        else if(pos.y() == r.bottom())
        {
            emitTrigger(Bottom, s);
        }
        else if(_lastTrigger != None)
        {
            emitTrigger(None, -1);
        }
    }
}
void ProbabilityEstimator::step()
{
        m_delay -= GetGlobalDt();
        if (m_flag && m_delay <= 0.0) {
                double weight;
                int spike;
                if (fabs(m_tPrevSpike - m_tPrevStim) < PE_WNDW) // the spike arrived within the window time after the stimulation
                        spike = 1;
                else
                        spike = 0;
                weight = exp(-PE_T/PE_TAU);
                m_probability = (1-weight)*spike + weight*m_probability;
                emitTrigger();
                Logger(Important, "ProbabilityEstimator(%d): estimated probability: %g\n", id(), m_probability);
                m_flag = false;
        }
}
void FrequencyEstimator::handleEvent(const Event *event)
{
    double now = event->time();
    switch(event->type())
    {
    case SPIKE:
        if(m_tPrevSpike > 0 && m_state) {
            double isi, weight;
            isi = now - m_tPrevSpike;
            weight = exp(-isi/FE_TAU);
            m_frequency = (1-weight)/isi + weight*m_frequency;
            emitTrigger();
            Logger(Debug, "FrequencyEstimator(%d): Estimated frequency: %g\n", id(), m_frequency);
        }
        m_tPrevSpike = now; // Updates last spike also when TOGGLE is off.
        break;
    case TOGGLE:
        changeState();
        Logger(Debug, "FrequencyEstimator(%d): Toggled at %9.3f.\n", id(), GetGlobalTime());
        break;
    }
}