//Reset LFP filter private void resetLFPFilter() { rawType Fs; if (Properties.Settings.Default.SeparateLFPBoard) { Fs = Properties.Settings.Default.LFPSampleFrequency; } else { Fs = Properties.Settings.Default.RawSampleFrequency; } if (lfpFilter != null) { lock (lfpFilter) { for (int i = 0; i < lfpFilter.Length; ++i) { //lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, // Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value)); if (Properties.Settings.Default.SeparateLFPBoard) { lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), lfpBufferLength); } else { lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), spikeBufferLength); } } } } else //lfpFilter is uninitialized { //lfpFilter = new BesselBandpassFilter[numChannels]; lfpFilter = new ButterworthFilter[numChannels]; for (int i = 0; i < numChannels; ++i) { //lfpFilter[i] = new BesselBandpassFilter((int)LFPFiltOrder.Value, Convert.ToDouble(textBox_lfpSamplingRate.Text), // Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value)); if (Properties.Settings.Default.SeparateLFPBoard) { lfpFilter[i] = new ButterworthFilter((int)LFPFiltOrder.Value, Properties.Settings.Default.LFPSampleFrequency, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), lfpBufferLength); } else { lfpFilter[i] = new ButterworthFilter((int)LFPFiltOrder.Value, Properties.Settings.Default.LFPSampleFrequency, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), spikeBufferLength); } } } }
public void Reset(int order, rawType samplingRate, rawType lowCut, rawType highCut, int bufferSize) { lock (this) { dcof = ButterworthFilter.dcof_bwbp(order, (rawType)(lowCut / (samplingRate * 0.5)), (rawType)(highCut / (samplingRate * 0.5))); ccof = ButterworthFilter.ccof_bwbp(order, (rawType)(lowCut / (samplingRate * 0.5)), (rawType)(highCut / (samplingRate * 0.5))); //for (int i = 0; i < dcof.Length; ++i) // dcof[i] = -dcof[i]; //Since you always subtract dcof lastInput = new rawType[ccof.Length - 1]; lastInput.Initialize(); lastOutput = new rawType[ccof.Length - 1]; lastOutput.Initialize(); oldData = new rawType[bufferSize]; } }
//Reset spike filter private void resetSpikeFilter() { if (spikeFilter != null) { lock (spikeFilter) { for (int i = 0; i < spikeFilter.Length; ++i) { spikeFilter[i].Reset((int)SpikeFiltOrder.Value, Properties.Settings.Default.RawSampleFrequency, Convert.ToDouble(SpikeLowCut.Value), Convert.ToDouble(SpikeHighCut.Value), spikeBufferLength); } } } else //spikeFilter is uninitialized { spikeFilter = new ButterworthFilter[numChannels]; for (int i = 0; i < numChannels; ++i) { spikeFilter[i] = new ButterworthFilter((int)SpikeFiltOrder.Value, Properties.Settings.Default.RawSampleFrequency, Convert.ToDouble(SpikeLowCut.Value), Convert.ToDouble(SpikeHighCut.Value), spikeBufferLength); } } }
//Reset spike filter private void resetSpikeFilter() { if (spikeFilter != null) { lock (spikeFilter) { for (int i = 0; i < spikeFilter.Length; ++i) spikeFilter[i].Reset((int)SpikeFiltOrder.Value, Properties.Settings.Default.RawSampleFrequency, Convert.ToDouble(SpikeLowCut.Value), Convert.ToDouble(SpikeHighCut.Value), spikeBufferLength); } } else //spikeFilter is uninitialized { spikeFilter = new ButterworthFilter[numChannels]; for (int i = 0; i < numChannels; ++i) spikeFilter[i] = new ButterworthFilter((int)SpikeFiltOrder.Value, Properties.Settings.Default.RawSampleFrequency, Convert.ToDouble(SpikeLowCut.Value), Convert.ToDouble(SpikeHighCut.Value), spikeBufferLength); } }
//Reset LFP filter private void resetLFPFilter() { rawType Fs; if (Properties.Settings.Default.SeparateLFPBoard) Fs = Properties.Settings.Default.LFPSampleFrequency; else Fs = Properties.Settings.Default.RawSampleFrequency; if (lfpFilter != null) { lock (lfpFilter) { for (int i = 0; i < lfpFilter.Length; ++i) //lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, // Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value)); if (Properties.Settings.Default.SeparateLFPBoard) lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), lfpBufferLength); else lfpFilter[i].Reset((int)LFPFiltOrder.Value, Fs, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), spikeBufferLength); } } else //lfpFilter is uninitialized { //lfpFilter = new BesselBandpassFilter[numChannels]; lfpFilter = new ButterworthFilter[numChannels]; for (int i = 0; i < numChannels; ++i) //lfpFilter[i] = new BesselBandpassFilter((int)LFPFiltOrder.Value, Convert.ToDouble(textBox_lfpSamplingRate.Text), // Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value)); if (Properties.Settings.Default.SeparateLFPBoard) lfpFilter[i] = new ButterworthFilter((int)LFPFiltOrder.Value, Properties.Settings.Default.LFPSampleFrequency, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), lfpBufferLength); else lfpFilter[i] = new ButterworthFilter((int)LFPFiltOrder.Value, Properties.Settings.Default.LFPSampleFrequency, Convert.ToDouble(LFPLowCut.Value), Convert.ToDouble(LFPHighCut.Value), spikeBufferLength); } }