public void Run()
        {
            //Clear the plot
            BoothPlotModel.Series.Clear();
            BoothPlotModel.InvalidatePlot(true);

            //Clear the trials array
            _trials.Clear();

            //Tell the scope we are running
            _scope.StartSession();

            //Add a message saying we are running
            Messages = "Running...\n";
        }
        private void _scope_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("MostRecentStimulationTrain"))
            {
                //Record the new stim
                _trials.Add(_scope.MostRecentStimulationTrain);
                var most_recent_timestamp = DateTime.Now;
                var num_stims             = _trials.Count;

                //Clear the plot
                BoothPlotModel.Series.Clear();

                //Obtain indices of trials we want to display
                List <int> _trace_indices = new List <int>();
                switch (_scope.ScopeSessionDisplayType)
                {
                case DisplayType.AllTraces:
                    _trace_indices = Enumerable.Range(0, _trials.Count).ToList();
                    break;

                case DisplayType.MostRecentTenTraces:
                    _trace_indices = Enumerable.Range(Math.Max(0, _trials.Count - 10), Math.Min(_trials.Count, 10)).ToList();
                    break;

                case DisplayType.MostRecentTrace:
                    _trace_indices.Add(_trials.Count - 1);
                    break;
                }

                //Grab data from each trial, transform it, and create a LineSeries object to display it
                for (int i = 0; i < _trace_indices.Count; i++)
                {
                    //Grab the data from the stim train. Make sure to call ToList() to make a copy of it before we transform it
                    var idx        = _trace_indices[i];
                    var train_data = _trials[idx].Data.ToList();

                    //Calculate how many elements to display from the current trace
                    int elements_to_take = train_data.Count;
                    switch (_scope.ScopeTraceDisplayType)
                    {
                    case DisplayType_IndividualTrace.FirstHundredSamples:
                        elements_to_take = Math.Min(100, train_data.Count);
                        break;

                    case DisplayType_IndividualTrace.FirstThousandSamples:
                        elements_to_take = Math.Min(1000, train_data.Count);
                        break;

                    case DisplayType_IndividualTrace.FirstTenth:
                        elements_to_take = Convert.ToInt32(0.1d * Convert.ToDouble(train_data.Count));
                        break;

                    case DisplayType_IndividualTrace.FirstQuarter:
                        elements_to_take = Convert.ToInt32(0.25d * Convert.ToDouble(train_data.Count));
                        break;
                    }

                    //Grab the elements we want to take and display
                    train_data = train_data.Take(elements_to_take).ToList();

                    //Plot this data
                    LineSeries new_line = new LineSeries();
                    for (int j = 0; j < train_data.Count; j++)
                    {
                        new_line.Points.Add(new DataPoint(j, train_data[j]));
                    }

                    BoothPlotModel.Series.Add(new_line);
                    BoothPlotModel.InvalidatePlot(true);
                }

                //Add a message to the list of messages
                Messages = Messages + most_recent_timestamp.ToString("HH:mm:ss") + " - Stimulation detected (" + num_stims.ToString() + ")\n";

                //Notify the GUI that the plot has changed
                NotifyPropertyChanged("BoothPlotModel");
            }
        }