Exemplo n.º 1
0
        protected override IObservable <NeuropixelsV1DataFrame> Process(IObservable <ONIManagedFrame <ushort> > source, ulong frameOffset)
        {
            return(Observable.Concat(

                       // First sequence is Empty but starts the probe after context reset so that data is aligned
                       Observable.Create <NeuropixelsV1DataFrame>(observer =>
            {
                using (var probe = new NeuropixelsV1Probe(DeviceAddress))
                {
                    if (RequireSNMatch && Configuration.ConfigProbeSN != Configuration.FlexProbeSN)
                    {
                        throw new Bonsai.WorkflowRuntimeException("Probe and configuration serial numbers do not match.");
                    }

                    if (Configuration.RefreshNeeded)
                    {
                        probe.FullReset();
                        probe.WriteConfiguration(Configuration, PerformReadCheck);
                    }
                    else
                    {
                        probe.DigitalReset();
                    }

                    probe.Start();
#if DEBUG
                    Console.WriteLine($"Probe {Configuration.FlexProbeSN} started");
#endif
                }
                observer.OnCompleted();
                return Disposable.Empty;
            }),

                       // Process frame stream
                       source
                       .Buffer(BlockSize * NeuropixelsV1DataFrame.SuperframesPerUltraFrame)
                       .Select(block => { return new NeuropixelsV1DataFrame(block, frameOffset); })
                       ));
        }
Exemplo n.º 2
0
        public override IObservable <NeuropixelsV1DataFrame> Process(IObservable <oni.Frame> source)
        {
            // Configure probe
            var probe = new NeuropixelsV1Probe(Controller, DeviceIndex.SelectedIndex);

            probe.WriteConfiguration(Configuration, PerformReadCheck);

            var data_block = new NeuropixelsV1DataBlock(BlockSize);

            return(source
                   .Where(f => f.DeviceIndex() == DeviceIndex.SelectedIndex)
                   .Where(f =>
            {
                return data_block.FillFromFrame(f);
            })
                   .Select(f =>
            {
                var sample = new NeuropixelsV1DataFrame(data_block, FrameClockHz, DataClockHz);
                data_block = new NeuropixelsV1DataBlock(BlockSize);
                return sample;
            }));
        }