Exemplo n.º 1
0
 public void SetChannel(BipolarDoubleChannel channel)
 {
     if (channel == _signalChannel)
     {
         return;
     }
     if (_signalChannel != null)
     {
         _signalChannel.LengthChanged -= OnLengthChanged;
     }
     _signalChannel = channel;
     if (_signalChannel != null)
     {
         _signalChartControl.Name      = channel.Info.Name;
         _signalChannel.LengthChanged += OnLengthChanged;
     }
 }
Exemplo n.º 2
0
        private void OnDeviceConnected()
        {
            BatteryChannel = new BatteryChannel(_currentDevice);

            var deviceChannels = _currentDevice.Channels
                                 .Where(x => x.Type == ChannelType.Signal)
                                 .ToDictionary(channelInfo => channelInfo.Name, channelInfo => new EegChannel(_currentDevice, channelInfo));

            if (deviceChannels.ContainsKey("T3") && deviceChannels.ContainsKey("O1"))
            {
                T3O1SignalChannel   = new BipolarDoubleChannel(deviceChannels["T3"], deviceChannels["O1"]);
                T3O1SpectrumChannel = new SpectrumChannel(T3O1SignalChannel);
                if (deviceChannels.ContainsKey("T4") && deviceChannels.ContainsKey("O2"))
                {
                    T4O21SignalChannel  = new BipolarDoubleChannel(deviceChannels["T4"], deviceChannels["O2"]);
                    T4O2SpectrumChannel = new SpectrumChannel(T4O21SignalChannel);
                    IndexChannel        = new EegIndexChannel(deviceChannels["T3"], deviceChannels["T4"], deviceChannels["O1"],
                                                              deviceChannels["O2"]);
                    IndexChannel.SetWeights(1.00, 1.00, 0.00, 0.00);
                    IndexChannel.Delay = 0.0;

                    IndexViewChannel = new EegIndexChannel(deviceChannels["T3"], deviceChannels["T4"], deviceChannels["O1"],
                                                           deviceChannels["O2"]);
                    IndexViewChannel.SetWeights(1.00, 1.00, 0.00, 1.00);
                    IndexViewChannel.Delay = 0.0;

                    AlphaLeftPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> {
                        T3O1SpectrumChannel
                    }, 8, 14, "AlphaLeft");
                    BetaLeftPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> {
                        T3O1SpectrumChannel
                    }, 14, 34, "BetaLeft");
                    AlphaRightPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> {
                        T4O2SpectrumChannel
                    }, 8, 14, "AlphaRight");
                    BetaRightPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> {
                        T4O2SpectrumChannel
                    }, 14, 34, "BetaRight");

                    ChannelsChanged?.Invoke(this, null);
                }
            }
        }
Exemplo n.º 3
0
 public void SetChannel(BipolarDoubleChannel channel)
 {
     if (channel == _channel)
     {
         return;
     }
     if (_channel != null)
     {
         _channel.LengthChanged -= OnLengthChanged;
     }
     _channel = channel;
     if (_channel != null)
     {
         _channel.LengthChanged += OnLengthChanged;
         SetDuration(_channel.TotalLength);
     }
     else
     {
         SetDuration(0);
     }
 }
Exemplo n.º 4
0
        private IList <DoubleSignalChannelWrap> CreateChannels(IList <IDataChannel <double> > rawChannels)
        {
            var channels = new List <IDataChannel <double> >();
            var filters  = GetSelectedFilters();

            foreach (var dataChannel in rawChannels)
            {
                if (filters.Length > 0)
                {
                    channels.Add(new FilteredChannel(dataChannel, filters));
                }
                else
                {
                    channels.Add(dataChannel);
                }
            }

            var channelAdapters = new List <DoubleSignalChannelWrap>();
            var name            = "";

            if (filters.Length > 0)
            {
                name = '\n' + filters.Select(x => x.ToString()).Aggregate((a, b) => a + '\n' + b);
            }
            foreach (var signalChannel in channels)
            {
                channelAdapters.Add(new DoubleSignalChannelWrap(signalChannel, signalChannel.Info.Name + name));
            }
            for (var i = 0; i < channels.Count - 1; ++i)
            {
                for (var j = i + 1; j < channels.Count; ++j)
                {
                    var bipolarChannel = new BipolarDoubleChannel(channels[i], channels[j]);
                    channelAdapters.Add(new DoubleSignalChannelWrap(bipolarChannel));
                }
            }
            return(channelAdapters);
        }
Exemplo n.º 5
0
        private static IEnumerable <ChannelAdapter <double> > CreateChannels(Device device)
        {
            var channels = DeviceTraits.GetChannelsWithType(device, ChannelType.Signal)
                           .Select(channelInfo => CreateChannelForDevice(device, channelInfo))
                           .Cast <IDataChannel <double> >()
                           .ToList();

            var channelAdapters = new List <ChannelAdapter <double> >();

            foreach (var signalChannel in channels)
            {
                channelAdapters.Add(new ChannelAdapter <double>(signalChannel));
            }
            for (var i = 0; i < channels.Count - 1; ++i)
            {
                for (var j = i + 1; j < channels.Count; ++j)
                {
                    var bipolarChannel = new BipolarDoubleChannel(channels[i], channels[j]);
                    channelAdapters.Add(new ChannelAdapter <double>(bipolarChannel));
                }
            }
            return(channelAdapters);
        }