Esempio n. 1
0
    /// <summary>
    /// Evaluates the ratio based on the collected data.
    /// </summary>
    private float EvaluateRatioAutomatic(Brainwave _BrainwaveType, float _Value)
    {
        int total = 0;
        int min   = -1;
        int max   = -1;

        foreach (MindwaveDataModel data in m_MindwaveData)
        {
            int value = 0;

            switch (_BrainwaveType)
            {
            case Brainwave.Delta:
                value = data.eegPower.delta;
                break;

            case Brainwave.Theta:
                value = data.eegPower.theta;
                break;

            case Brainwave.LowAlpha:
                value = data.eegPower.lowAlpha;
                break;

            case Brainwave.HighAlpha:
                value = data.eegPower.highAlpha;
                break;

            case Brainwave.LowBeta:
                value = data.eegPower.lowBeta;
                break;

            case Brainwave.HighBeta:
                value = data.eegPower.highBeta;
                break;

            case Brainwave.LowGamma:
                value = data.eegPower.lowGamma;
                break;

            case Brainwave.HighGamma:
                value = data.eegPower.highGamma;
                break;

            default:
                break;
            }

            // Apply a coefficient to the value, depending on the quality of the signal to the Mindwave.
            int signalQuality = (MindwaveHelper.NO_SIGNAL_LEVEL - data.poorSignalLevel);
            total += value * (signalQuality / MindwaveHelper.NO_SIGNAL_LEVEL);
            min    = (min == -1) ? value : Mathf.Min(min, value);
            max    = (max == -1) ? value : Mathf.Max(max, value);
        }

        int diff = (max - min);

        return((diff == 0) ? 0 : Mathf.Clamp01((_Value - min) / diff));
    }
Esempio n. 2
0
    /// <summary>
    /// Evaluates the ratio based on defined min/max values for the given brainwave.
    /// </summary>
    private float EvaluateRatioManual(Brainwave _BrainwaveType, float _Value)
    {
        Vector2 minMax = Vector2.zero;

        switch (_BrainwaveType)
        {
        case Brainwave.Delta:
            minMax = m_DeltaWaves;
            break;

        case Brainwave.Theta:
            minMax = m_ThetaWaves;
            break;

        case Brainwave.LowAlpha:
            minMax = m_LowAlphaWaves;
            break;

        case Brainwave.HighAlpha:
            minMax = m_HighAlphaWaves;
            break;

        case Brainwave.LowBeta:
            minMax = m_LowBetaWaves;
            break;

        case Brainwave.HighBeta:
            minMax = m_HighBetaWaves;
            break;

        case Brainwave.LowGamma:
            minMax = m_LowGammaWaves;
            break;

        case Brainwave.HighGamma:
            minMax = m_HighGammaWaves;
            break;
        }

        // On minMax vectors: x = min, y = max
        int diff = (int)(minMax.y - minMax.x);

        return((diff == 0) ? 0 : Mathf.Clamp01((_Value - minMax.x) / diff));
    }
Esempio n. 3
0
    /// <summary>
    /// Evaluate the ratio of the given value, according to the average collected value of the
    /// given brainwave.
    /// Note that a coefficient is applied to each value depending on the "poorSignalLevel" value.
    /// If that value is more or equal to 200 (which means there's no signal), the value will be 0.
    /// </summary>
    /// <param name="_Value">The value you want to evaluate.</param>
    public float EvaluateRatio(Brainwave _BrainwaveType, float _Value)
    {
        float ratio = 0.0f;

        switch (m_DataMode)
        {
        case MindwaveCalibratorMode.Automatic:
            ratio = EvaluateRatioAutomatic(_BrainwaveType, _Value);
            break;

        case MindwaveCalibratorMode.Manual:
            ratio = EvaluateRatioManual(_BrainwaveType, _Value);
            break;

        default:
            break;
        }

        return(ratio);
    }