Exemplo n.º 1
0
        public SampleCollection GetBaseline(double alpha, double normalityAmp, int startSectionLength)
        {
            Baseline baseline = Baseline.CreateBaseline(_points.Select(p => (long)p.Y).ToList(), 7, startSectionLength, alpha, normalityAmp);

            var points = new List <MyPoint>();

            for (int i = 0; i < baseline.Averages.Count; ++i)
            {
                points.Add(new MyPoint(_points[i].X, baseline.Averages[i]));
            }

            var col = new SampleCollection(points);

            return(col);
        }
Exemplo n.º 2
0
        //private SubtitleInfo GetFixedSubtitle(SubtitleInfo subtitlToFix, List<KeyValuePair<LineInfo, LineInfo>> orderedMatchPoints, List<double> matchPointsDiffsFromGoodSync)
        //{
        //    var subtitle = subtitlToFix.CloneSub();
        //    int idx = 0;
        //    //attach average to actual timestamps
        //    foreach (var item in orderedMatchPoints)
        //    {
        //        item.Key.TimeStamp.IsOffsetCorrected = true;
        //        item.Key.TimeStamp.Correction = (long)matchPointsDiffsFromGoodSync[idx];
        //        ++idx;
        //    }

        //    //spread correction to all timestamps (including the ones not attached)
        //    long prevOffset = (long)matchPointsDiffsFromGoodSync[0];
        //    TimeStamp prev = null;

        //    foreach (var time in subtitle.TimeMarkers)
        //    {
        //        if (!time.IsOffsetCorrected)
        //        {
        //            var next = subtitle.Lines.Where(p => p.TimeStamp.FromTime > time.FromTime).FirstOrDefault(x => x.TimeStamp.IsOffsetCorrected);
        //            var currTime = time;
        //            var prevTime = prev;
        //            double newOffset = prevOffset;

        //            if (prevTime != null && next != null)
        //            {
        //                var nextTime = next.TimeStamp;

        //                //timeAfterPrev / timeInterval (=next-prev) = the precentage of movement in the X axis between the two points
        //                double part = ((double)currTime.FromTime - (double)prevTime.FromTime) / ((double)nextTime.FromTime - (double)prevTime.FromTime);

        //                //(change in corrections between prev -> next) * (calculated place between them =part) + (the base correction of prev =the stating point of this correction)
        //                newOffset = (((double)nextTime.Correction - (double)prev.Correction) * part) + (double)prevTime.Correction;
        //            }

        //            time.IsOffsetCorrected = true;
        //            time.Correction = (long)newOffset;
        //        }
        //        else
        //        {
        //            prevOffset = time.Correction;
        //            prev = time;
        //        }

        //        //extend duration for all subs
        //        time.Duration = (long)(TimeStampDurationMultiplyer * (double)time.Duration);
        //    }
        //    return subtitle;
        //}

        private List <KeyValuePair <LineInfo, LineInfo> > CalculateDiffAndBaseline(List <KeyValuePair <LineInfo, LineInfo> > ordered, out List <long> dataset2, out List <double> averages)
        {
            dataset2 = ordered.Select(x => x.Value.TimeStamp.FromTime - x.Key.TimeStamp.FromTime).ToList();

            var baseline = Baseline.CreateBaseline(dataset2, 7, (int)StartSectionLength, BaselineAlgAlpha, NormalZoneAmplitude);

            averages = baseline.Averages;

            //fix collections to remove abnormal values in preperation for using them in the sync later
            if (RemoveAbnormalPoints)
            {
                averages = averages.Where((p, i) => (!baseline.AbnormalPoints.Contains(i))).ToList();
                ordered  = ordered.Where((p, i) => (!baseline.AbnormalPoints.Contains(i))).ToList();
                dataset2 = dataset2.Where((p, i) => (!baseline.AbnormalPoints.Contains(i))).ToList();
                baseline = Baseline.CreateBaseline(dataset2, 7, (int)StartSectionLength, BaselineAlgAlpha, 3);
                averages = baseline.Averages;
            }

            return(ordered);
        }
Exemplo n.º 3
0
        public SampleCollection FilterAbnormalsByBaseline(double alpha, double normalityAmp, int startSectionLength)
        {
            Baseline baseline = Baseline.CreateBaseline(_points.Select(p => (long)p.Y).ToList(), 7, startSectionLength, alpha, normalityAmp);

            var points = new List <MyPoint>();

            for (int i = 0; i < baseline.Averages.Count; ++i)
            {
                if (!baseline.AbnormalPoints.Contains(i))
                {
                    points.Add(new MyPoint(_points[i].X, _points[i].Y));
                }
            }

            var col = new SampleCollection(points);

            col._pointDescByXValue = this._pointDescByXValue;

            return(col);
        }