void FixedUpdate()
        {
            if (!LooxidLinkManager.Instance.isLinkCoreConnected)
            {
                return;
            }

            gravity         = Mathf.Lerp(gravity, targetGravity, 0.1f);
            Physics.gravity = new Vector3(0, gravity, 0f);

            float value = 0.0f;

            if (selectInteraction == InteractionData.ATTENTION)
            {
                value = (float)attention.value;
            }
            else if (selectInteraction == InteractionData.RELAXATION)
            {
                value = (float)relaxation.value;
            }
            else if (selectInteraction == InteractionData.LEFT_ACTIVTY)
            {
                value = (float)leftActivity.value;
            }
            else if (selectInteraction == InteractionData.RIGHT_ACTIVITY)
            {
                value = (float)rightActivity.value;
            }
            else if (selectInteraction == InteractionData.DELTA_INDEX)
            {
                List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);
                if (featureIndexList.Count > 0)
                {
                    List <double> deltaScaleDataList = new List <double>();
                    for (int i = 0; i < featureIndexList.Count; i++)
                    {
                        double deltaValue = featureIndexList[i].Delta(visualizer.SelectChannel);

                        if (!double.IsInfinity(deltaValue) && !double.IsNaN(deltaValue))
                        {
                            deltaScaleDataList.Add(deltaValue);
                        }
                    }
                    delta.SetScale(deltaScaleDataList);
                }
                value = (float)delta.value;
            }
            else if (selectInteraction == InteractionData.THETA_INDEX)
            {
                List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);
                if (featureIndexList.Count > 0)
                {
                    List <double> thetaScaleDataList = new List <double>();
                    for (int i = 0; i < featureIndexList.Count; i++)
                    {
                        double thetaValue = featureIndexList[i].Theta(visualizer.SelectChannel);

                        if (!double.IsInfinity(thetaValue) && !double.IsNaN(thetaValue))
                        {
                            thetaScaleDataList.Add(thetaValue);
                        }
                    }
                    theta.SetScale(thetaScaleDataList);
                }
                value = (float)theta.value;
            }
            else if (selectInteraction == InteractionData.ALPHA_INDEX)
            {
                List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);
                if (featureIndexList.Count > 0)
                {
                    List <double> alphaScaleDataList = new List <double>();
                    for (int i = 0; i < featureIndexList.Count; i++)
                    {
                        double alphaValue = featureIndexList[i].Alpha(visualizer.SelectChannel);

                        if (!double.IsInfinity(alphaValue) && !double.IsNaN(alphaValue))
                        {
                            alphaScaleDataList.Add(alphaValue);
                        }
                    }
                    alpha.SetScale(alphaScaleDataList);
                }
                value = (float)alpha.value;
            }
            else if (selectInteraction == InteractionData.BETA_INDEX)
            {
                List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);
                if (featureIndexList.Count > 0)
                {
                    List <double> betaScaleDataList = new List <double>();
                    for (int i = 0; i < featureIndexList.Count; i++)
                    {
                        double betaValue = featureIndexList[i].Beta(visualizer.SelectChannel);

                        if (!double.IsInfinity(betaValue) && !double.IsNaN(betaValue))
                        {
                            betaScaleDataList.Add(betaValue);
                        }
                    }
                    beta.SetScale(betaScaleDataList);
                }
                value = (float)beta.value;
            }
            else if (selectInteraction == InteractionData.GAMMA_INDEX)
            {
                List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);
                if (featureIndexList.Count > 0)
                {
                    List <double> gammaScaleDataList = new List <double>();
                    for (int i = 0; i < featureIndexList.Count; i++)
                    {
                        double gammaValue = featureIndexList[i].Gamma(visualizer.SelectChannel);

                        if (!double.IsInfinity(gammaValue) && !double.IsNaN(gammaValue))
                        {
                            gammaScaleDataList.Add(gammaValue);
                        }
                    }
                    beta.SetScale(gammaScaleDataList);
                }
                value = (float)gamma.value;
            }

            powerData.Add(value);
        }
Ejemplo n.º 2
0
        IEnumerator DisplayData()
        {
            while (this.gameObject.activeSelf)
            {
                yield return(new WaitForSeconds(0.1f));

                if (this.SelectTab == Tab2DVisualizer.SENSOR_STATUS)
                {
                    if (sensorStatusData != null)
                    {
                        Color32 offColor = new Color32(64, 64, 64, 255);

                        AF3SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.AF3) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                        AF4SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.AF4) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                        Fp1SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.Fp1) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                        Fp2SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.Fp2) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                        AF7SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.AF7) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                        AF8SensorImage.color = sensorStatusData.IsSensorOn(EEGSensorID.AF8) ? (Color)LooxidLinkManager.linkColor : (Color)offColor;
                    }
                }
                else if (this.SelectTab == Tab2DVisualizer.MIND_INDEX)
                {
                    LeftActivityIndicator.SetValue((float)leftActivity.value);
                    RightActivityIndicator.SetValue((float)rightActivity.value);
                    AttentionIndicator.SetValue((float)attention.value);
                    RelaxationIndicator.SetValue((float)relaxation.value);
                }
                else if (this.SelectTab == Tab2DVisualizer.FEATURE_INDEX)
                {
                    List <EEGFeatureIndex> featureIndexList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);

                    if (featureIndexList.Count > 0)
                    {
                        List <double> deltaScaleDataList = new List <double>();
                        List <double> thetaScaleDataList = new List <double>();
                        List <double> alphaScaleDataList = new List <double>();
                        List <double> betaScaleDataList  = new List <double>();
                        List <double> gammaScaleDataList = new List <double>();

                        for (int i = 0; i < featureIndexList.Count; i++)
                        {
                            double deltaValue = featureIndexList[i].Delta(SelectChannel);
                            double thetaValue = featureIndexList[i].Theta(SelectChannel);
                            double alphaValue = featureIndexList[i].Alpha(SelectChannel);
                            double betaValue  = featureIndexList[i].Beta(SelectChannel);
                            double gammaValue = featureIndexList[i].Gamma(SelectChannel);

                            if (!double.IsInfinity(deltaValue) && !double.IsNaN(deltaValue))
                            {
                                deltaScaleDataList.Add(deltaValue);
                            }
                            if (!double.IsInfinity(thetaValue) && !double.IsNaN(thetaValue))
                            {
                                thetaScaleDataList.Add(thetaValue);
                            }
                            if (!double.IsInfinity(alphaValue) && !double.IsNaN(alphaValue))
                            {
                                alphaScaleDataList.Add(alphaValue);
                            }
                            if (!double.IsInfinity(betaValue) && !double.IsNaN(betaValue))
                            {
                                betaScaleDataList.Add(betaValue);
                            }
                            if (!double.IsInfinity(gammaValue) && !double.IsNaN(gammaValue))
                            {
                                gammaScaleDataList.Add(gammaValue);
                            }
                        }

                        delta.SetScale(deltaScaleDataList);
                        theta.SetScale(thetaScaleDataList);
                        alpha.SetScale(alphaScaleDataList);
                        beta.SetScale(betaScaleDataList);
                        gamma.SetScale(gammaScaleDataList);
                    }

                    DeltaIndicator.SetValue((float)delta.value);
                    ThetaIndicator.SetValue((float)theta.value);
                    AlphaIndicator.SetValue((float)alpha.value);
                    BetaIndicator.SetValue((float)beta.value);
                    GammaIndicator.SetValue((float)gamma.value);
                }
            }
        }