/// <summary> /// This method returns the mouse clicks for the list of subjects /// on the trial with the given trial id. /// </summary> /// <param name="trialID">An <see cref="Int32"/> with the trial id.</param> /// <param name="checkedSubjects">A <see cref="List{String}"/> with the subject names.</param> /// <returns>A <see cref="SQLiteOgamaDataSet.MouseFixationsDataTable"/> /// with the mouse clicks.</returns> private DataTable GetFilteredMouseClicks(int trialID, List<string> checkedSubjects) { var clickTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); foreach (string entry in checkedSubjects) { // Ignore trials marked to be eliminated in analysis. DataTable currentTrial = Document.ActiveDocument.DocDataSet.TrialsAdapter.GetDataBySubjectAndTrialID(entry, trialID); if (currentTrial.Rows.Count > 0) { if (currentTrial.Rows[0]["EliminateData"] != null && currentTrial.Rows[0]["EliminateData"].ToString() != string.Empty) { continue; } else { int trialSequence = (int)currentTrial.Rows[0]["TrialSequence"]; DataTable trialEvents = Document.ActiveDocument.DocDataSet.TrialEventsAdapter.GetDataBySubjectAndSequence(entry, trialSequence); foreach (DataRow trialEvent in trialEvents.Rows) { string typeString = trialEvent["EventType"].ToString(); EventType type = EventType.None; try { type = (EventType)Enum.Parse(typeof(EventType), typeString, true); } catch (ArgumentException) { continue; } if (type == EventType.Mouse) { string taskString = trialEvent["EventTask"].ToString(); string paramString = trialEvent["EventParam"].ToString(); MouseStopCondition msc = (MouseStopCondition)TypeDescriptor.GetConverter(typeof(StopCondition)).ConvertFrom(paramString); InputEventTask task = (InputEventTask)Enum.Parse(typeof(InputEventTask), taskString, true); switch (task) { case InputEventTask.Down: SQLiteOgamaDataSet.MouseFixationsRow newRow = clickTable.NewMouseFixationsRow(); newRow.PosX = msc.ClickLocation.X; newRow.PosY = msc.ClickLocation.Y; newRow.SubjectName = entry; newRow.TrialID = trialID; newRow.TrialSequence = trialSequence; clickTable.AddMouseFixationsRow(newRow); break; } } else if (type == EventType.Response) { string taskString = trialEvent["EventTask"].ToString(); string paramString = trialEvent["EventParam"].ToString(); StopCondition sc = (StopCondition)TypeDescriptor.GetConverter(typeof(StopCondition)).ConvertFrom(paramString); if (sc is MouseStopCondition) { MouseStopCondition msc = sc as MouseStopCondition; InputEventTask task = (InputEventTask)Enum.Parse(typeof(InputEventTask), taskString, true); SQLiteOgamaDataSet.MouseFixationsRow newRow = clickTable.NewMouseFixationsRow(); newRow.PosX = msc.ClickLocation.X; newRow.PosY = msc.ClickLocation.Y; newRow.SubjectName = entry; newRow.TrialID = trialID; newRow.TrialSequence = trialSequence; clickTable.AddMouseFixationsRow(newRow); break; } } } } } } return clickTable; }
public virtual SQLiteOgamaDataSet.MouseFixationsDataTable GetDataByTrialID(int Param1) { this.Adapter.SelectCommand = this.CommandCollection[6]; this.Adapter.SelectCommand.Parameters[0].Value = Param1; var dataTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual SQLiteOgamaDataSet.MouseFixationsDataTable GetDataBySubjectAndTrialID(string Param1, int Param2) { this.Adapter.SelectCommand = this.CommandCollection[5]; if (Param1 == null) { throw new ArgumentNullException("Param1"); } this.Adapter.SelectCommand.Parameters[0].Value = Param1; this.Adapter.SelectCommand.Parameters[1].Value = Param2; var dataTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual SQLiteOgamaDataSet.MouseFixationsDataTable GetData() { this.Adapter.SelectCommand = this.CommandCollection[0]; var dataTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
/// <summary> /// Gets mouse fixation data table rows by given Where statement using the query: /// SELECT MouseFixations.* FROM [MouseFixations] WHERE WhereStatement /// ORDER BY SubjectName,TrialID,Length /// </summary> /// <param name="whereStatement">A <see cref="string"/> with the SQL WHERE /// statement for the query to use.</param> /// <returns>A <see cref="SQLiteOgamaDataSet.MouseFixationsDataTable"/> with found rows.</returns> /// <exception cref="ArgumentNullException">Thrown, when WhereStatement is empty.</exception> public static SQLiteOgamaDataSet.MouseFixationsDataTable GetMouseFixDataByWhereStatement(string whereStatement) { if (whereStatement == string.Empty) { throw new ArgumentNullException(); } SQLiteDataAdapter adapter = new SQLiteDataAdapter(); System.Data.Common.DataTableMapping tableMapping = new System.Data.Common.DataTableMapping(); tableMapping.SourceTable = "Table"; tableMapping.DataSetTable = "TableMouseFixations"; tableMapping.ColumnMappings.Add("ID", "ID"); tableMapping.ColumnMappings.Add("SubjectName", "SubjectName"); tableMapping.ColumnMappings.Add("TrialID", "TrialID"); tableMapping.ColumnMappings.Add("TrialSequence", "TrialSequence"); tableMapping.ColumnMappings.Add("CountInTrial", "CountInTrial"); tableMapping.ColumnMappings.Add("StartTime", "StartTime"); tableMapping.ColumnMappings.Add("Length", "Length"); tableMapping.ColumnMappings.Add("PosX", "PosX"); tableMapping.ColumnMappings.Add("PosY", "PosY"); adapter.TableMappings.Add(tableMapping); // Create the SelectCommand. var command = new SQLiteCommand( "SELECT MouseFixations.* FROM [MouseFixations] " + "WHERE " + whereStatement + " ORDER BY SubjectName,TrialID,Length", Document.ActiveDocument.DocDataSet.DatabaseConnection); // Set SelectCommand adapter.SelectCommand = command; // Create DataTable var dataTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); // Fill it with Data referring to Subject and Trial adapter.Fill(dataTable); return dataTable; }
/// <summary> /// This method returns the mouse clicks for the list of subjects /// on the trial with the given trial id. /// </summary> /// <param name="trialID">An <see cref="Int32"/> with the trial id.</param> /// <param name="checkedSubjects">A <see cref="List{String}"/> with the subject names.</param> /// <returns>A <see cref="SQLiteOgamaDataSet.MouseFixationsDataTable"/> /// with the mouse clicks.</returns> private DataTable GetFilteredMouseClicks(int trialID, List <string> checkedSubjects) { var clickTable = new SQLiteOgamaDataSet.MouseFixationsDataTable(); foreach (string entry in checkedSubjects) { // Ignore trials marked to be eliminated in analysis. DataTable currentTrial = Document.ActiveDocument.DocDataSet.TrialsAdapter.GetDataBySubjectAndTrialID(entry, trialID); if (currentTrial.Rows.Count > 0) { if (currentTrial.Rows[0]["EliminateData"] != null && currentTrial.Rows[0]["EliminateData"].ToString() != string.Empty) { continue; } else { int trialSequence = (int)currentTrial.Rows[0]["TrialSequence"]; DataTable trialEvents = Document.ActiveDocument.DocDataSet.TrialEventsAdapter.GetDataBySubjectAndSequence(entry, trialSequence); foreach (DataRow trialEvent in trialEvents.Rows) { string typeString = trialEvent["EventType"].ToString(); EventType type = EventType.None; try { type = (EventType)Enum.Parse(typeof(EventType), typeString, true); } catch (ArgumentException) { continue; } if (type == EventType.Mouse) { string taskString = trialEvent["EventTask"].ToString(); string paramString = trialEvent["EventParam"].ToString(); MouseStopCondition msc = (MouseStopCondition)TypeDescriptor.GetConverter(typeof(StopCondition)).ConvertFrom(paramString); InputEventTask task = (InputEventTask)Enum.Parse(typeof(InputEventTask), taskString, true); switch (task) { case InputEventTask.Down: SQLiteOgamaDataSet.MouseFixationsRow newRow = clickTable.NewMouseFixationsRow(); newRow.PosX = msc.ClickLocation.X; newRow.PosY = msc.ClickLocation.Y; newRow.SubjectName = entry; newRow.TrialID = trialID; newRow.TrialSequence = trialSequence; clickTable.AddMouseFixationsRow(newRow); break; } } else if (type == EventType.Response) { string taskString = trialEvent["EventTask"].ToString(); string paramString = trialEvent["EventParam"].ToString(); StopCondition sc = (StopCondition)TypeDescriptor.GetConverter(typeof(StopCondition)).ConvertFrom(paramString); if (sc is MouseStopCondition) { MouseStopCondition msc = sc as MouseStopCondition; InputEventTask task = (InputEventTask)Enum.Parse(typeof(InputEventTask), taskString, true); SQLiteOgamaDataSet.MouseFixationsRow newRow = clickTable.NewMouseFixationsRow(); newRow.PosX = msc.ClickLocation.X; newRow.PosY = msc.ClickLocation.Y; newRow.SubjectName = entry; newRow.TrialID = trialID; newRow.TrialSequence = trialSequence; clickTable.AddMouseFixationsRow(newRow); break; } } } } } } return(clickTable); }