public DataDependentAcquisitionRun(IRawDataReader rawDataReader)
        {
            _rawDataReader = rawDataReader;

            //_ms1List = new LinkedList<Spectrum>();
            _scanNumSpecMap = new Dictionary<int, Spectrum>();
            _ms1PeakList = new List<LcMsPeak>();

            // Parse all spectra
            var numMs1Scans = 0;
            foreach (var spec in _rawDataReader.ReadAllSpectra())
            {
                _scanNumSpecMap.Add(spec.ScanNum, spec);
                if (spec.MsLevel == 1)
                {
                    //_ms1List.AddLast(spec); // MS1 spectrum                    
                    ++numMs1Scans;
                    foreach (var peak in spec.Peaks)
                    {
                        _ms1PeakList.Add(new LcMsPeak(peak.Mz, peak.Intensity, spec.ScanNum));
                    }
                }
            }

            _numMs1Scans = numMs1Scans;
            _ms1PeakList.Sort();
        }
Esempio n. 2
0
        public OutputWindow(IRawDataReader p_dataReader, int height, int width)
        {
            InitializeComponent();

            if (height != -1)
            {
                this.Height = height;
            }
            if (width != -1)
            {
                this.Width = width;
            }

            #region hide grid and numbering
            this.plotter.BottomPanel.Visibility = System.Windows.Visibility.Collapsed;
            this.plotter.LeftPanel.Visibility   = System.Windows.Visibility.Collapsed;
            #endregion

            dataReader = p_dataReader;

            dataReader.Values += new RawDataChangedEventHandler(dataReader_Values);

            p_asyncWorker = new BackgroundWorker();
            p_asyncWorker.WorkerReportsProgress      = true;
            p_asyncWorker.WorkerSupportsCancellation = true;

            p_asyncWorker.DoWork             += new DoWorkEventHandler(p_asyncWorker_DoWork);
            p_asyncWorker.ProgressChanged    += new ProgressChangedEventHandler(p_asyncWorker_ProgressChanged);
            p_asyncWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(p_asyncWorker_RunWorkerCompleted);

            this.Closing += new CancelEventHandler(OutputWindow_Closing);
        }
        //IDigitalSignalProcessor dsp;

        public CountEpochGenerator(IRawDataReader reader, int n)
        {
            this.n         = n;
            this.reader    = reader;
            bufferQueue    = new ConcurrentQueue <double[]>();
            reader.Values += new RawDataChangedEventHandler(reader_Values);
        }
        public DataDependentAcquisitionRun(IRawDataReader rawDataReader)
        {
            _rawDataReader = rawDataReader;

            //_ms1List = new LinkedList<Spectrum>();
            _scanNumSpecMap = new Dictionary <int, Spectrum>();
            _ms1PeakList    = new List <LcMsPeak>();

            // Parse all spectra
            var numMs1Scans = 0;

            foreach (var spec in _rawDataReader.ReadAllSpectra())
            {
                _scanNumSpecMap.Add(spec.ScanNum, spec);
                if (spec.MsLevel == 1)
                {
                    //_ms1List.AddLast(spec); // MS1 spectrum
                    ++numMs1Scans;
                    foreach (var peak in spec.Peaks)
                    {
                        _ms1PeakList.Add(new LcMsPeak(peak.Mz, peak.Intensity, spec.ScanNum));
                    }
                }
            }

            _numMs1Scans = numMs1Scans;
            _ms1PeakList.Sort();
        }
Esempio n. 5
0
        public DialogLoader(IRawDataReader reader, IDataCursor cursor, IEventAggregator eventAggregator)
        {
            dataReader = reader;
            dataCursor = cursor;

            eventAggregator.GetEvent <OpenRawDataFileEvent>().Subscribe(OpenRawData);
            eventAggregator.GetEvent <ShowAboutBoxEvent>().Subscribe(ShowAboutBox);
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="frequenchyInHz">for example 1000 Hz (if you want to say 1Khz)</param>
        /// <param name="timePerChunkInMilliseconds">300 millieseconds</param>
        public TimeEpochGenerator(IRawDataReader reader, int timePerChunkInMilliseconds)
        {
            double frequenchyInHz = reader.SamplingFrequency;

            if (frequenchyInHz <= 0)
            {
                throw new System.Exception("Wrong frequency rate!");
            }

            int samplesPerChunk = Convert.ToInt32(Math.Truncate(timePerChunkInMilliseconds * frequenchyInHz / 1000));

            countGenerator            = new CountEpochGenerator(reader, samplesPerChunk);//chunk=epoch
            countGenerator.NextEpoch += new EpochReadyEventHandler(countGenerator_NextEpoch);
        }
Esempio n. 7
0
        public OutputForm(IRawDataReader p_dataReader)
        {
            InitializeComponent();

            if (p_dataReader is EmotivRawDataReader || p_dataReader is EmotivFileSystemDataReader)
            {
                ScallingDisabled = false;
            }

            dataReader = p_dataReader;

            #region Set First chart
            chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

            if (ScallingDisabled)
            {
                chart1.ChartAreas[0].AxisY.Maximum = 0.3;
                chart1.ChartAreas[0].AxisY.Minimum = -0.3;

                chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = false;
                chart1.ChartAreas[0].AxisX.ScaleBreakStyle.Enabled = false;
            }

            chart1.ChartAreas[0].AxisX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Milliseconds;

            chart1.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.NotSet;

            chart1.Series[0].Color = Color.Red;
            #endregion

            p_asyncWorker = new BackgroundWorker();
            p_asyncWorker.WorkerReportsProgress      = true;
            p_asyncWorker.WorkerSupportsCancellation = true;
            p_asyncWorker.ProgressChanged           += new ProgressChangedEventHandler(asyncWorker_ProgressChanged);
            p_asyncWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(asyncWorker_RunWorkerCompleted);
            p_asyncWorker.DoWork += new DoWorkEventHandler(asyncWorker_DoWork);

            dataReader.Values += new RawDataChangedEventHandler(dataReader_Values);
        }
Esempio n. 8
0
 public SimpleFeatureGenerator(IRawDataReader reader, IDigitalSignalProcessor dsp)
 {
     this.dsp       = dsp;
     this.reader    = reader;
     reader.Values += new RawDataChangedEventHandler(er_Values);
 }
Esempio n. 9
0
 public SimpleFeatureGenerator(IRawDataReader reader)
 {
     this.reader    = reader;
     reader.Values += new RawDataChangedEventHandler(er_Values);
 }
Esempio n. 10
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            buttonStart.Enabled = false;
            SelectedScenario    = comboBoxScenarioType.SelectedIndex;

            try
            {
                #region 1 Configure start

                IDigitalSignalProcessor dsp = null;
                if (cbEmotivDSP.Checked && cbEmotivDspMethod.SelectedIndex == 0)
                {
                    dsp = new BasicSignalProcessor();
                }
                if (cbFieldTripDSP.Checked && cbFieldTripDspMethod.SelectedIndex == 0)
                {
                    dsp = new BasicSignalProcessor();
                }

                if (rbuttonEmotiv.Checked)
                {
                    if (rbuttonEmotivSignal.Checked)
                    {
                        dataReader = new EmotivRawDataReader();
                    }
                    else
                    {
                        dataReader = new EmotivFileSystemDataReader(textBoxEmotivFile.Text);
                    }

                    int scenario = comboBoxScenarioType.SelectedIndex;
                    if (scenario == 1 || scenario == 2)                              //train and classify
                    {
                        IEpoching epocher = new TimeEpochGenerator(dataReader, 300); //this value depends on your BCI scenario
                        featureGenerator = new EigenVectorFeatureGenerator(epocher);
                    }
                }
                else if (rbuttonOpenVibe.Checked)
                {
                    dataReader = new OpenVibeRawDataReader();
                    int scenario = comboBoxScenarioType.SelectedIndex;
                    //if (scenario==5 || scenario==6) //these two acquire signal from OpenVibe
                    //{
                    //   IEpoching epocher = new CountEpochGenerator(dataReader, samples_per_chunk);
                    //   featureGenerator = new EigenVectorFeatureGenerator(epocher);
                    //}
                    //else
                    featureGenerator = new OpenVibeFeatureGenerator();
                }
                else if (rbuttonFieldTrip.Checked)
                {
                    dataReader = new FieldTripRawDataReader(this.tboxFieldTripHost.Text, Convert.ToInt32(this.ndFieldTripPort.Value));
                    int scenario = comboBoxScenarioType.SelectedIndex;
                    if (scenario == 1 || scenario == 2)
                    {
                        IEpoching epocher = new TimeEpochGenerator(dataReader, 300);//this value depends on your BCI scenario
                        featureGenerator = new EigenVectorFeatureGenerator(epocher);
                    }
                }

                if (dsp != null)
                {
                    dataReader.SetDspProcessor(dsp);
                }
                #endregion

                #region 2 Instantiate and run

                if (rbuttonExperimentator.Checked)
                {
                    //window created without background thread
                    ew = new WPF.ExperimentsWindow(); ew.Show(); currentWindow = ew;

                    currentWindow.Closed += delegate(object wsender, EventArgs we)
                    {
                        buttonStart.Text    = "Start";
                        buttonStart.Enabled = true;
                        ew = null;
                    };
                }
                else
                if (rbuttonEmotiv.Checked || rbuttonOpenVibe.Checked || rbuttonFieldTrip.Checked)
                {
                    switch (comboBoxScenarioType.SelectedIndex)
                    {
                    case 0:        //chart signal
                        if (rbuttonWPFcharting.Checked)
                        {
                            ow = new WPF.OutputWindow(dataReader, -1, -1); ow.Show(); currentWindow = ow;
                        }
                        else if (rbuttonWindowsFormsCharting.Checked)
                        {
                            of = new OutputForm(dataReader); of.Show(); of.Start(); currentForm = of;
                        }
                        break;

                    case 1: tf = new TrainForm(featureGenerator); tf.Show(); currentForm = tf; break;

                    case 2: cf = new ClassifyForm(featureGenerator); cf.Show(); currentForm = cf; break;

                    case 3: ow = new WPF.OutputWindow(dataReader, 165, 830); ow.Show(); currentWindow = ow; break; //xDAWN

                    case 4: ow = new WPF.OutputWindow(dataReader, 250, 830); ow.Show(); currentWindow = ow; break; //CSP

                    case 5: tf = new TrainForm(featureGenerator); tf.Show(); currentForm = tf; break;              //train

                    case 6: cf = new ClassifyForm(featureGenerator); cf.Show(); currentForm = cf; break;           //classify
                    }

                    if (rbuttonOpenVibe.Checked)
                    {
                        openVibeWorker.RunWorkerAsync();
                    }

                    if (currentForm != null)
                    {
                        currentForm.FormClosed += new FormClosedEventHandler(currentForm_FormClosed);
                    }
                    if (currentWindow != null)
                    {
                        currentWindow.Closed += new EventHandler(currentWindow_Closed);
                    }
                }

                if (currentWindow != null)
                {
                    System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(currentWindow);
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                if (ex.Message.IndexOf("edk.dll") >= 0)
                {
                    MessageBox.Show(ex.Message + "\r\n You need edk.dll and edk_utils.dll from the Emotiv Reseach SDK placed in Adastra's installation folder.");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }

                buttonStart.Enabled = true;
            }
            // }
        }