Esempio n. 1
0
        private void CalculateCepstrum()
        {
            answer = new MySeries[spec.Length];
            Complex[] buff = new Complex[Setting.FrameLength];

            for (int frame = 0; frame < answer.Length; frame++)
            {
                SetLabelValue(frame * 100 / answer.Length);
                SetBarValue(frame * 100 / answer.Length);
                for (int i = 0; i < Setting.FrameLength; i++)
                {
                    buff[i] = Math.Log(1 + spec[frame].data[i]);
                }
                FFT.Backward(buff, FourierTransformScaling.NoScaling);
                answer[frame]       = new MySeries();
                answer[frame].begin = (frame + 1) * Setting.FrameLength / 2;
                answer[frame].end   = answer[frame].begin + Setting.FrameLength - 1;
                answer[frame].data  = new float[Setting.FrameLength];
                for (int i = 0; i < Setting.FrameLength; i++)
                {
                    answer[frame].data[i] = (float)Complex.Abs(buff[i]);
                }
            }
            SetLabelValue(100);
            SetBarValue(100);
            this.Invoke(new Action(this.Close));
        }
Esempio n. 2
0
        private void CalculateSpec()
        {
            answer = new MySeries[sample.end * 2 / Setting.FrameLength - 1];
            Complex[] buff = new Complex[Setting.FrameLength];

            for (int frame = 0; frame < answer.Length; frame++)
            {
                SetLabelValue(frame * 100 / answer.Length);
                SetBarValue(frame * 100 / answer.Length);
                for (int i = 0; i < Setting.FrameLength; i++)
                {
                    buff[i] = sample.data[frame * Setting.FrameLength / 2 + i];
                }
                HammingWindow.Use(buff);
                FFT.Forward(buff, FourierTransformScaling.ForwardScaling);
                answer[frame]       = new MySeries();
                answer[frame].begin = (frame + 1) * Setting.FrameLength / 2;
                answer[frame].end   = answer[frame].begin + Setting.FrameLength - 1;
                answer[frame].data  = new float[Setting.FrameLength];
                for (int i = 0; i < Setting.FrameLength; i++)
                {
                    answer[frame].data[i] = (float)Complex.Abs(buff[i]);
                }
            }
            SetLabelValue(100);
            SetBarValue(100);
            this.Invoke(new Action(this.Close));
        }
Esempio n. 3
0
        public static MySeries[] CalculateSpec(MySeries wave)
        {
            ProgressDlg p = new ProgressDlg();

            p.type   = CalculateType.Spec;
            p.sample = wave;
            p.ShowDialog();
            return(p.answer);
        }
Esempio n. 4
0
 private void Form6_Load(object sender, EventArgs e)
 {
     SendMessage();
     Form1.form1.SignalFre.Text   = TestForm.form2.textBox17.Text;
     Form1.form1.PhaseOffset.Text = Convert.ToString(xorigin);
     series          = new Series("飞机方位角");            //角度差对象。
     DateChange     += new EventHandler(MyDateChange); //数据更新标志位.
     Draw           += new MySeries(MyDrawLine);       //不停的描点划线。
     button1.Enabled = false;                          //表未画好前灰掉保存按钮。
 }
Esempio n. 5
0
        private void Form4_Load(object sender, EventArgs e)
        {
            SendMessage();
            Form1.form1.PhaseOffset.Text = TestForm.form2.textBox13.Text;//控制参量画图
            Form1.form1.SignalFre.Text   = TestForm.form2.textBox9.Text;

            series          = new Series("灵敏度");              //角度差对象。
            DateChange     += new EventHandler(MyDateChange); //数据更新标志位.
            Draw           += new MySeries(MyDrawLine);       //不停的描点划线。
            button1.Enabled = false;                          //表未画好前灰掉保存按钮。
        }
        public void Test1()
        {
            //Arrange
            MySeries FiboSeries = new MySeries();

            //Act
            var result = FiboSeries.FiboFunction(0);

            //Assert
            Assert.IsType <int>(result);
            Assert.Equal(0, result);
            Assert.NotEqual(10, result);
        }
Esempio n. 7
0
        private void Form3_Load(object sender, EventArgs e)
        {
            SendMessage();
            Form1.form1.PhaseOffset.Text = TestForm.form2.textBox2.Text;//控制参量画图
            Form1.form1.SignalFre.Text   = TestForm.form2.textBox1.Text;
            int    a;
            string a1, a2, a3;

            a  = (int)((double.Parse(Form1.form1.SignalFre.Text)) * 1000);
            a1 = (a % 256).ToString("X2");//变量定义冲突!!
            a  = a / 256;
            a2 = (a % 256).ToString("X2");
            a  = a / 256;
            a3 = (a % 256).ToString("X2");
            Form1.form1.Send_text.Text = "10 " + a3 + " " + a2 + " " + a1;
            series = new Series("测角精度");                      //角度差对象。

            DateChange     += new EventHandler(MyDateChange); //数据更新标志位.MyDateChange为空.
            Draw           += new MySeries(MyDrawLine);       //不停的描点划线。
            button1.Enabled = false;                          //表未画好前灰掉保存按钮。
        }
        // To use a custom database schema with the Database Manager, you must define a custom MyPrepareSearch method
        // and assign it to the StorageDatabaseManager.PrepareSearch delegate. After doing this, the search fields in the Database Manager
        //will properly refine any database manager search.  The MyPrepareSearch() method gets the search fields specified in the database manager
        // by calling StorageDatabaseManager.GetDicomQueryParams().  This returns any query parameters specified.
        // The MyPrepareSearch() method then needs to create a MatchingParameterCollection that corresponds to the specified search.
        // Note that the database manager search fields correspond to items contained in the patient, study, and series tables only.
        // There are no search fields that correspond to the image table.
        // Therefore MyPrepareSearch() only needs to add MyPatient, MyStudy, and MySeries objects to the MatchingParameterList.
        // For more details, see the "Changing the LEAD Medical Storage Server to use a different database schema" tutorial.


        private void MyPrepareSearch(MatchingParameterCollection matchingCollection)
        {
            DicomQueryParams q = __DbManager.GetDicomQueryParams();

            try
            {
                MatchingParameterList matchingList = new MatchingParameterList();
                MyPatient             patient      = new MyPatient();
                MyStudy  study  = new MyStudy();
                MySeries series = new MySeries();

                matchingList.Add(patient);
                matchingList.Add(study);
                matchingList.Add(series);

                matchingCollection.Add(matchingList);
                study.StudyAccessionNumber    = q.AccessionNumber;
                patient.PatientIdentification = q.PatientId;

                if (!string.IsNullOrEmpty(q.PatientName.FamilyName))
                {
                    patient.PatientName = q.PatientName.FamilyName.TrimEnd('*') + "*";
                }

                if (!string.IsNullOrEmpty(q.PatientName.GivenName))
                {
                    patient.PatientName = q.PatientName.GivenName.TrimEnd('*') + "*";
                }

                if (!string.IsNullOrEmpty(q.Modalities))
                {
                    series.SeriesModality = q.Modalities.Replace(",", "\\");
                }
                ;

                if (!string.IsNullOrEmpty(q.SeriesDescription))
                {
                    series.SeriesSeriesDescription = q.SeriesDescription.TrimEnd('*') + "*";
                }

                if (!string.IsNullOrEmpty(q.ReferringPhysiciansName.FamilyName))
                {
                    study.StudyReferringPhysiciansName = q.ReferringPhysiciansName.FamilyName.TrimEnd('*') + "*";
                }
                ;

                if (!string.IsNullOrEmpty(q.ReferringPhysiciansName.GivenName))
                {
                    study.StudyReferringPhysiciansName = q.ReferringPhysiciansName.GivenName.TrimEnd('*') + "*";
                }
                ;

                if (q.StudyFromChecked || q.StudyToChecked)
                {
                    DateRange studyDateRange = new DateRange();

                    if (q.StudyFromChecked)
                    {
                        studyDateRange.StartDate = q.StudyFromDate;
                    }

                    if (q.StudyToChecked)
                    {
                        studyDateRange.EndDate = q.StudyToDate;
                    }

                    study.StudyStudyDate = studyDateRange;
                }

                if (q.StorageDateChecked)
                {
                    MyInstance      instance  = new MyInstance();
                    DateRange       dateRange = new DateRange();
                    DateRangeFilter StorageDateRangeFilter = q.StorageDateRange;
                    string          startDate = StorageDateRangeFilter.DateRangeFrom;
                    string          endDate   = StorageDateRangeFilter.DateRangeTo;

                    if (StorageDateRangeFilter.SelectedDateFilter == DateRangeFilter.RangeFilterType.DateRange)
                    {
                        if (!string.IsNullOrEmpty(startDate))
                        {
                            dateRange.StartDate = DateTime.Parse(startDate);
                        }

                        if (!string.IsNullOrEmpty(endDate))
                        {
                            dateRange.EndDate = DateTime.Parse(endDate);
                        }
                    }
                    else if (StorageDateRangeFilter.SelectedDateFilter == DateRangeFilter.RangeFilterType.Months)
                    {
                        DateTime lastMonthsDate = DateTime.Now.SubtractMonths(Convert.ToInt32(StorageDateRangeFilter.LastMonths));

                        dateRange.StartDate = lastMonthsDate;
                        dateRange.EndDate   = DateTime.Now;
                    }
                    else
                    {
                        TimeSpan subtractionDays = new TimeSpan(Convert.ToInt32(StorageDateRangeFilter.LastDays),
                                                                DateTime.Now.Hour,
                                                                DateTime.Now.Minute,
                                                                DateTime.Now.Second,
                                                                DateTime.Now.Millisecond);

                        dateRange.StartDate = DateTime.Now.Subtract(subtractionDays);
                        dateRange.EndDate   = DateTime.Now;
                    }

                    instance.ImageLastStoreDate = dateRange;
                    matchingList.Add(instance);
                }

                study.StudyStudyId = q.StudyId;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                // do nothing ;
            }
        }
Esempio n. 9
0
    public void MyMethod()
    {
        MySeries mySeries = (MySeries)this.Series[0];

        mySeries.MySeriesMethod();
    }
Esempio n. 10
0
        // Returns a DataSet that reflects the existence of PatientID, StudyInstanceUID, SeriesInstanceUID, and SOPInstanceUID
        // * If the patient does not exist, returns an empty DataSet
        // * If patient exists but no study returns a DataSet where MyPatientTable has row with PatientID of DicomDataSet
        // * If patient exists, study exists but no series, returns a DataSet that has PatientID (MyPatientTable), and StudyInstanceUID (MyStudyTable)
        // * If patient, study, series exist but no Instance, returns a DataSet with PatientID, StudyInstanceUID, and SeriesInstanceUID
        // * If patinet, study series, instance exist, returns empty dataset
        private DataSet GetUpdateDataSet
        (
            DicomDataSet ds,
            bool updateExistentPatient,
            bool updateExistentStudy,
            bool updateExistentSeries,
            bool updateExistentInstances
        )
        {
            MatchingParameterCollection matchingEntitiesCollection = new MatchingParameterCollection();
            MatchingParameterList       matchingEntitiesList       = new MatchingParameterList();

            matchingEntitiesCollection.Add(matchingEntitiesList);

            MyInstance instance = new MyInstance();

            instance.SOPInstanceUID = ds.MyGetStringValue(DicomTag.SOPInstanceUID);

            bool instanceExists = IsCompositeInstancesExists(instance.SOPInstanceUID);

            if (instanceExists)
            {
                matchingEntitiesList.Add(instance);

                DeleteInstance(matchingEntitiesCollection);

                matchingEntitiesList.Remove(instance);

                instanceExists = false;
            }


            MyPatient patient = new MyPatient();

            patient.PatientIdentification = ds.MyGetStringValue(DicomTag.PatientID);

            if (null != patient.PatientIdentification)
            {
                matchingEntitiesList.Add(patient);
            }

            bool patientExist = IsPatientsExists(patient.PatientIdentification);

            if (updateExistentPatient && patientExist)
            {
                // case #1
                return(QueryCompositeInstances(matchingEntitiesCollection));
            }
            else if (!patientExist)
            {
                // case #2
                return(new MyDataSet());
            }
            else
            {
                // case #3
                // (!updateExistentPatient) && (patientExist)
                // int ? patientId = GetIntValue(patient.PatientIdentification);

                MyStudy study = new MyStudy();
                study.StudyStudyInstanceUID = ds.MyGetStringValue(DicomTag.StudyInstanceUID);

                if (null != study.StudyStudyInstanceUID)
                {
                    matchingEntitiesList.Add(study);
                }

                bool studyExists = IsStudyExists(study.StudyStudyInstanceUID);

                if (updateExistentStudy && studyExists)
                {
                    return(QueryCompositeInstances(matchingEntitiesCollection));
                }
                else if (!studyExists)
                {
                    if (matchingEntitiesList.Contains(study))
                    {
                        matchingEntitiesList.Remove(study);
                    }

                    return(QueryPatients(matchingEntitiesCollection));
                }
                else
                {
                    MySeries series = new MySeries();

                    series.SeriesSeriesInstanceUID = ds.MyGetStringValue(DicomTag.SeriesInstanceUID);

                    if (!string.IsNullOrEmpty(series.SeriesSeriesInstanceUID))
                    {
                        matchingEntitiesList.Add(series);
                    }

                    bool seriesExists = IsSeriesExists(series.SeriesSeriesInstanceUID);

                    if (updateExistentSeries && seriesExists)
                    {
                        return(QueryCompositeInstances(matchingEntitiesCollection));
                    }
                    else if (!seriesExists)
                    {
                        if (matchingEntitiesList.Contains(series))
                        {
                            matchingEntitiesList.Remove(series);
                        }

                        return(QueryStudies(matchingEntitiesCollection));
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(instance.SOPInstanceUID))
                        {
                            matchingEntitiesList.Add(instance);
                        }

                        if (updateExistentInstances && instanceExists)
                        {
                            return(QueryCompositeInstances(matchingEntitiesCollection));
                        }
                        else
                        {
                            MyDataSet.MyPatientTableRow patientRow;
                            MyDataSet.MyStudyTableRow   studyRow;
                            MyDataSet.MySeriesTableRow  seriesRow;

                            MyDataSet myDataSet = new MyDataSet();
                            myDataSet.EnforceConstraints = false;
                            myDataSet.MyPatientTable.BeginLoadData();
                            myDataSet.MyStudyTable.BeginLoadData();
                            myDataSet.MySeriesTable.BeginLoadData();
                            myDataSet.MyInstanceTable.BeginLoadData();

                            patientRow = myDataSet.MyPatientTable.AddMyPatientTableRow(patient.PatientIdentification,
                                                                                       string.Empty,
                                                                                       DateTime.MinValue,
                                                                                       string.Empty,
                                                                                       string.Empty);

                            //if (patientId != null)
                            //{
                            //   patientRow.PatientId = patientId.Value;
                            //}

                            //dicomDataSet.MyPatientTable.Rows[0]["PatientId"] = patientId;

                            studyRow = myDataSet.MyStudyTable.AddMyStudyTableRow(patientRow,
                                                                                 study.StudyStudyInstanceUID,
                                                                                 DateTime.MinValue,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty,
                                                                                 string.Empty);

                            seriesRow = myDataSet.MySeriesTable.AddMySeriesTableRow(
                                studyRow,
                                series.SeriesSeriesInstanceUID,
                                string.Empty,
                                0,
                                string.Empty,
                                DateTime.MinValue,
                                string.Empty);

                            //1. if updateInstance and instance exist not valid (will be in the above IF
                            //2. if updateInstance and instance NOT exist don't fill from Db
                            //3. if NOT updateInstance and instance exist then insert SOP Instance UID
                            //4. if NOT updateInstnace and NOT instance exist then don't fill from Db

                            //case 3 above
                            if (instanceExists)
                            {
                                myDataSet.MyInstanceTable.AddMyInstanceTableRow(seriesRow,
                                                                                instance.SOPInstanceUID,
                                                                                0,
                                                                                DateTime.MinValue,
                                                                                string.Empty,
                                                                                string.Empty,
                                                                                0,
                                                                                0,
                                                                                0);
                            }

                            myDataSet.AcceptChanges();

                            myDataSet.MyPatientTable.EndLoadData();
                            myDataSet.MyStudyTable.EndLoadData();
                            myDataSet.MySeriesTable.EndLoadData();
                            myDataSet.MyInstanceTable.EndLoadData();
                            myDataSet.EnforceConstraints = true;
                            return(myDataSet);
                        }
                    }
                }
            }
        }
Esempio n. 11
0
 public Column(string name)
 {
     _name   = name;
     values  = new List <double>();
     _series = new MySeries(name);
 }