diff --git a/DataAnalysis/Analysis.cs b/DataAnalysis/Analysis.cs index 6402f0d..fe02248 100644 --- a/DataAnalysis/Analysis.cs +++ b/DataAnalysis/Analysis.cs @@ -11,31 +11,31 @@ const double ignoreTime = 2000.0D; public void Analyze() { - var imglist = new List() { 1, 2, 3 }; - foreach (var imgid in imglist) { - var logall = _data.Where(s => s.image == imgid).OrderBy(s => s.etime); - var startTime = logall.Min(s => s.etime); - var endTime = logall.Max(s => s.etime); - //Console.WriteLine($"image {imgid} {startTime} - {endTime}ms"); - //var grance = logall.Take(10); - //foreach (var d in grance) { - // Console.WriteLine($"{d.etime}, {d.image}, ({d.x}, {d.y})"); - //} - var target = logall.Where(s => s.etime > startTime + ignoreTime); - var mx = target.Average(s => s.x); - var my = target.Average(s => s.y); - var ssumx = 0D; - var ssumy = 0D; - foreach (var d in target) { - ssumx += (d.x - mx) * (d.x - mx); - ssumy += (d.y - my) * (d.y - my); - Console.WriteLine($"{d.etime},{d.image},{d.x - mx},{d.y - my}"); - } - var sdx = Math.Sqrt(ssumx / (double)target.Count()); - var sdy = Math.Sqrt(ssumy / (double)target.Count()); - //Console.WriteLine($"SD x={sdx}, y={sdy}"); - Console.WriteLine(",,,"); - } + //var imglist = new List() { 1, 2, 3 }; + //foreach (var imgid in imglist) { + // var logall = _data.Where(s => s.image == imgid).OrderBy(s => s.etime); + // var startTime = logall.Min(s => s.etime); + // var endTime = logall.Max(s => s.etime); + // //Console.WriteLine($"image {imgid} {startTime} - {endTime}ms"); + // //var grance = logall.Take(10); + // //foreach (var d in grance) { + // // Console.WriteLine($"{d.etime}, {d.image}, ({d.x}, {d.y})"); + // //} + // var target = logall.Where(s => s.etime > startTime + ignoreTime); + // var mx = target.Average(s => s.x); + // var my = target.Average(s => s.y); + // var ssumx = 0D; + // var ssumy = 0D; + // foreach (var d in target) { + // ssumx += (d.x - mx) * (d.x - mx); + // ssumy += (d.y - my) * (d.y - my); + // Console.WriteLine($"{d.etime},{d.image},{d.x - mx},{d.y - my}"); + // } + // var sdx = Math.Sqrt(ssumx / (double)target.Count()); + // var sdy = Math.Sqrt(ssumy / (double)target.Count()); + // //Console.WriteLine($"SD x={sdx}, y={sdy}"); + // Console.WriteLine(",,,"); + //} } public void ReadData(string filename) { @@ -43,31 +43,37 @@ var csv = new CsvFile(); csv.Open(filename, new List()); - foreach (var d in csv.Data) { - if (d.Length != 4) { - Console.WriteLine("CSVデータが4列になっていません"); - return; - } - var logdata = new LogData(); - if (!double.TryParse(d[0], out logdata.etime)) { - Console.WriteLine("CSVデータの1列目が実数になっていません"); - return; - } - if (!int.TryParse(d[1], out logdata.image)) { - Console.WriteLine("CSVデータの2列目が整数になっていません"); - return; - } - if (!double.TryParse(d[2], out logdata.x)) { - Console.WriteLine("CSVデータの3列目が実数になっていません"); - return; - } - if (!double.TryParse(d[3], out logdata.y)) { - Console.WriteLine("CSVデータの4列目が実数になっていません"); - return; - } - _data.Add(logdata); + if (csv.Headers.Length < 25 || csv.Headers.Length > 26) { + Console.WriteLine("CSVデータの列数が正しくありません."); + return; } - //Console.WriteLine($"{_data.Count}件のデータを読み込みました"); + bool WithScene = (csv.Headers.Length == 26); + + foreach (var d in csv.Data) { + var ld = new LogData(); + + int c = 0; + ld.ElapTime = double.Parse(d[c++]); + ld.StimNo = int.Parse(d[c++]); + if (WithScene) ld.SceneNo = int.Parse(d[c++]); + ld.SceneTime = double.Parse(d[c++]); + //ld.GazeV.x = float.Parse(d[c++]); + //ld.GazeV.y = float.Parse(d[c++]); + //ld.Shift.x = float.Parse(d[c++]); + //ld.Shift.y = float.Parse(d[c++]); + //ld.GazeI.x = float.Parse(d[c++]); + //ld.GazeI.y = float.Parse(d[c++]); + //ld.Target = int.Parse(d[c++]); + //ld.ContactTime = double.Parse(d[c++]); + //ld.Feedback = int.Parse(d[c++]); + //ld.TrainingLevel = int.Parse(d[c++]); + //ld.RR = int.Parse(d[c++]); + //ld.PupilL = float.Parse(d[c++]); + //ld.PupilR = float.Parse(d[c++]); + + _data.Add(ld); + } + Console.WriteLine($"{_data.Count}件のデータを読み込みました"); } } } diff --git a/DataAnalysis/LogData.cs b/DataAnalysis/LogData.cs index 8ebc383..f3e339b 100644 --- a/DataAnalysis/LogData.cs +++ b/DataAnalysis/LogData.cs @@ -5,10 +5,23 @@ using System.Threading.Tasks; namespace DataAnalysis { + + struct Point2f { public float x; public float y; } + class LogData { - public double etime; - public int image; - public double x; - public double y; + public double ElapTime; // 経過時間 + public int StimNo; // 刺激データ番号 + public int SceneNo; // シーン番号 + public double SceneTime; // 刺激提示の経過時間 + public Point2f GazeV; // 注視点(視野カメラ座標) + public Point2f Shift; // ずれ + public Point2f GazeI; // 注視点(画像座標) + public int Target; // ターゲット判定 + public double ContactTime; // 目標コンタクト時間 + public int Feedback; // フィードバック + public int TrainingLevel; // トレーニングレベル + public int RR; // バイタル出力(RR間隔) + public float PupilL; // 瞳孔径 + public float PupilR; // 瞳孔径 } } diff --git a/DataAnalysis/Program.cs b/DataAnalysis/Program.cs index e0863f7..8a40ede 100644 --- a/DataAnalysis/Program.cs +++ b/DataAnalysis/Program.cs @@ -10,11 +10,23 @@ class Program { static void Main(string[] args) { - var filename = @"D:\usr\DL\log\1_oguchi\log20191220_131538.csv"; - var analysis = new Analysis(); - analysis.ReadData(filename); - analysis.Analyze(); - //System.Console.ReadKey(); + var filename = @"D:\usr\prog\PrismSoftware\log\20201007_184239_nakaguchi_2.csv"; + + char[] sep = { ',' }; + using (var sr = new StreamReader(filename, Encoding.GetEncoding("shift_jis"))) { + while (sr.Peek() > -1) { + var line = sr.ReadLine().Split(sep, 14); + Console.WriteLine(line[2]); + } + } + + //var readToEnd = File.ReadAllText(filename, Encoding.GetEncoding("shift_jis")); + Console.WriteLine("done."); + + //var analysis = new Analysis(); + //analysis.ReadData(filename); + //analysis.Analyze(); + System.Console.ReadKey(); } diff --git a/EcomAnalysis/App.config b/EcomAnalysis/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/EcomAnalysis/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EcomAnalysis/EcomAnalysis.csproj b/EcomAnalysis/EcomAnalysis.csproj new file mode 100644 index 0000000..6c3f74f --- /dev/null +++ b/EcomAnalysis/EcomAnalysis.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C} + WinExe + EcomAnalysis + EcomAnalysis + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/EcomAnalysis/Form1.Designer.cs b/EcomAnalysis/Form1.Designer.cs new file mode 100644 index 0000000..86bcd0f --- /dev/null +++ b/EcomAnalysis/Form1.Designer.cs @@ -0,0 +1,36 @@ + +namespace EcomAnalysis { + partial class Form1 { + /// + /// 必要なデザイナー変数です。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 使用中のリソースをすべてクリーンアップします。 + /// + /// マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。 + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows フォーム デザイナーで生成されたコード + + /// + /// デザイナー サポートに必要なメソッドです。このメソッドの内容を + /// コード エディターで変更しないでください。 + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/EcomAnalysis/Form1.cs b/EcomAnalysis/Form1.cs new file mode 100644 index 0000000..37574d1 --- /dev/null +++ b/EcomAnalysis/Form1.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace EcomAnalysis { + public partial class Form1 : Form { + public Form1() { + InitializeComponent(); + } + } +} diff --git a/EcomAnalysis/Program.cs b/EcomAnalysis/Program.cs new file mode 100644 index 0000000..8f612b8 --- /dev/null +++ b/EcomAnalysis/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Diagnostics; + +namespace EcomAnalysis { + static class Program { + /// + /// アプリケーションのメイン エントリ ポイントです。 + /// + [STAThread] + static void Main() { + var args = Environment.GetCommandLineArgs(); + foreach (var a in args) { + Debug.WriteLine(a); + } + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/EcomAnalysis/Properties/AssemblyInfo.cs b/EcomAnalysis/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9788bda --- /dev/null +++ b/EcomAnalysis/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 +// 制御されます。アセンブリに関連付けられている情報を変更するには、 +// これらの属性値を変更します。 +[assembly: AssemblyTitle("EcomAnalysis")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EcomAnalysis")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから +// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、 +// その型の ComVisible 属性を true に設定してください。 +[assembly: ComVisible(false)] + +// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります +[assembly: Guid("7a0f46b7-29aa-4a68-9939-b6a523da333c")] + +// アセンブリのバージョン情報は、以下の 4 つの値で構成されています: +// +// メジャー バージョン +// マイナー バージョン +// ビルド番号 +// リビジョン +// +// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます +// 既定値にすることができます: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/EcomAnalysis/Properties/Resources.Designer.cs b/EcomAnalysis/Properties/Resources.Designer.cs new file mode 100644 index 0000000..4d6b67f --- /dev/null +++ b/EcomAnalysis/Properties/Resources.Designer.cs @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします +// +//------------------------------------------------------------------------------ + + +namespace EcomAnalysis.Properties { + /// + /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 + /// + // このクラスは StronglyTypedResourceBuilder クラスが ResGen + // または Visual Studio のようなツールを使用して自動生成されました。 + // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に + // ResGen を実行し直すか、または VS プロジェクトをリビルドします。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// このクラスで使用されるキャッシュされた ResourceManager インスタンスを返します。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if ((resourceMan == null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EcomAnalysis.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします + /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/EcomAnalysis/Properties/Resources.resx b/EcomAnalysis/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/EcomAnalysis/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/EcomAnalysis/Properties/Settings.Designer.cs b/EcomAnalysis/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5ffe26a --- /dev/null +++ b/EcomAnalysis/Properties/Settings.Designer.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +namespace EcomAnalysis.Properties { + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/EcomAnalysis/Properties/Settings.settings b/EcomAnalysis/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/EcomAnalysis/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/PrismSoftware.sln b/PrismSoftware.sln index 56bca0f..ba45f05 100644 --- a/PrismSoftware.sln +++ b/PrismSoftware.sln @@ -13,6 +13,8 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECTrainer2", "ECTrainer2\ECTrainer2.vcxproj", "{9C2C0D9D-9C59-47C4-8FF6-7F21C9B8C968}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EcomAnalysis", "EcomAnalysis\EcomAnalysis.csproj", "{7A0F46B7-29AA-4A68-9939-B6A523DA333C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,6 +52,7 @@ {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|x64.ActiveCfg = Debug|Any CPU + {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|x64.Build.0 = Debug|Any CPU {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|x86.ActiveCfg = Debug|Any CPU {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Debug|x86.Build.0 = Debug|Any CPU {EE0E8DA2-9781-44A8-B15A-BAD7D5BB03CB}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -67,6 +70,17 @@ {9C2C0D9D-9C59-47C4-8FF6-7F21C9B8C968}.Release|x64.Build.0 = Release|x64 {9C2C0D9D-9C59-47C4-8FF6-7F21C9B8C968}.Release|x86.ActiveCfg = Release|Win32 {9C2C0D9D-9C59-47C4-8FF6-7F21C9B8C968}.Release|x86.Build.0 = Release|Win32 + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Debug|x64.ActiveCfg = Debug|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Debug|x86.ActiveCfg = Debug|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Debug|x86.Build.0 = Debug|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|Any CPU.Build.0 = Release|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|x64.ActiveCfg = Release|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|x64.Build.0 = Release|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|x86.ActiveCfg = Release|Any CPU + {7A0F46B7-29AA-4A68-9939-B6A523DA333C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE