public Neuropixels1R0Device() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // Find the hardware clock rate var sample_clock_hz = (int)50e6; // TODO: oni_ref.DAQ.AcquisitionClockHz; // Find all RHD devices devices = oni_ref.DAQ.DeviceMap.Where( pair => pair.Value.id == (uint)oni.Device.DeviceID.NEUROPIX1R0 ).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no devices to use // TODO: this aliases into some XML error if (devices.Count == 0) { throw new oni.ONIException((int)oni.lib.Error.DEVIDX); } DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); source = Observable.Create <Neuropixels1R0DataFrame>(observer => { EventHandler <FrameReceivedEventArgs> inputReceived; var data_block = new Neuropixels1R0DataBlock(BlockSize); oni_ref.Environment.Start(); inputReceived = (sender, e) => { var frame = e.Value; //If this frame contaisn data from the selected device_index if (frame.DeviceIndices.Contains(DeviceIndex.SelectedIndex)) { // Pull the sample if (data_block.FillFromFrame(frame, DeviceIndex.SelectedIndex)) { observer.OnNext(new Neuropixels1R0DataFrame(data_block, sample_clock_hz)); //TODO: Does this deep copy?? data_block = new Neuropixels1R0DataBlock(BlockSize); } } }; oni_ref.Environment.FrameInputReceived += inputReceived; return(Disposable.Create(() => { oni_ref.Environment.FrameInputReceived -= inputReceived; oni_ref.Environment.Stop(); oni_ref.Dispose(); })); }); }
public Neuropixels1R0DataFrame(Neuropixels1R0DataBlock dataBlock, int hardware_clock_hz) { LFPClock = GetClock(dataBlock.SpikeClock); LFPClock = GetClock(dataBlock.LFPClock); SpikeTime = GetTime(dataBlock.SpikeClock, hardware_clock_hz); LFPTime = GetTime(dataBlock.LFPClock, hardware_clock_hz); SpikeData = GetEphysData(dataBlock.SpikeData); LFPData = GetEphysData(dataBlock.LFPData); FrameCounter = GetCounter(dataBlock.CounterData); FrameType = GetFrameType(dataBlock.FrameType); }