internal void SetSpikeDetector(int spkBufferLength)
        {
            this.spikeBufferLength = spkBufferLength;

            int detectionDeadTime = (int)Math.Round(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                (double)numericUpDown_DeadTime.Value / 1.0e6);
            int minSpikeWidth = (int)Math.Floor(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                (double)numericUpDown_MinSpikeWidth.Value / 1.0e6);
            int maxSpikeWidth = (int)Math.Round(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                (double)numericUpDown_MaxSpikeWidth.Value / 1.0e6);
            double maxSpikeAmp = (double)numericUpDown_MaxSpkAmp.Value / 1.0e6;
            double minSpikeSlope = (double)numericUpDown_MinSpikeSlope.Value / 1.0e6;
            int threshPolarity = detectorParameters.ThresholdPolarity;

            // Repopulate conversion table
            label_deadTimeSamp.Text = detectionDeadTime + " sample(s)";
            label_MinWidthSamp.Text = minSpikeWidth + " sample(s)";
            label_MaxWidthSamp.Text = maxSpikeWidth + " sample(s)";

            // Reset the number of samples
            this.numPre = (int)((double)numPreSamples.Value / 1e6 * Properties.Settings.Default.RawSampleFrequency);
            this.numPost = (int)((double)numPostSamples.Value / 1e6 * Properties.Settings.Default.RawSampleFrequency);
            if (numPre == 0)
                numPre = 1;
            if (numPost == 0)
                numPost = 1;

            // Set the pre/post sample coversion label
            label_PreSampConv.Text =
                numPre + " samples"; ;
            label_PostSampConv.Text =
                numPost + " samples"; ;

            // Half a millisecond to determine spike polarity
            int spikeIntegrationTime = (int)Math.Ceiling(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) / 1000);

            switch (comboBox_noiseEstAlg.SelectedIndex)
            {
                case 0:  //RMS Fixed
                    spikeDetector = new RMSThresholdFixed(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                        numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                        maxSpikeAmp, minSpikeSlope, spikeIntegrationTime, Properties.Settings.Default.ADCPollingPeriodSec, threshPolarity);

                    spikeDetectorRaw = (SpikeDetector)spikeDetector.DeepClone();
                    spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                    break;
                case 1:  //RMS Adaptive
                    spikeDetector = new AdaptiveRMSThreshold(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                        numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                        maxSpikeAmp, minSpikeSlope, spikeIntegrationTime, Properties.Settings.Default.ADCPollingPeriodSec, threshPolarity);

                    spikeDetectorRaw = (SpikeDetector)spikeDetector.DeepClone();
                    spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                    break;
                case 2:  //Limada
                    spikeDetector = new LimAda(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                        numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                        maxSpikeWidth, minSpikeSlope, spikeIntegrationTime, Convert.ToInt32(Properties.Settings.Default.RawSampleFrequency), threshPolarity);

                    spikeDetectorRaw = (SpikeDetector)spikeDetector.DeepClone();
                    spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                    break;
                default:
                    break;
            }

            switch (comboBox_spikeDetAlg.SelectedIndex)
            {
                case 0:  //auto-aligner
                    numericUpDown_MaxSpikeWidth.Enabled = true;
                    numericUpDown_MinSpikeWidth.Enabled = true;
                    detectorType = 0;
                    break;
                case 1:  //simple
                    numericUpDown_MaxSpikeWidth.Enabled = false;
                    numericUpDown_MinSpikeWidth.Enabled = false;
                    detectorType = 1;
                    break;
                default:
                    break;
            }

            spikeDetectionLag = spikeDetector.serverLag;
        }
Beispiel #2
0
        internal void SetSpikeDetector(int spkBufferLength)
        {
            this.spikeBufferLength = spkBufferLength;

            int detectionDeadTime = (int)Math.Round(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                                                    (double)numericUpDown_DeadTime.Value / 1.0e6);
            int minSpikeWidth = (int)Math.Floor(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                                                (double)numericUpDown_MinSpikeWidth.Value / 1.0e6);
            int maxSpikeWidth = (int)Math.Round(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) *
                                                (double)numericUpDown_MaxSpikeWidth.Value / 1.0e6);
            double maxSpikeAmp    = (double)numericUpDown_MaxSpkAmp.Value / 1.0e6;
            double minSpikeSlope  = (double)numericUpDown_MinSpikeSlope.Value / 1.0e6;
            int    threshPolarity = detectorParameters.ThresholdPolarity;

            // Repopulate conversion table
            label_deadTimeSamp.Text = detectionDeadTime + " sample(s)";
            label_MinWidthSamp.Text = minSpikeWidth + " sample(s)";
            label_MaxWidthSamp.Text = maxSpikeWidth + " sample(s)";

            // Reset the number of samples
            this.numPre  = (int)((double)numPreSamples.Value / 1e6 * Properties.Settings.Default.RawSampleFrequency);
            this.numPost = (int)((double)numPostSamples.Value / 1e6 * Properties.Settings.Default.RawSampleFrequency);
            if (numPre == 0)
            {
                numPre = 1;
            }
            if (numPost == 0)
            {
                numPost = 1;
            }

            // Set the pre/post sample coversion label
            label_PreSampConv.Text =
                numPre + " samples";;
            label_PostSampConv.Text =
                numPost + " samples";;

            // Half a millisecond to determine spike polarity
            int spikeIntegrationTime = (int)Math.Ceiling(Convert.ToDouble(Properties.Settings.Default.RawSampleFrequency) / 1000);

            switch (comboBox_noiseEstAlg.SelectedIndex)
            {
            case 0:      //RMS Fixed
                spikeDetector = new RMSThresholdFixed(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                                                      numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                                                      maxSpikeAmp, minSpikeSlope, spikeIntegrationTime, Properties.Settings.Default.ADCPollingPeriodSec, threshPolarity);

                spikeDetectorRaw   = (SpikeDetector)spikeDetector.DeepClone();
                spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                break;

            case 1:      //RMS Adaptive
                spikeDetector = new AdaptiveRMSThreshold(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                                                         numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                                                         maxSpikeAmp, minSpikeSlope, spikeIntegrationTime, Properties.Settings.Default.ADCPollingPeriodSec, threshPolarity);

                spikeDetectorRaw   = (SpikeDetector)spikeDetector.DeepClone();
                spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                break;

            case 2:      //Limada
                spikeDetector = new LimAda(spikeBufferLength, numChannels, 2, numPre + numPost + 1, numPost,
                                           numPre, (rawType)Convert.ToDouble(thresholdMultiplier.Value), detectionDeadTime, minSpikeWidth, maxSpikeWidth,
                                           maxSpikeWidth, minSpikeSlope, spikeIntegrationTime, Convert.ToInt32(Properties.Settings.Default.RawSampleFrequency), threshPolarity);

                spikeDetectorRaw   = (SpikeDetector)spikeDetector.DeepClone();
                spikeDetectorSalpa = (SpikeDetector)spikeDetector.DeepClone();

                break;

            default:
                break;
            }

            switch (comboBox_spikeDetAlg.SelectedIndex)
            {
            case 0:      //auto-aligner
                numericUpDown_MaxSpikeWidth.Enabled = true;
                numericUpDown_MinSpikeWidth.Enabled = true;
                detectorType = 0;
                break;

            case 1:      //simple
                numericUpDown_MaxSpikeWidth.Enabled = false;
                numericUpDown_MinSpikeWidth.Enabled = false;
                detectorType = 1;
                break;

            default:
                break;
            }

            spikeDetectionLag = spikeDetector.serverLag;
        }