void OnReceiveEEGFeatureIndexes(EEGFeatureIndex featureIndexData)
        {
            double deltaValue = featureIndexData.Delta(visualizer.SelectChannel);
            double thetaValue = featureIndexData.Theta(visualizer.SelectChannel);
            double alphaValue = featureIndexData.Alpha(visualizer.SelectChannel);
            double betaValue  = featureIndexData.Beta(visualizer.SelectChannel);
            double gammaValue = featureIndexData.Gamma(visualizer.SelectChannel);

            delta.value = (double.IsInfinity(deltaValue) || double.IsNaN(deltaValue)) ? 0.0f : LooxidLinkUtility.Scale(delta.min, delta.max, 0.0f, 1.0f, deltaValue);
            theta.value = (double.IsInfinity(thetaValue) || double.IsNaN(thetaValue)) ? 0.0f : LooxidLinkUtility.Scale(theta.min, theta.max, 0.0f, 1.0f, thetaValue);
            alpha.value = (double.IsInfinity(alphaValue) || double.IsNaN(alphaValue)) ? 0.0f : LooxidLinkUtility.Scale(alpha.min, alpha.max, 0.0f, 1.0f, alphaValue);
            beta.value  = (double.IsInfinity(betaValue) || double.IsNaN(betaValue)) ? 0.0f : LooxidLinkUtility.Scale(beta.min, beta.max, 0.0f, 1.0f, betaValue);
            gamma.value = (double.IsInfinity(gammaValue) || double.IsNaN(gammaValue)) ? 0.0f : LooxidLinkUtility.Scale(gamma.min, gamma.max, 0.0f, 1.0f, gammaValue);
        }
Ejemplo n.º 2
0
        private List <double> GetFeatureDataList(EEGSensorID sensorID, FeatureIndexEnum featureIndex)
        {
            List <double>          dataList         = new List <double>();
            List <double>          ScaleDataList    = new List <double>();
            List <EEGFeatureIndex> featureScaleList = LooxidLinkData.Instance.GetEEGFeatureIndexData(10.0f);

            if (featureScaleList.Count > 0)
            {
                for (int i = 0; i < featureScaleList.Count; i++)
                {
                    if (featureIndex == FeatureIndexEnum.DELTA && !double.IsNaN(featureScaleList[i].Delta(sensorID)))
                    {
                        ScaleDataList.Add(featureScaleList[i].Delta(sensorID));
                    }
                    if (featureIndex == FeatureIndexEnum.THETA && !double.IsNaN(featureScaleList[i].Theta(sensorID)))
                    {
                        ScaleDataList.Add(featureScaleList[i].Theta(sensorID));
                    }
                    if (featureIndex == FeatureIndexEnum.ALPHA && !double.IsNaN(featureScaleList[i].Alpha(sensorID)))
                    {
                        ScaleDataList.Add(featureScaleList[i].Alpha(sensorID));
                    }
                    if (featureIndex == FeatureIndexEnum.BETA && !double.IsNaN(featureScaleList[i].Beta(sensorID)))
                    {
                        ScaleDataList.Add(featureScaleList[i].Beta(sensorID));
                    }
                    if (featureIndex == FeatureIndexEnum.GAMMA && !double.IsNaN(featureScaleList[i].Gamma(sensorID)))
                    {
                        ScaleDataList.Add(featureScaleList[i].Gamma(sensorID));
                    }
                }
            }

            List <EEGFeatureIndex> featureDataList = LooxidLinkData.Instance.GetEEGFeatureIndexData(8.0f);

            if (featureDataList.Count > 0)
            {
                double min = Min(ScaleDataList);
                double max = Max(ScaleDataList);

                int numIndexList = 6 * linkFequency;
                for (int i = 0; i < featureDataList.Count; i++)
                {
                    if (i < numIndexList)
                    {
                        if (featureIndex == FeatureIndexEnum.DELTA)
                        {
                            double delta = double.IsNaN(featureDataList[i].Delta(sensorID)) ? 0.0 : LooxidLinkUtility.Scale(min, max, 0.0f, 1.0f, featureDataList[i].Delta(sensorID));
                            dataList.Add(delta);
                        }
                        if (featureIndex == FeatureIndexEnum.THETA)
                        {
                            double theta = double.IsNaN(featureDataList[i].Theta(sensorID)) ? 0.0 : LooxidLinkUtility.Scale(min, max, 0.0f, 1.0f, featureDataList[i].Theta(sensorID));
                            dataList.Add(theta);
                        }
                        if (featureIndex == FeatureIndexEnum.ALPHA)
                        {
                            double alpha = double.IsNaN(featureDataList[i].Alpha(sensorID)) ? 0.0 : LooxidLinkUtility.Scale(min, max, 0.0f, 1.0f, featureDataList[i].Alpha(sensorID));
                            dataList.Add(alpha);
                        }
                        if (featureIndex == FeatureIndexEnum.BETA)
                        {
                            double beta = double.IsNaN(featureDataList[i].Beta(sensorID)) ? 0.0 : LooxidLinkUtility.Scale(min, max, 0.0f, 1.0f, featureDataList[i].Beta(sensorID));
                            dataList.Add(beta);
                        }
                        if (featureIndex == FeatureIndexEnum.GAMMA)
                        {
                            double gamma = double.IsNaN(featureDataList[i].Gamma(sensorID)) ? 0.0 : LooxidLinkUtility.Scale(min, max, 0.0f, 1.0f, featureDataList[i].Gamma(sensorID));
                            dataList.Add(gamma);
                        }
                    }
                }
            }
            return(dataList);
        }
 void OnReceiveMindIndexes(MindIndex mindIndexData)
 {
     leftActivity.value  = double.IsNaN(mindIndexData.leftActivity) ? 0.0f : (float)LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexData.leftActivity);
     rightActivity.value = double.IsNaN(mindIndexData.rightActivity) ? 0.0f : (float)LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexData.rightActivity);
     attention.value     = double.IsNaN(mindIndexData.attention) ? 0.0f : (float)LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexData.attention);
     relaxation.value    = double.IsNaN(mindIndexData.relaxation) ? 0.0f : (float)LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexData.relaxation);
 }
Ejemplo n.º 4
0
        IEnumerator DisplayData()
        {
            while (this.gameObject.activeSelf)
            {
                yield return(new WaitForSeconds(0.1f));

                // Device Status: Connected Status
                if (ConnectedText[0] != null)
                {
                    ConnectedText[0].text  = (LooxidLinkManager.Instance.isLinkHubConnected) ? "Connected" : "Disconnected";
                    ConnectedText[0].color = (LooxidLinkManager.Instance.isLinkHubConnected) ? ConnectedColor : DisconnectedColor;
                }
                if (ConnectedImage[0] != null)
                {
                    ConnectedImage[0].sprite = (LooxidLinkManager.Instance.isLinkHubConnected) ? ConnectedSprite[0] : ConnectedSprite[1];
                }
                if (ConnectedText[1] != null)
                {
                    ConnectedText[1].text  = (LooxidLinkManager.Instance.isLinkCoreConnected) ? "Connected" : "Disconnected";
                    ConnectedText[1].color = (LooxidLinkManager.Instance.isLinkCoreConnected) ? ConnectedColor : DisconnectedColor;
                }
                if (ConnectedImage[1] != null)
                {
                    ConnectedImage[1].sprite = (LooxidLinkManager.Instance.isLinkCoreConnected) ? ConnectedSprite[0] : ConnectedSprite[1];
                }

                // Device Status: Sensor Status
                if (sensorStatusData != null)
                {
                    int numChannel = System.Enum.GetValues(typeof(EEGSensorID)).Length;
                    for (int i = 0; i < numChannel; i++)
                    {
                        bool isSensorOn = sensorStatusData.IsSensorOn((EEGSensorID)i);
                        if (SensorStatusText[i] != null)
                        {
                            SensorStatusText[i].text   = isSensorOn ? "ON" : "OFF";
                            SensorStatusText[i].color  = isSensorOn ? ConnectedColor : DisconnectedColor;
                            SensorStatusImage[i].color = isSensorOn ? ConnectedColor : DisconnectedColor;
                        }
                    }
                }


                // Mind Indexes: Indicators
                LeftActivityIndicator.SetValue((float)leftActivity.value);
                RightActivityIndicator.SetValue((float)rightActivity.value);
                AttentionIndicator.SetValue((float)attention.value);
                RelaxationIndicator.SetValue((float)relaxation.value);
                AsymmetryText.text = asymmetry.value.ToString("F3");


                // Mind Indexes: Charts
                List <double>    leftActivityDataList  = new List <double>();
                List <double>    rightActivityDataList = new List <double>();
                List <double>    attentionDataList     = new List <double>();
                List <double>    relaxationDataList    = new List <double>();
                int              numIndexList          = 5 * linkFequency;
                List <MindIndex> mindIndexList         = LooxidLinkData.Instance.GetMindIndexData(7.0f);
                for (int i = 0; i < mindIndexList.Count; i++)
                {
                    if (i < numIndexList)
                    {
                        double mindLeftActivity  = (double.IsNaN(mindIndexList[i].leftActivity)) ? 0.0f : LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexList[i].leftActivity);
                        double mindRightActivity = (double.IsNaN(mindIndexList[i].rightActivity)) ? 0.0f : LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexList[i].rightActivity);
                        double mindAttention     = (double.IsNaN(mindIndexList[i].attention)) ? 0.0f : LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexList[i].attention);
                        double mindRelaxation    = (double.IsNaN(mindIndexList[i].relaxation)) ? 0.0f : LooxidLinkUtility.Scale(LooxidLink.MIND_INDEX_SCALE_MIN, LooxidLink.MIND_INDEX_SCALE_MAX, 0.0f, 1.0f, mindIndexList[i].relaxation);
                        leftActivityDataList.Add(mindLeftActivity);
                        rightActivityDataList.Add(mindRightActivity);
                        attentionDataList.Add(mindAttention);
                        relaxationDataList.Add(mindRelaxation);
                    }
                }
                leftActivityDataList.Reverse();
                rightActivityDataList.Reverse();
                attentionDataList.Reverse();
                relaxationDataList.Reverse();

                if (LeftActivityChart != null)
                {
                    LeftActivityChart.SetValue(leftActivityDataList.ToArray());
                }
                if (RightActivityChart != null)
                {
                    RightActivityChart.SetValue(rightActivityDataList.ToArray());
                }
                if (AttentionChart != null)
                {
                    AttentionChart.SetValue(attentionDataList.ToArray());
                }
                if (RelaxationChart != null)
                {
                    RelaxationChart.SetValue(relaxationDataList.ToArray());
                }

                // Feature Indexes: Charts
                int numIndexes = System.Enum.GetValues(typeof(FeatureIndexEnum)).Length;
                for (int i = 0; i < numIndexes; i++)
                {
                    FeatureIndexCharts[i].SetValue(GetFeatureDataList(SelectFeatureSensorID, (FeatureIndexEnum)i).ToArray());
                }
            }
        }