Ejemplo n.º 1
0
        public virtual void SetScanToNETAlignmentData(double[] scanVals, double[] netVals)
        {
            ScanToNETAlignmentData.Clear();

            for (var i = 0; i < scanVals.Length; i++)
            {
                var scanToAdd = (int)(Math.Round(scanVals[i]));

                if (!ScanToNETAlignmentData.ContainsKey(scanToAdd))
                {
                    ScanToNETAlignmentData.Add(scanToAdd, (float)netVals[i]);
                }
            }
        }
Ejemplo n.º 2
0
        private double GetInterpolatedNet(int scanNum)
        {
            if (scanNum < MinLcScan)
            {
                return(MinLcScan);
            }
            var maxScan = MaxLcScan;


            double lowerNET  = 0;
            double upperNET  = 1;
            var    lowerScan = MinLcScan;
            var    upperScan = maxScan;


            var found       = false;
            var currentScan = scanNum;

            while (!found && currentScan >= MinLcScan)
            {
                currentScan--;
                if (ScanToNETAlignmentData.ContainsKey(currentScan))
                {
                    lowerScan = currentScan;
                    lowerNET  = ScanToNETAlignmentData[lowerScan];
                    found     = true;
                }
            }

            found       = false;
            currentScan = scanNum;
            while (!found && currentScan <= maxScan)
            {
                currentScan++;
                if (ScanToNETAlignmentData.ContainsKey(currentScan))
                {
                    upperScan = currentScan;
                    upperNET  = ScanToNETAlignmentData[upperScan];
                    found     = true;
                }
            }

            var slope      = (upperNET - lowerNET) / (upperScan - lowerScan);
            var yintercept = (upperNET - slope * upperScan);

            return(scanNum * slope + yintercept);
        }
Ejemplo n.º 3
0
        public virtual double GetNETValueForScan(int scanNum)
        {
            if (ScanToNETAlignmentData == null || ScanToNETAlignmentData.Count == 0)
            {
                CreateDefaultScanToNETAlignmentData();

                var scanToNETTableIsStillEmpty = ScanToNETAlignmentData == null || ScanToNETAlignmentData.Count == 0;
                if (scanToNETTableIsStillEmpty)
                {
                    throw new ArgumentException("Scan-to-NET table is empty. Tried to create it from Dataset but failed.");
                }
            }

            if (ScanToNETAlignmentData.ContainsKey(scanNum))
            {
                return(ScanToNETAlignmentData[scanNum]);
            }

            return(GetInterpolatedNet(scanNum));
        }
Ejemplo n.º 4
0
        public virtual double GetScanForNet(double net)
        {
            //need to find the two (scan,net) pairs that are the lower and upper boundaries of the input NET
            //then do an intersect

            var closestNETPair = new KeyValuePair <int, float>();


            var lowerScan = MinLcScan;
            var upperScan = MaxLcScan;

            float lowerNET = 0;
            float upperNET = 1;


            //first find the closest ScanNET pair
            var diff = double.MaxValue;

            foreach (var item in ScanToNETAlignmentData)
            {
                var currentDiff = Math.Abs(item.Value - net);
                if (currentDiff < diff)
                {
                    closestNETPair = item;
                    diff           = currentDiff;
                }
            }

            //we found either the point above the inputted NET or below. Need to fill the appropriate lower and upper scan/NET
            var isLowerThanInputNET = closestNETPair.Value <= net;

            if (isLowerThanInputNET)
            {
                lowerScan = closestNETPair.Key;
                lowerNET  = closestNETPair.Value;

                var found       = false;
                var currentScan = lowerScan + 1; //add one and then start looking for next higher scan
                while (!found && currentScan <= MaxLcScan)
                {
                    currentScan++;
                    if (ScanToNETAlignmentData.ContainsKey(currentScan))
                    {
                        upperScan = currentScan;
                        upperNET  = ScanToNETAlignmentData[upperScan];
                        found     = true;
                    }
                }
            }
            else
            {
                upperScan = closestNETPair.Key;
                upperNET  = closestNETPair.Value;

                var found       = false;
                var currentScan = upperScan - 1;

                while (!found && currentScan >= MinLcScan)
                {
                    currentScan--;
                    if (ScanToNETAlignmentData.ContainsKey(currentScan))
                    {
                        lowerScan = currentScan;
                        lowerNET  = ScanToNETAlignmentData[lowerScan];
                        found     = true;
                    }
                }
            }


            if (upperScan <= lowerScan)    //this happens at the MinScan
            {
                return(lowerScan);
            }

            var slope      = (upperNET - lowerNET) / (upperScan - lowerScan);
            var yintercept = (upperNET - slope * upperScan);

            var xvalue = (net - yintercept) / slope;

            if (xvalue < MinLcScan)
            {
                xvalue = MinLcScan;
            }

            if (xvalue > MaxLcScan)
            {
                xvalue = MaxLcScan;
            }

            return(xvalue);
        }