private void button1_Click(object sender, EventArgs e) { data data_object = new data(); string s = textBox1.Text; string s2 = textBox2.Text; y_axis_2_signal_1 = data_object.read_data_file(s); y_axis_2_signal_2 = data_object.read_data_file(s2); for (int i = 0; i < y_axis_2_signal_1.Count; i++) { y_axis_signal_merge.Add(y_axis_2_signal_1[i] + y_axis_2_signal_2[i]); } }
private void button1_Click(object sender, EventArgs e) { data data_object = new data(); #region 1_signal if (checkBox1.Checked == true) { string s = textBox1.Text; y_axis_1_signal = data_object.read_data_file(s); } #endregion #region 2_signal if (checkBox2.Checked == true) { string s = textBox1.Text; string s2 = textBox2.Text; y_axis_2_signal_1 = data_object.read_data_file(s); y_axis_2_signal_2 = data_object.read_data_file(s2); } #endregion }
private void button1_Click(object sender, EventArgs e) { data data_object = new data(); string s = textBox1.Text; double freq = double.Parse(textBox2.Text); signal = data_object.read_data_file(s); Stopwatch time = Stopwatch.StartNew(); DFT(signal); time.Stop(); MessageBox.Show(time.ElapsedMilliseconds.ToString()); ampitide = Get_Ampitude(real, imagin); phase = Get_Phase(real, imagin); X_axis = Get_X_axis(freq, signal); }
private void button1_Click(object sender, EventArgs e) { data d = new data(); string s = textBox1.Text; List <double> signal = new List <double>(); List <Tuple <double, double> > result = new List <Tuple <double, double> >(); signal = d.read_data_file(s); int n = signal.Count; result = Fast_forurier_series(signal, n); Ampitud = Get_Ampitude(result); phase = Get_Phase(result); double freq = double.Parse(textBox2.Text); x = Get_X_axis(freq, signal); string s1 = textBox3.Text; d.write_data_inFile_3(s1, result); }
private void button1_Click(object sender, EventArgs e) { List<double> FinalResult = new List<double>(); List<double> ecg = new List<double>(); List<double> hN_after_convultion = new List<double>(); double fc1 = 0; double fc2 = 0; double transition_width = 0; double Attinuation = 0; double Sampling = 0; fc1 = double.Parse(textBox4.Text); fc2 = double.Parse(textBox5.Text); transition_width = double.Parse(textBox1.Text); Attinuation = double.Parse(textBox2.Text); Sampling = double.Parse(textBox3.Text); if (textBox5.Text == "") { fc2 = 0; } FinalResult = Calculation_of_Hn(Attinuation,transition_width,Sampling,fc1,fc2);//store in file string coffetionet = "coffetionet.txt"; d.write_data_inFile(coffetionet,FinalResult); string s = textBox8.Text; ecg = d.read_data_file(s); //hN_after_convultion = f.convelution_Directe(FinalResult, ecg);//sto in file string Coeffaftercon = "coffetionet_After_convolution.txt"; d.write_data_inFile(Coeffaftercon, hN_after_convultion); int Nforup; int Nfordown; Nforup=int.Parse(textBox7.Text); Nfordown=int.Parse(textBox6.Text); //SAMPLING List<double> SamplingResult = UPSamplingAndDownSampling(FinalResult, ecg, Nforup, Nfordown);//store in file string SamplingRes = "SamplingResult.txt"; d.write_data_inFile(SamplingRes, SamplingResult); }
private void button1_Click(object sender, EventArgs e) { data data_object = new data(); string s = textBox2.Text; int level; if (checkBox1.Checked == true) { double bits = double.Parse(textBox3.Text); level = int.Parse(Math.Pow(2.0, bits).ToString()); } else { level = int.Parse(textBox1.Text); } y_axis_signal = data_object.read_data_file(s); double min_x = 0.0; double max_x = 0.0; double resolution = 0.0; List <double> x_list = new List <double>(); List <double> y_list = new List <double>(); List <double> mid_point_list = new List <double>(); Tuple <double, double, double> t1 = new Tuple <double, double, double>(min_x, max_x, resolution); t1 = data_object.Get_min_Max_X_resolution(y_axis_signal, level); min_x = t1.Item1; max_x = t1.Item2; resolution = t1.Item3; Tuple <List <double>, List <double>, List <double> > t2 = new Tuple <List <double>, List <double>, List <double> >(x_list, y_list, mid_point_list); t2 = data_object.creat_ranges_midPoint(min_x, resolution, level); x_list = t2.Item1; y_list = t2.Item2; mid_point_list = t2.Item3; List <int> index = new List <int>(); for (int j = 0; j < y_axis_signal.Count; j++) { for (int l = 0; l < y_list.Count; l++) { if ((x_list[l] <= y_axis_signal[j]) && (y_axis_signal[j] <= y_list[l])) { index.Add(l); break; } } } List <string> encode = new List <string>(); for (int k = 0; k < index.Count; k++) { int id = index[k]; double x = mid_point_list[id]; xq.Add(x); string s1 = Convert.ToString(index[k], 2).PadLeft((int)Math.Log(level, 2), '0'); //////////// encode.Add(s1); } dataGridView1.Rows.Add(y_axis_signal.Count); for (int i = 0; i < y_axis_signal.Count; i++) { dataGridView1.Rows[i].Cells[0].Value = i; dataGridView1.Rows[i].Cells[1].Value = y_axis_signal[i]; dataGridView1.Rows[i].Cells[2].Value = index[i]; dataGridView1.Rows[i].Cells[3].Value = xq[i]; dataGridView1.Rows[i].Cells[4].Value = encode[i]; dataGridView1.Rows[i].Cells[5].Value = double.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString()) - double.Parse(dataGridView1.Rows[i].Cells[1].Value.ToString()); } double Error = 0.0; for (int j = 0; j < y_axis_signal.Count; j++) { Error += double.Parse(dataGridView1.Rows[j].Cells[5].Value.ToString()) * double.Parse(dataGridView1.Rows[j].Cells[5].Value.ToString()); } double m = (1.0 / y_axis_signal.Count); dataGridView1.Rows[y_axis_signal.Count].Cells[5].Value = m * Error; }
private void button1_Click(object sender, EventArgs e) { List <double> signal1 = new List <double>(); List <double> signal2 = new List <double>(); List <Complex> signal1_complex = new List <Complex>(); List <Complex> signal2_complex = new List <Complex>(); data data_object = new data(); string s1 = textBox1.Text; string s2 = textBox2.Text; signal1 = data_object.read_data_file(s1); signal2 = data_object.read_data_file(s2); string s1_CX = textBox1.Text; string s2_CX = textBox2.Text; //signal1_complex = data_object.read_data_file_Complex(s1_CX); //signal2_complex = data_object.read_data_file_Complex(s2_CX); /////////////////////////////////////////// #region convelution_Directe " true " if (checkBox10.Checked == true) { List <double> direct_convelution_out = convelution_Directe(signal1, signal2); } #endregion #region convelution_fast " false " if (checkBox9.Checked == true) { List <double> convelution_fast_out = convelution_fast(signal1_complex, signal2_complex); } #endregion //////////////////////////////////////////// #region direct correlation true if (checkBox4.Checked == true) // direct correlation { if (checkBox2.Checked == true) // cross { List <double> sl = new List <double>(); sl.AddRange(signal1); List <double> sl2 = new List <double>(); sl2.AddRange(signal2); List <double> direct_correlation = correlation_Directe(signal1, signal2); double norm = Normalization(sl, sl2, direct_correlation.Count); for (int i = 0; i < direct_correlation.Count; i++) { direct_correlation[i] = direct_correlation[i] / norm; } } if (checkBox1.Checked == true) // auto { List <double> sl = new List <double>(); sl.AddRange(signal1); List <double> sl2 = new List <double>(); sl2.AddRange(signal1); List <double> direct_correlation1 = correlation_Directe_auto(signal1, signal1); double norm = Normalization(sl, sl2, direct_correlation1.Count); for (int i = 0; i < direct_correlation1.Count; i++) { direct_correlation1[i] = direct_correlation1[i] / norm; } } } #endregion #region fast correlation if (checkBox3.Checked == true) // fast correlation " auto "t" _____ cross "f" " { List <Complex> sl = new List <Complex>(); sl.AddRange(signal1_complex); List <Complex> sl2 = new List <Complex>(); sl2.AddRange(signal2_complex); List <double> list_correlation_fast = correlation_fast(signal1_complex, signal2_complex); double norm = Normalization_Complex(sl, sl2, list_correlation_fast.Count); for (int i = 0; i < list_correlation_fast.Count; i++) { list_correlation_fast[i] = list_correlation_fast[i] / norm; } } #endregion }
private void button2_Click(object sender, EventArgs e) { data data_object = new data(); if (flag == 0) { string s = textBox2.Text; l1 = data_object.read_data_file(s); flag = 1; } List <double> l2 = new List <double>(); if (checkBox1.Checked == true) { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); string s2 = textBox4.Text; l2 = data_object.read_data_file(s2); List <double> mul_signal = new List <double>(); mul_signal = multi_signal(l1, l2); l1 = mul_signal; CreateGraph2(zedGraphControl1, 0, mul_signal); } if (checkBox2.Checked == true) // const { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); List <double> mul_signal = new List <double>(); double constant = double.Parse(textBox1.Text); mul_signal = const_signal(l1, constant); l1 = mul_signal; CreateGraph2(zedGraphControl1, 0, mul_signal); } if (checkBox3.Checked == true) // foold { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); CreateGraph_flood(zedGraphControl1, 0, l1); for (int i = 0; i < l1.Count; i++) { // l1[i] = l1[i] * -1; l1[0] = l1[0] * -1; /////////////////////////////////// check ************************** } } if (checkBox4.Checked == true) //shift { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); int shifted_value = int.Parse(textBox3.Text); shifted_value = shifted_value * -1; CreateGraph2(zedGraphControl1, shifted_value, l1); } if (checkBox5.Checked == true) // shift_foold { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); int shifted_value = int.Parse(textBox3.Text); CreateGraph_flood(zedGraphControl1, shifted_value, l1); } }