public virtual SQLiteOgamaDataSet.GazeFixationsDataTable GetDataByTrialID(int Param1)
 {
   this.Adapter.SelectCommand = this.CommandCollection[6];
   this.Adapter.SelectCommand.Parameters[0].Value = Param1;
   var dataTable = new SQLiteOgamaDataSet.GazeFixationsDataTable();
   this.Adapter.Fill(dataTable);
   return dataTable;
 }
    public virtual SQLiteOgamaDataSet.GazeFixationsDataTable 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.GazeFixationsDataTable();
      this.Adapter.Fill(dataTable);
      return dataTable;
    }
示例#3
0
文件: Queries.cs 项目: DeSciL/Ogama
    /// <summary>
    /// Gets gaze fixation data table rows by given Where statement using the query:
    /// SELECT GazeFixations.* FROM [GazeFixations] 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.GazeFixationsDataTable"/> with found rows.</returns>
    /// <exception cref="ArgumentNullException">Thrown, when WhereStatement is empty.</exception>
    public static SQLiteOgamaDataSet.GazeFixationsDataTable GetGazeFixDataByWhereStatement(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 = "TableGazeFixations";
      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 GazeFixations.* FROM [GazeFixations] " +
        "WHERE " + whereStatement +
        " ORDER BY SubjectName,TrialID,Length",
        Document.ActiveDocument.DocDataSet.DatabaseConnection);

      // Set SelectCommand
      adapter.SelectCommand = command;

      // Create DataTable
      var dataTable = new SQLiteOgamaDataSet.GazeFixationsDataTable();

      // Fill it with Data referring to Subject and Trial
      adapter.Fill(dataTable);

      return dataTable;
    }
 public virtual SQLiteOgamaDataSet.GazeFixationsDataTable GetData()
 {
   this.Adapter.SelectCommand = this.CommandCollection[0];
   var dataTable = new SQLiteOgamaDataSet.GazeFixationsDataTable();
   this.Adapter.Fill(dataTable);
   return dataTable;
 }
示例#5
0
    /// <summary>
    /// This method parses the ezvisionlog.txt which is the output of the 
    /// ezvision.exe for the lines with the "CovertShift", 
    /// that indicates the fixation shift.
    /// </summary>
    /// <param name="duration">Out. An <see cref="Int32"/> with the duration
    /// up to the last fixation.</param>
    /// <returns>A <see cref="DataTable"/> with the parsed fixations.</returns>
    private DataTable ParseEzvisionLog(out int duration)
    {
      string workingPath = Properties.Settings.Default.SaliencyCalculationPath;
      string importFile = Path.Combine(workingPath, "ezvisionlog.txt");
      string line = string.Empty;
      int fixCounter = 0;
      duration = 0;
      var fixations = new SQLiteOgamaDataSet.GazeFixationsDataTable();

      // Check import file.
      if (!File.Exists(importFile))
      {
        throw new FileNotFoundException("The import file could not be found");
      }

      // Begin reading File
      try
      {
        using (StreamReader importReader = new StreamReader(importFile))
        {
          // Read ImportFile
          while ((line = importReader.ReadLine()) != null)
          {
            // only use lines containing "CovertShift"
            if (!line.Contains("CovertShift"))
            {
              continue;
            }

            // Split separated line items
            var items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var timeString = items[0].Replace("ms", string.Empty);
            var startTime = 0f;

            // Specify the dot as decimal separator.
            NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
            nfi.NumberDecimalSeparator = ".";

            float.TryParse(timeString, NumberStyles.Float, nfi, out startTime);
            var startTimeMS = (int)startTime;

            foreach (string item in items)
            {
              if (item.Contains("(") && item.Contains(")"))
              {
                string strCoordinatePair = item.Replace("(", string.Empty);
                strCoordinatePair = strCoordinatePair.Replace(")", string.Empty);
                string[] coordinates = strCoordinatePair.Split(',');

                var fixationRow = fixations.NewGazeFixationsRow();

                // Dummy entries
                fixationRow.SubjectName = string.Empty;
                fixationRow.TrialID = 0;
                fixationRow.TrialSequence = 0;

                // Interesting entries.
                fixationRow.StartTime = startTimeMS;
                fixationRow.PosX = Convert.ToInt32(coordinates[0]);
                fixationRow.PosY = Convert.ToInt32(coordinates[1]);
                fixationRow.CountInTrial = fixCounter;
                fixations.AddGazeFixationsRow(fixationRow);

                // Update length of foregoing fixation
                if (fixCounter >= 1)
                {
                  fixations[fixCounter - 1].Length = (int)(startTimeMS - fixations[fixCounter - 1].StartTime);
                  duration = (int)(fixations[fixCounter - 1].StartTime + fixations[fixCounter - 1].Length);
                }

                fixCounter++;
                break;
              }
            }
          }

          if (fixations.Count > 0)
          {
            fixations.Rows[fixations.Count - 1].Delete();
          }
        }

        return fixations;
      }
      catch (Exception ex)
      {
        ExceptionMethods.HandleException(ex);
      }

      return null;
    }