Beispiel #1
0
        private void IISDetector(object sender, double[][] lfpData, int numReads)
        {
            if (!isTraining)
            {
                if (numReadsRefractory >= totalNumReadsRefractory)
                {
                    for (int i = 0; i < lfpData[channel].Length; ++i)
                    {
                        if (lfpData[channel][i] > threshold)
                        {
                            zap();
                            numReadsRefractory = 1;

#if (USE_LOG_FILE)
                            NeuroRighter nr = (NeuroRighter)sender;
                            //nr.logFile.WriteLine("Zap trigger at index, buffer read (buffer length): " + i + " " + numReads + " (" + lfpData[channel].Length + ")");
                            nr.logFile.Write(((i / 2000.0) + numReads * 0.003).ToString() + " ");
#endif

                            break; //automatically stop checking, supposing we're in refractory
                            //this will break down if the device refresh rate is long
                        }
                    }
                }
                else
                {
                    ++numReadsRefractory;
                }
            }
            else
            {
                threshold += NeuroRighter.rootMeanSquared(lfpData[channel]);
                if (++numReadsTraining >= totalNumReadsTraining)
                {
                    isTraining = false;
                    threshold /= totalNumReadsTraining;
                    threshold *= thresholdMult;
                }
            }
        }