Exemplo n.º 1
0
        // Routine  to do the following functions :
        // 1> Validates the file names at each step
        // 2> Checks and Creates Gaze file if not found
        // 3> checks and  creates Display File if not found
        // on ERROR : throws ATLogic Exception with a User message  Wrapped around the System message.
        private String setUp(String gelogFileName)
        {
            ReplayTrial.cleanUp();
            DisplayFileCreation.cleanUp();

            // validate the input File name chosen by the User
            String geLogFileName = this.selectTrialBox.Text;

            if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "")
            {
                MessageBox.Show("Select a valid Trial file to replay");
                this.selectTrialBox.Clear();
                return(null);
            }

            //  Validation Success at this point
            // retrieve EDF file( created  by Eyelink ) that is found in the session directory.
            String edfFileName = getEDFFileName(geLogFileName);

            if (edfFileName == null)
            {
                MessageBox.Show("EDF File not found  : given gelogFile " + geLogFileName);
                this.selectTrialBox.Clear();
                return(null);
            }

            //1. From the EDF file obtained above,convert the file from .EDF  format to .ASC file format and
            //2. Create Gaze Files (split the single .ASC file into as many gaze files as the number of trials foudn in the session).
            //3. Retrieve the gaze file for the Given Trial

            string edfGazeFileName = null;

            try
            {
                edfGazeFileName = createAndRetrieveGazeFile(edfFileName, geLogFileName);
            }
            catch (Exception)
            {
                MessageBox.Show("EDF Gaze File not found  : given edfFile " + edfFileName);
                this.selectTrialBox.Clear();
                return(null);
            }

            if (edfGazeFileName == null)
            {
                MessageBox.Show("Error retrieving Edf Gaze File : given gelogFile " + geLogFileName);
                this.selectTrialBox.Clear();
                return(null);
            }

            // At this point, we have both gaze file and gelog file required to create a display file.
            // Retrieve a  name for the Display file to be created from the given gelog file and gaze file names.
            String displayFileName = null;

            try
            {
                displayFileName = DisplayFileCreation.GetDisplayFileName(geLogFileName);
            }
            catch (Exception)
            {
                MessageBox.Show("Error Retrieving Display File Name ");
                this.selectTrialBox.Clear();
                return(null);
            }

            if (displayFileName == null)
            {
                MessageBox.Show("Error Retrieving Display File Name ");
                this.selectTrialBox.Clear();
                return(null);
            }

            if (!File.Exists(displayFileName))
            {
                DisplayFileCreation.create(geLogFileName, edfGazeFileName, displayFileName);
            }
            if (!File.Exists(displayFileName))
            {
                MessageBox.Show("Error Creating Display File Name :" + displayFileName);
                this.selectTrialBox.Clear();
                return(displayFileName);
            }
            return(displayFileName);
        }
Exemplo n.º 2
0
        // Routine to handle Generation of XLS  file Creation
        private void GenerateXLS_Click_Click(object sender, EventArgs e)
        {
            try
            {
                ReplayTrial.cleanUp();
                DisplayFileCreation.cleanUp();

                // validate the input File name chosen by the User
                String geLogFileName = this.selectTrialBox.Text;
                if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "")
                {
                    MessageBox.Show("Select a valid Trial file to replay");
                    this.selectTrialBox.Clear();
                    return;
                }

                String xlsFileName = ATUtil.retrieveXLSFileName(geLogFileName, "GELOG");
                if (ATUtil.checkIfXLSFileExists(xlsFileName))
                {
                    MessageBox.Show("XLS File Exists");
                    this.selectTrialBox.Clear();
                    return;
                }
                String displayFileName = setUp(geLogFileName);
                // Create Human Readable File
                WaitMessageForm waitMessageFrm = new WaitMessageForm();

                //waitMessageFrm.Location = new System.Drawing.Point(0, 0);
                waitMessageFrm.TopMost = true;
                waitMessageFrm.BringToFront();
                waitMessageFrm.Show();
                waitMessageFrm.Refresh();

                XML2XLS converter = new XML2XLS(displayFileName);
                try
                {
                    converter.convert();

                    waitMessageFrm.Hide();
                    waitMessageFrm.Close();

                    MessageBox.Show(" XML to XLS file converted Successfully");
                }
                catch (SystemException e3)
                {
                    // do nothing
                    MessageBox.Show(e3.Message);
                }
                catch (Exception e2)
                {
                    // do nothing
                    MessageBox.Show(e2.Message);
                }
                finally
                {
                    converter = null;
                }
            }
            catch (ATLogicException e3)
            {
                MessageBox.Show("Analysis Tool Exception : Error Creating XLS file : " + e3.getATLogicErrorMessage());
                MessageBox.Show("Analysis Tool Exception : Error Creating XLS file : " + e3.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }
            catch (SystemException e4)
            {
                MessageBox.Show(" AT Exception :Error Creating XLS file : " + e4.Message);
                MessageBox.Show(" AT Exception : Error Creating XLS file : " + e4.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }
            catch (Exception e5)
            {
                MessageBox.Show(" Generic Exception : Error Creating XLS file  : " + e5.Message);
                MessageBox.Show(" Generic Exception : Error Creating XLS file  : " + e5.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }
        }
Exemplo n.º 3
0
        /**
         * Routine to enqueue Time stamp with Object Position Data from GELog File
         * Gets called from Thread
         */
        public void doWork()
        {
            try
            {
                // retrieve all Object Positions data and enqueue them
                Regex timeStartRegex = new Regex("^TimeStart");
                Regex timeEndRegex   = new Regex("^TimeEnd");
                if (File.Exists(geLogFileName))
                {
                    using (StreamReader sr = new StreamReader(geLogFileName))
                    {
                        // DisplayFileCreation.WriteError("in Object Data worker  thread : doWork method : stream reader opened found");

                        String newLine = null;

                        do
                        {
                            do
                            {
                                newLine = sr.ReadLine();
                            } while (newLine != null && !(timeStartRegex.IsMatch(newLine)));

                            if (newLine == null)
                            {
                                break;
                            }

                            // Split the new line to obtain the timeStamp data
                            String[] timeStampData = Regex.Split(newLine.Trim(), "\\s+");

                            ObjPositionData objPosData = new ObjPositionData();
                            objPosData.timeStamp = Convert.ToInt32(timeStampData[1].Trim());

                            String objDataLine;
                            // here we have a line that has Time Stamp Data
                            // continue to read new Line and Process the line's contents until TimeEnd node is seen
                            objDataLine = sr.ReadLine();
                            while (objDataLine != null && !timeEndRegex.IsMatch(objDataLine))
                            {
                                string[] objData = Regex.Split(objDataLine, "\\s+");

                                ObjectData data    = new ObjectData();
                                String     objname = objData[0].Trim().Substring(0, objData[0].Trim().Length - 1);
                                String     xPos    = objData[1].Trim();
                                String     yPos    = objData[3].Trim();

                                data.objName = objname;
                                data.xPos    = Convert.ToInt32(xPos);
                                data.yPos    = Convert.ToInt32(yPos);

                                objPosData.addObjData(data);
                                //  DisplayFileCreation.WriteError("in Object data  worker  thread : doWork method : " + Convert.ToInt32(xPos));
                                // move on to next line
                                objDataLine = sr.ReadLine();
                            }// end of while loop  -- reading data from a unique TimeStart node
                            if (newLine == null)
                            {
                                break;
                            }
                            DisplayFileCreation.geLogTrialDataQueue.Enqueue(objPosData); // enqueue positions of all objects for the current TimeStamp
                        } while (newLine != null);                                       // move on to next line  until EOF
                    }// end of reading from Stream Reader
                }
                else
                {
                    DisplayFileCreation.WriteError("Aborting processing Trial info .Invalid Input File : " + geLogFileName);
                }
            }

            catch (StackOverflowException e)
            {
                DisplayFileCreation.WriteError(" StackOverflowException : " + e.StackTrace);
            }
            catch (SystemException e)
            {
                DisplayFileCreation.WriteError(" SystemException : " + e.StackTrace);
            }

            catch (ApplicationException e)
            {
                DisplayFileCreation.WriteError(" ApplicationException : " + e.StackTrace);
            }

            catch (Exception) {
                throw;
            }
        }
Exemplo n.º 4
0
        /**
         * Event to handle replay button click
         * Creates a Display File and Human readable file for the input Trial if one does not exist and replays the trial
         * Display File  - user_selected__trial_name.display  ( XML file format)
         * Display Readable File - user_selected_trial_name.xls ( Microsoft Excel file )
         *
         * @Author : Smitha Madhavamurthy
         * @date : 04-05-2007
         *
         */
        private void replay_click(object sender, EventArgs e)
        {
            try
            {
                ReplayTrial.cleanUp();
                DisplayFileCreation.cleanUp();

                // validate the input File name chosen by the User
                String geLogFileName = this.selectTrialBox.Text;
                if (this.selectTrialBox == null || this.selectTrialBox.Text == null || geLogFileName == null || geLogFileName == "")
                {
                    MessageBox.Show("Select a valid Trial file to replay");
                    this.selectTrialBox.Clear();
                    return;
                }
                String displayFileName = setUp(geLogFileName);
                // Check to see user's option of the Speed of Replay
                try
                {
                    String speedFactor = "NORMAL";
                    ReplayTrial.DisplayFileName = displayFileName;
                    if (slow_speed)
                    {
                        speedFactor = "SLOW";
                    }
                    else if (very_slow_speed)
                    {
                        speedFactor = "VERYSLOW";
                    }
                    else if (fast_speed)
                    {
                        speedFactor = "FAST";
                    }
                    else
                    {
                        speedFactor = "NORMAL";
                    }

                    // Now invoke the  routine to Start Replaying the Trial
                    ReplayTrial.display(speedFactor);
                }
                catch (SystemException e1)
                {
                    MessageBox.Show(" System Exception : Error replaying Trial : " + e1.Message);
                    MessageBox.Show(" System Exception : Error replaying Trial : " + e1.StackTrace);
                    this.selectTrialBox.Clear();
                    return;
                }

                catch (ATLogicException e2)
                {
                    MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e2.getATLogicErrorMessage());
                    MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e2.StackTrace);
                    this.selectTrialBox.Clear();
                    return;
                }
            }
            catch (ATLogicException e3)
            {
                MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e3.getATLogicErrorMessage());
                MessageBox.Show("Analysis Tool Exception : Error replaying Trial : " + e3.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }
            catch (SystemException e4)
            {
                MessageBox.Show(" AT Exception : Error replaying Trial : " + e4.Message);
                MessageBox.Show(" AT Exception : Error replaying Trial : " + e4.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }
            catch (Exception e5) // any generic Exception
            {
                MessageBox.Show(" Generic Exception : Error replaying Trial : " + e5.Message);
                MessageBox.Show(" Generic Exception : Error replaying Trial : " + e5.StackTrace);
                this.selectTrialBox.Clear();
                return;
            }

            this.selectTrialBox.Clear(); // clears the field that holds the user selected Trial name
        }
Exemplo n.º 5
0
        /**
         * Routine to enqueue Gaze position data into a Queue
         */
        public void doWork()
        {
            //local  variable
            ObjPositionData gazePrevData = null;
            float           prevXpos     = 0;
            float           prevYPos     = 0;

            DisplayFileCreation.logData("Gaze  worker  thread : Processing doWork method ");
            if (File.Exists(edfFileName))
            {
                DisplayFileCreation.logData("in gaze  worker  thread : doWork method  : edf  file exists");


                // retrieve all Gaze Position data and enqueue them
                using (StreamReader sr = new StreamReader(edfFileName))
                {
                    // DisplayFileCreation.WriteError("in gaze  worker  thread : doWork method : stream reader  opened");

                    String line;

                    do
                    {
                        line = sr.ReadLine();
                        if (line != null && gazePostionRegex.IsMatch(line))
                        {
                            // here have a line that has gaze position data
                            ObjPositionData gazeData = new ObjPositionData();
                            ObjectData      data     = new ObjectData();

                            String[] split = Regex.Split(line.Trim(), "\\s+");

                            if (split.Length < 3)
                            {
                                continue;
                            }

                            String str1 = split[0];
                            String str2 = split[1];
                            String str3 = split[2];
                            if (str2 == "." || str3 == ".")
                            {
                                String timestampNew = str1;
                                ////if (gazePrevData != null)
                                // {
                                gazePrevData = new ObjPositionData();

                                gazePrevData.TimeStamp = Convert.ToInt32(timestampNew);
                                ObjectData thisData = new ObjectData();
                                thisData.IsTargetObject = 0;
                                thisData.ObjName        = "gaze";
                                thisData.XPos           = prevXpos;
                                thisData.YPos           = prevYPos;
                                gazePrevData.addObjData(thisData);

                                DisplayFileCreation.edfTrialDataQueue.Enqueue(gazePrevData);
                                // }
                                //  * */
                                //   continue;
                            }
                            else
                            {
                                String timestamp = split[0].Trim();
                                String xPos      = split[1].Trim();
                                String yPos      = split[2].Trim();

                                data.objName = "gaze";
                                float xpos = -1;
                                float ypos = -1;
                                try
                                {
                                    xpos = float.Parse(xPos);
                                    ypos = float.Parse(yPos);
                                }
                                catch (Exception)
                                {
                                    continue;
                                }
                                if (xpos == -1 || ypos == -1)
                                {
                                    continue;
                                }
                                else
                                {
                                    data.xPos = xpos;
                                    data.yPos = ypos;
                                    gazeData.addObjData(data);
                                    gazeData.timeStamp = Convert.ToInt32(timestamp);
                                    DisplayFileCreation.edfTrialDataQueue.Enqueue(gazeData);
                                    prevXpos               = xpos;
                                    prevYPos               = ypos;
                                    gazePrevData           = null;
                                    gazePrevData           = new ObjPositionData();
                                    gazePrevData.TimeStamp = gazeData.timeStamp;
                                    LinkedList <ObjectData> list = gazeData.getobjList();
                                    gazePrevData.setObjList(list);
                                }
                                //DisplayFileCreation.WriteError("in gaze  worker  thread : doWork method : " + Convert.ToInt32(timestamp));
                            } // else loop ends
                        }     // end of if loop
                    } while (line != null);
                }             // end of reading from Stream Reader
            }
            else
            {
                DisplayFileCreation.WriteError("ABORTING processing Object Position Data: Invalid input File :" + edfFileName);
            }
        } // end of enqueing Gaze data from EDF File