diff --git a/EcomAnalysis/EcomAnalysis.csproj b/EcomAnalysis/EcomAnalysis.csproj index 4b27d51..f9f40f1 100644 --- a/EcomAnalysis/EcomAnalysis.csproj +++ b/EcomAnalysis/EcomAnalysis.csproj @@ -33,8 +33,13 @@ 4 + + ..\packages\MathNet.Numerics.4.15.0\lib\net461\MathNet.Numerics.dll + + + @@ -67,6 +72,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/EcomAnalysis/Form1.Designer.cs b/EcomAnalysis/Form1.Designer.cs index 7e123c9..3747a5c 100644 --- a/EcomAnalysis/Form1.Designer.cs +++ b/EcomAnalysis/Form1.Designer.cs @@ -58,6 +58,12 @@ this.label12 = new System.Windows.Forms.Label(); this.TxtVisit = new System.Windows.Forms.TextBox(); this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.listView2 = new System.Windows.Forms.ListView(); + this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader12 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader13 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.label13 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // label1 @@ -76,14 +82,14 @@ this.TxtLogFilename.Location = new System.Drawing.Point(64, 6); this.TxtLogFilename.Name = "TxtLogFilename"; this.TxtLogFilename.ReadOnly = true; - this.TxtLogFilename.Size = new System.Drawing.Size(576, 19); + this.TxtLogFilename.Size = new System.Drawing.Size(647, 19); this.TxtLogFilename.TabIndex = 1; // // label2 // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label2.Location = new System.Drawing.Point(119, 145); + this.label2.Location = new System.Drawing.Point(31, 141); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 24); this.label2.TabIndex = 2; @@ -94,7 +100,7 @@ this.TxtFB1.BackColor = System.Drawing.SystemColors.Info; this.TxtFB1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB1.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB1.Location = new System.Drawing.Point(255, 142); + this.TxtFB1.Location = new System.Drawing.Point(167, 138); this.TxtFB1.Name = "TxtFB1"; this.TxtFB1.ReadOnly = true; this.TxtFB1.Size = new System.Drawing.Size(199, 24); @@ -105,7 +111,7 @@ // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label3.Location = new System.Drawing.Point(119, 175); + this.label3.Location = new System.Drawing.Point(31, 171); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(62, 24); this.label3.TabIndex = 4; @@ -115,7 +121,7 @@ // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label4.Location = new System.Drawing.Point(119, 205); + this.label4.Location = new System.Drawing.Point(31, 201); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(54, 24); this.label4.TabIndex = 5; @@ -125,7 +131,7 @@ // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label5.Location = new System.Drawing.Point(119, 235); + this.label5.Location = new System.Drawing.Point(31, 231); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(65, 24); this.label5.TabIndex = 6; @@ -135,7 +141,7 @@ // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label6.Location = new System.Drawing.Point(119, 265); + this.label6.Location = new System.Drawing.Point(31, 261); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(101, 24); this.label6.TabIndex = 7; @@ -146,7 +152,7 @@ this.TxtFB2.BackColor = System.Drawing.SystemColors.Info; this.TxtFB2.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB2.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB2.Location = new System.Drawing.Point(255, 172); + this.TxtFB2.Location = new System.Drawing.Point(167, 168); this.TxtFB2.Name = "TxtFB2"; this.TxtFB2.ReadOnly = true; this.TxtFB2.Size = new System.Drawing.Size(199, 24); @@ -158,7 +164,7 @@ this.TxtFB3.BackColor = System.Drawing.SystemColors.Info; this.TxtFB3.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB3.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB3.Location = new System.Drawing.Point(255, 202); + this.TxtFB3.Location = new System.Drawing.Point(167, 198); this.TxtFB3.Name = "TxtFB3"; this.TxtFB3.ReadOnly = true; this.TxtFB3.Size = new System.Drawing.Size(199, 24); @@ -170,7 +176,7 @@ this.TxtFB4.BackColor = System.Drawing.SystemColors.Info; this.TxtFB4.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB4.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB4.Location = new System.Drawing.Point(255, 232); + this.TxtFB4.Location = new System.Drawing.Point(167, 228); this.TxtFB4.Name = "TxtFB4"; this.TxtFB4.ReadOnly = true; this.TxtFB4.Size = new System.Drawing.Size(199, 24); @@ -182,7 +188,7 @@ this.TxtFB5.BackColor = System.Drawing.SystemColors.Info; this.TxtFB5.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFB5.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFB5.Location = new System.Drawing.Point(255, 262); + this.TxtFB5.Location = new System.Drawing.Point(167, 258); this.TxtFB5.Name = "TxtFB5"; this.TxtFB5.ReadOnly = true; this.TxtFB5.Size = new System.Drawing.Size(199, 24); @@ -193,7 +199,7 @@ // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label7.Location = new System.Drawing.Point(119, 304); + this.label7.Location = new System.Drawing.Point(31, 300); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(58, 24); this.label7.TabIndex = 12; @@ -204,7 +210,7 @@ this.TxtFBTotal.BackColor = System.Drawing.SystemColors.Info; this.TxtFBTotal.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtFBTotal.Font = new System.Drawing.Font("MS UI Gothic", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtFBTotal.Location = new System.Drawing.Point(255, 301); + this.TxtFBTotal.Location = new System.Drawing.Point(167, 297); this.TxtFBTotal.Name = "TxtFBTotal"; this.TxtFBTotal.ReadOnly = true; this.TxtFBTotal.Size = new System.Drawing.Size(199, 24); @@ -229,7 +235,7 @@ this.TxtDateTime.Location = new System.Drawing.Point(373, 40); this.TxtDateTime.Name = "TxtDateTime"; this.TxtDateTime.ReadOnly = true; - this.TxtDateTime.Size = new System.Drawing.Size(255, 21); + this.TxtDateTime.Size = new System.Drawing.Size(326, 21); this.TxtDateTime.TabIndex = 15; this.TxtDateTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // @@ -245,7 +251,8 @@ // // listView1 // - this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, @@ -261,9 +268,9 @@ this.listView1.FullRowSelect = true; this.listView1.GridLines = true; this.listView1.HideSelection = false; - this.listView1.Location = new System.Drawing.Point(24, 386); + this.listView1.Location = new System.Drawing.Point(24, 375); this.listView1.Name = "listView1"; - this.listView1.Size = new System.Drawing.Size(604, 199); + this.listView1.Size = new System.Drawing.Size(675, 227); this.listView1.TabIndex = 17; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.View = System.Windows.Forms.View.Details; @@ -286,45 +293,39 @@ // // columnHeader4 // - this.columnHeader4.DisplayIndex = 4; this.columnHeader4.Text = "潜時"; this.columnHeader4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader4.Width = 100; // // columnHeader5 // - this.columnHeader5.DisplayIndex = 5; this.columnHeader5.Text = "心拍数"; this.columnHeader5.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader5.Width = 100; // // columnHeader6 // - this.columnHeader6.DisplayIndex = 6; this.columnHeader6.Text = "瞬目回数"; this.columnHeader6.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader6.Width = 100; // // columnHeader7 // - this.columnHeader7.DisplayIndex = 7; this.columnHeader7.Text = "瞳孔径:右"; this.columnHeader7.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader7.Width = 100; // // columnHeader8 // - this.columnHeader8.DisplayIndex = 8; this.columnHeader8.Text = "瞳孔径:左"; this.columnHeader8.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader8.Width = 100; // // label10 // - this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label10.AutoSize = true; this.label10.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label10.Location = new System.Drawing.Point(19, 356); + this.label10.Location = new System.Drawing.Point(19, 345); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(157, 27); this.label10.TabIndex = 18; @@ -338,7 +339,7 @@ this.TxtSubject.Location = new System.Drawing.Point(373, 77); this.TxtSubject.Name = "TxtSubject"; this.TxtSubject.ReadOnly = true; - this.TxtSubject.Size = new System.Drawing.Size(152, 27); + this.TxtSubject.Size = new System.Drawing.Size(212, 27); this.TxtSubject.TabIndex = 20; // // label11 @@ -353,9 +354,10 @@ // // BtnSaveSceneTable // - this.BtnSaveSceneTable.Location = new System.Drawing.Point(191, 359); + this.BtnSaveSceneTable.Font = new System.Drawing.Font("MS UI Gothic", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BtnSaveSceneTable.Location = new System.Drawing.Point(559, 621); this.BtnSaveSceneTable.Name = "BtnSaveSceneTable"; - this.BtnSaveSceneTable.Size = new System.Drawing.Size(82, 24); + this.BtnSaveSceneTable.Size = new System.Drawing.Size(140, 38); this.BtnSaveSceneTable.TabIndex = 21; this.BtnSaveSceneTable.Text = "CSV保存"; this.BtnSaveSceneTable.UseVisualStyleBackColor = true; @@ -371,7 +373,7 @@ // this.label12.AutoSize = true; this.label12.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.label12.Location = new System.Drawing.Point(531, 77); + this.label12.Location = new System.Drawing.Point(591, 77); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(62, 27); this.label12.TabIndex = 22; @@ -382,26 +384,77 @@ this.TxtVisit.BackColor = System.Drawing.SystemColors.Info; this.TxtVisit.BorderStyle = System.Windows.Forms.BorderStyle.None; this.TxtVisit.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); - this.TxtVisit.Location = new System.Drawing.Point(599, 77); + this.TxtVisit.Location = new System.Drawing.Point(659, 77); this.TxtVisit.Name = "TxtVisit"; this.TxtVisit.ReadOnly = true; - this.TxtVisit.Size = new System.Drawing.Size(29, 27); + this.TxtVisit.Size = new System.Drawing.Size(40, 27); this.TxtVisit.TabIndex = 23; this.TxtVisit.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // columnHeader9 // - this.columnHeader9.DisplayIndex = 3; this.columnHeader9.Text = "EC回数"; this.columnHeader9.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.columnHeader9.Width = 100; // + // listView2 + // + this.listView2.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader10, + this.columnHeader11, + this.columnHeader12, + this.columnHeader13}); + this.listView2.Font = new System.Drawing.Font("MS UI Gothic", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.listView2.GridLines = true; + this.listView2.HideSelection = false; + this.listView2.Location = new System.Drawing.Point(395, 201); + this.listView2.Name = "listView2"; + this.listView2.Size = new System.Drawing.Size(304, 125); + this.listView2.TabIndex = 24; + this.listView2.UseCompatibleStateImageBehavior = false; + this.listView2.View = System.Windows.Forms.View.Details; + // + // columnHeader10 + // + this.columnHeader10.Text = "シーン"; + this.columnHeader10.Width = 80; + // + // columnHeader11 + // + this.columnHeader11.Text = "LF"; + this.columnHeader11.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader11.Width = 70; + // + // columnHeader12 + // + this.columnHeader12.Text = "HF"; + this.columnHeader12.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader12.Width = 70; + // + // columnHeader13 + // + this.columnHeader13.Text = "LF/HF"; + this.columnHeader13.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.columnHeader13.Width = 70; + // + // label13 + // + this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("MS UI Gothic", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.label13.Location = new System.Drawing.Point(390, 171); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(117, 27); + this.label13.TabIndex = 25; + this.label13.Text = "HRV解析"; + // // Form1 // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(652, 597); + this.ClientSize = new System.Drawing.Size(723, 671); + this.Controls.Add(this.label13); + this.Controls.Add(this.listView2); this.Controls.Add(this.TxtVisit); this.Controls.Add(this.label12); this.Controls.Add(this.BtnSaveSceneTable); @@ -473,6 +526,12 @@ private System.Windows.Forms.Label label12; private System.Windows.Forms.TextBox TxtVisit; private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ListView listView2; + private System.Windows.Forms.ColumnHeader columnHeader10; + private System.Windows.Forms.ColumnHeader columnHeader11; + private System.Windows.Forms.ColumnHeader columnHeader12; + private System.Windows.Forms.ColumnHeader columnHeader13; + private System.Windows.Forms.Label label13; } } diff --git a/EcomAnalysis/Form1.cs b/EcomAnalysis/Form1.cs index 235c36e..ba706e5 100644 --- a/EcomAnalysis/Form1.cs +++ b/EcomAnalysis/Form1.cs @@ -9,16 +9,23 @@ using System.Windows.Forms; using System.IO; using System.Diagnostics; +using MathNet.Numerics.Interpolation; +using System.Numerics; +using MathNet.Numerics.IntegralTransforms; namespace EcomAnalysis { public partial class Form1 : Form { + const int BLOCKS = 4; private string[] _HeaderItems = { - "stimNo", "sceneNo", "stimTime", "target", "contact time", "Feedback", "RR", "gazeVx", "gazeVy", "pupilR", "pupilL" }; + "time", "stimNo", "sceneNo", "stimTime", "target", "contact time", + "Feedback", "RR", "gazeVx", "gazeVy", "pupilR", "pupilL" }; private Dictionary _SceneNoAssign = new Dictionary(); private List _Data = new List(); private List _SceneTable = new List(); private SceneMean _ScMean = new SceneMean(); + private double[] LF = new double[BLOCKS]; + private double[] HF = new double[BLOCKS]; /// /// コンストラクタ @@ -156,6 +163,113 @@ $"{_ScMean.Pupil.L:0.00} ms"})); } + // HRV算出(1/4ブロック単位) + listView2.Items.Clear(); + for (var block = 0; block < BLOCKS; block++) { + var datArr = _Data.Where(s => + s.StimNo >= 4 + block * 21 && s.StimNo < 24 + block * 21).ToArray(); + var startTime = datArr[0].ElapTime; + var lastRRtime = startTime; + var lastRR = datArr[0].RR; + var rrTime = new List(); + var rrVal = new List(); + + for (var i = 0; i < datArr.Count(); i++) { + if (datArr[i].RR >= RR_MIN && datArr[i].RR <= RR_MAX) { + if (datArr[i].RR != lastRR) { + while (datArr[i].ElapTime - lastRRtime > datArr[i].RR * 0.001 + 0.1) { + lastRRtime += lastRR * 0.001; + rrTime.Add(lastRRtime); + rrVal.Add(lastRR); + } + rrTime.Add(datArr[i].ElapTime); + rrVal.Add(datArr[i].RR); + lastRRtime = datArr[i].ElapTime; + lastRR = datArr[i].RR; + } + } + } + // ノイズ除去 + const int M = 2; + var rrcTime = new List(); + var rrcVal = new List(); + for (var i = M; i < rrTime.Count() - M; i++) { + var wrrVal = rrVal.GetRange(i - M, M * 2 + 1); + wrrVal.Sort(); + var median = wrrVal[M]; + if (Math.Abs(rrVal[i] - median) / median < 0.5) { + rrcTime.Add(rrTime[i]); + rrcVal.Add(rrVal[i]); + } + } + // 時間等間隔に補間 + var linear = LinearSpline.Interpolate(rrcTime, rrcVal); // 線形補間 + //var cspline = CubicSpline.InterpolateNatural(rrcTime, rrcVal); // 3次スプライン補間 + var rriVal = new List(); + const int WINDOW_LEN = 512; // ウインドウサイズ + const int WINDOW_NUM = 4; // ウインドウ分割数 + int SAMPLES = (WINDOW_LEN / 2) * (WINDOW_NUM + 1); + const double fc = 0.04; // 低域遮断周波数 + double T = rrcTime.Max() - rrcTime[0]; + double F = 0.443 / fc; + int n = (int)Math.Floor(F * SAMPLES / (T * (1 - F / T))) + 1; // 移動平均サイズ + var interval = T / (SAMPLES + n); + // Debug.WriteLine($"dt={interval}, n={n}, fc={0.443 / (n * interval)}"); + for (var t = rrcTime[0]; t < rrcTime.Max(); t += interval) { + rriVal.Add(linear.Interpolate(t)); + } + // 移動平均によるトレンド除去 + var trend = Enumerable.Range(0, SAMPLES).Select(i => rriVal.Skip(i).Take(n).Average()).ToList(); + var rrtr = new List(); + var sum = 0D; + for (var i = 0; i < SAMPLES; i++) { + var tr = rriVal[i + n / 2] - trend[i]; + rrtr.Add(tr); + sum += tr; + } + // 平均偏差 + sum /= SAMPLES; + for (var i = 0; i < SAMPLES; i++) { + rrtr[i] -= sum; + //Debug.WriteLine($"{i * interval}\t{rrtr[i]}"); + } + // ウインドウ処理 + var taperWeight = new double[WINDOW_LEN]; + var taperSize = WINDOW_LEN / 10; + for (var i = 0; i < WINDOW_LEN; i++) { + taperWeight[i] = i < taperSize ? 0.5 * (1.0 - Math.Cos(Math.PI * (double)i / taperSize)) : + i > WINDOW_LEN- taperSize ? 0.5 * (1.0 + Math.Cos(Math.PI * (double)(i- WINDOW_LEN + taperSize) / taperSize)) : 1.0; + } + var fft = new Complex[WINDOW_NUM][]; + for (var w = 0; w < WINDOW_NUM; w++) { + var rrw = rrtr.GetRange(w * WINDOW_LEN / 2, WINDOW_LEN); + fft[w] = new Complex[WINDOW_LEN]; + for (var i = 0; i < WINDOW_LEN; i++) { + fft[w][i] = new Complex(rrw[i] * taperWeight[i], 0); + } + Fourier.Forward(fft[w], FourierOptions.Default); + } + var df = 1.0 / (WINDOW_LEN * interval); // フーリエ解析の周波数分解能 + LF[block] = 0D; + HF[block] = 0D; + const double LFmin = 0.04; + const double LFmax = 0.15; + const double HFmax = 0.4; + for (var i = 0; i < WINDOW_LEN / 2; i++) { + var fftm = 0D; + for (var w = 0; w < WINDOW_NUM; w++) { + fftm += fft[w][i].Magnitude * fft[w][i].Magnitude; + } + fftm /= WINDOW_NUM; + var power = 2.0 * fftm / 0.875 / WINDOW_LEN * interval; + LF[block] += i * df >= LFmin && i * df < LFmax ? power : 0; + HF[block] += i * df >= LFmax && i * df < HFmax ? power : 0; + //Debug.WriteLine($"{i * df}\t{power}"); + } + listView2.Items.Add(new ListViewItem(new string[] { + $"{block*10+1}-{block*10+10}", $"{LF[block]:0.0}", $"{HF[block]:0.0}", $"{LF[block]/HF[block]:0.00}" })); + } + // 表示 TxtFB1.Text = $"{fbCounts[0],2}回 {fbPts[0],4}ポイント"; TxtFB2.Text = $"{fbCounts[1],2}回 {fbPts[1],4}ポイント"; @@ -220,6 +334,7 @@ while (sr.Peek() > -1) { var line = sr.ReadLine().Split(sep); var ld = new LogData(); + ld.ElapTime = double.Parse(line[headerCol["time"]]); ld.StimNo = int.Parse(line[headerCol["stimNo"]]); ld.SceneTime = double.Parse(line[headerCol["stimTime"]]); ld.Target = int.Parse(line[headerCol["target"]]); diff --git a/EcomAnalysis/LogData.cs b/EcomAnalysis/LogData.cs index c723503..72d2749 100644 --- a/EcomAnalysis/LogData.cs +++ b/EcomAnalysis/LogData.cs @@ -17,7 +17,7 @@ } class LogData { - //public double ElapTime; // 経過時間 + public double ElapTime; // 経過時間 public int StimNo; // 刺激データ番号 public int SceneNo; // シーン番号 public double SceneTime; // 刺激提示の経過時間 diff --git a/EcomAnalysis/packages.config b/EcomAnalysis/packages.config new file mode 100644 index 0000000..b3e90ef --- /dev/null +++ b/EcomAnalysis/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file