예제 #1
0
        public Duo<List<SliceInfo>> Slice(double[] pulseSequence, IList<int> crestIndices) {
            if (crestIndices.Count <= 1) throw new SliceException();
            var tuple = Group(crestIndices);
            var sliceLength = Ruler.MeasureSliceLength(crestIndices, pulseSequence.Length);
            IList<int> startIndices1, startIndices2;

            var crestOffset = Aligner.CrestIndex(_minPtsCntBeforeCrest, sliceLength);
            if (
                SimpleSlicer.FindStartIndices(pulseSequence, tuple.Item1, sliceLength, crestOffset, out startIndices1) &&
                SimpleSlicer.FindStartIndices(pulseSequence, tuple.Item2, sliceLength, crestOffset, out startIndices2)) {
                return Duo.Create(startIndices1, startIndices2)
                    .Select(ints => ints.Select(i => new SliceInfo(i, sliceLength, crestOffset)).ToList())
                    .ToDuo();
            }
            throw new SliceException();
        }
예제 #2
0
        public List <SliceInfo> Slice(double[] pulseSequence, IList <int> crestIndices)
        {
            if (crestIndices.IsEmpty())
            {
                return(new List <SliceInfo>(0));
            }

            var sliceLength = Ruler.MeasureSliceLength(crestIndices, pulseSequence.Length);

            /*if (crestIndices.Count == 1) {
             *  // todo should abandon?
             *  return new List<SliceInfo>(1) { new SliceInfo(0, sliceLength, crestIndices[0]) };
             * }*/
            var crestOffset = Aligner.CrestIndex(_minPtsCntBeforeCrest, sliceLength);

            IList <int> startIndices;

            return(FindStartIndices(pulseSequence, crestIndices, sliceLength, crestOffset, out startIndices)
                ? startIndices.Select(index => new SliceInfo(index, sliceLength, crestOffset)).ToList()
                : new List <SliceInfo>(0));
        }