コード例 #1
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                //Get the list of words to use for this study block
                var hal_config             = HumanAcceleratedLearningConfiguration.GetInstance();
                var available_dictionaries = hal_config.LanguageDictionaries;
                source_language_dictionary = available_dictionaries.Where(x =>
                                                                          x.ForeignLanguageName.Equals(ForeignLanguage) &&
                                                                          x.NativeLanguageName.Equals(NativeLanguage)
                                                                          ).FirstOrDefault();

                //Shuffle the words
                if (source_language_dictionary != null)
                {
                    var word_list = source_language_dictionary.DictionaryWordPairs.ToList();
                    shuffled_word_list     = MathHelperMethods.ShuffleList(word_list);
                    last_word_display_time = DateTime.MinValue;
                    current_wordpair_index = 0;

                    //Create a file for this study session
                    fid = StudyBlock.CreateStudyBlockFile(current_subject.UserName);

                    HasPhaseStarted = true;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Saves a human subject to a data file
        /// </summary>
        /// <param name="s"></param>
        public static void SaveHumanSubject(HumanSubject s)
        {
            //Construct a file name for the patient data file
            string file_name = s.UserName + ".txt";

            //Construct a path for the save location
            string path_name = HumanAcceleratedLearningConfiguration.GetInstance().PrimarySavePath;

            //Create the directory if it doesn't exist
            DirectoryInfo info = new DirectoryInfo(path_name);

            if (!info.Exists)
            {
                info.Create();
            }

            //Open the file for writing
            string       full_path_and_file = path_name + file_name;
            StreamWriter writer             = new StreamWriter(full_path_and_file);

            writer.WriteLine(s.UserName);
            writer.WriteLine(MathHelperMethods.ConvertDateTimeToMatlabDatenum(s.StartDate).ToString());

            //Write out the names of each segment in the order that they were performed in the participant's first visit
            foreach (var seg in s.FirstVisitStage.StageSegments)
            {
                writer.WriteLine(seg.SegmentName);
            }

            //Close the file
            writer.Close();
        }
コード例 #3
0
        /// <summary>
        /// Writes a study trial for the object location to the file
        /// </summary>
        public static void WriteObjectLocationStudyTrial(StreamWriter fid, string image_name, double xpos, double ypos, DateTime time_presented)
        {
            double matlab_time = MathHelperMethods.ConvertDateTimeToMatlabDatenum(time_presented);

            fid.WriteLine("OBJECT, " + image_name + ", " + xpos.ToString("0.##") + ", " + ypos.ToString("0.##") + ", " + matlab_time.ToString());
            fid.Flush();
        }
コード例 #4
0
        /// <summary>
        /// Writes a study trial to the file
        /// </summary>
        public static void WriteStudyTrial(StreamWriter fid, string foreign_language_word, string native_word, DateTime time_presented)
        {
            double matlab_time = MathHelperMethods.ConvertDateTimeToMatlabDatenum(time_presented);

            fid.WriteLine(foreign_language_word.ToString() + ", " + native_word.ToString() + ", " + matlab_time.ToString());
            fid.Flush();
        }
コード例 #5
0
        public static void WriteTestBlockTrial(StreamWriter fid, TestBlockTrial t)
        {
            double matlab_time_presented = MathHelperMethods.ConvertDateTimeToMatlabDatenum(t.PresentationTime);

            fid.WriteLine(t.ForeignWord + ", " + t.NativeInput + ", " + t.Correct.ToString() + ", " +
                          matlab_time_presented.ToString() + ", " + t.InputLatency.ToString());
            fid.Flush();
        }
        public static void WriteTestBlockTrial(StreamWriter fid, TestBlockTrial_ObjectLocation t)
        {
            string pos_x                 = t.PositionX.ToString();
            string pos_y                 = t.PositionY.ToString();
            string cpos_x                = t.CorrectPositionX.ToString();
            string cpos_y                = t.CorrectPositionY.ToString();
            string dist                  = t.DistanceFromCorrectPosition.ToString("0.##");
            string correct_bool          = t.Correct.ToString();
            string latency               = t.InputLatency.ToString("0.##");
            double matlab_time_presented = MathHelperMethods.ConvertDateTimeToMatlabDatenum(t.PresentationTime);

            fid.WriteLine(t.ImageName + ", " + pos_x + ", " + pos_y + ", " + cpos_x + ", " + cpos_y + ", " + dist + ", " + correct_bool + ", " +
                          latency + ", " + matlab_time_presented.ToString());
            fid.Flush();
        }
コード例 #7
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                current_subject_obj = current_subject;

                //Get the list of words to use for this test block
                var hal_config = HumanAcceleratedLearningConfiguration.GetInstance();
                source_language_dictionary = hal_config.LanguageDictionaries.Where(x =>
                                                                                   (x.ForeignLanguageName.Equals(ForeignLanguage) &&
                                                                                    x.NativeLanguageName.Equals(NativeLanguage))
                                                                                   ).FirstOrDefault();

                //Get the list of words that this participant has already gotten correct in previous test blocks
                current_subject.MakeSureCorrectlyAnsweredWordListExistsForSubject(ForeignLanguage);
                if (source_language_dictionary != null)
                {
                    var correct_word_list = current_subject.CorrectlyAnsweredWordList[ForeignLanguage];
                    var all_word_pairs    = source_language_dictionary.DictionaryWordPairs.ToList();
                    var ordered_foreign_language_Words = all_word_pairs.Select(x => x.Item1).ToList();

                    //Remove the words from the list of word pairs that have already been answered correctly
                    for (int i = 0; i < correct_word_list.Count; i++)
                    {
                        int index = ordered_foreign_language_Words.IndexOf(correct_word_list[i]);
                        if (index > -1)
                        {
                            ordered_foreign_language_Words.RemoveAt(index);
                            all_word_pairs.RemoveAt(index);
                        }
                    }

                    //Shuffle the remaining words
                    shuffled_word_list     = MathHelperMethods.ShuffleList(all_word_pairs);
                    last_word_display_time = DateTime.MinValue;
                    test_start_time        = DateTime.Now;
                    current_wordpair_index = 0;

                    //Create a file for this test session
                    fid = TestBlock.CreateTestBlockFile(current_subject.UserName);

                    HasPhaseStarted = true;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Loads data from a previously created human subject.
        /// </summary>
        public static HumanSubject LoadHumanSubject(string username)
        {
            HumanSubject s = new HumanSubject();

            //Construct a file name to load
            string file_name = username + ".txt";

            //Construct a full path and file
            string fully_qualified_path = HumanAcceleratedLearningConfiguration.GetInstance().PrimarySavePath + file_name;

            //Check to see if the patient data file exists
            FileInfo info = new FileInfo(fully_qualified_path);

            //If the patient data file exists...
            if (info.Exists)
            {
                //Read the contents of the file
                List <string> lines = ConfigurationFileLoader.LoadFileLines(fully_qualified_path);

                //Read the user name
                s.UserName = lines[0].Trim();

                //Read the participant's start date
                double matlab_datenum = 0;
                bool   success        = Double.TryParse(lines[1], out matlab_datenum);
                if (success)
                {
                    s.StartDate = MathHelperMethods.ConvertMatlabDatenumToDateTime(matlab_datenum);
                }

                //Now read the order of the participant's segments
                for (int i = 2; i < lines.Count; i++)
                {
                    s.SegmentOrder.Add(lines[i].Trim());
                }
            }

            return(s);
        }
コード例 #9
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                _current_subject = current_subject;

                if (current_subject.AllObjectImages.Count == 0 && current_subject.AllObjectImageLocations.Count == 0)
                {
                    var res_folder = HumanAcceleratedLearningConfiguration.GetInstance().ResourcesFolder;
                    var img_path   = HumanAcceleratedLearningConfiguration.GetInstance().ObjectLocationImagesPath;
                    var all_images = Directory.GetFiles(res_folder + img_path).ToList();

                    current_subject.AllObjectImages = all_images;
                    last_picture_display_time       = DateTime.MinValue;
                    current_image_index             = 0;

                    for (int i = 0; i < all_images.Count; i++)
                    {
                        var loc_x = MathHelperMethods.RandomNumbers.Next(1, Convert.ToInt32(grid_columns) - 1);
                        var loc_y = MathHelperMethods.RandomNumbers.Next(1, Convert.ToInt32(grid_rows) - 1);
                        current_subject.AllObjectImageLocations.Add(new Tuple <int, int>(loc_x, loc_y));
                    }

                    //Save all of the object locations to a file
                    ObjectLocation_FileHandler.WriteAllObjectLocationsToFile(current_subject);
                }

                //Create a shuffled list of image indices for this study session
                var all_indices = Enumerable.Range(0, current_subject.AllObjectImages.Count).ToList();
                shuffled_list_of_image_indices = MathHelperMethods.ShuffleList(all_indices);

                //Create a file for this study session
                fid = StudyBlock.CreateStudyBlockFile(current_subject.UserName);

                HasPhaseStarted = true;
                StartTime       = DateTime.Now;
            }
        }
コード例 #10
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                _current_subject          = current_subject;
                last_picture_display_time = DateTime.MinValue;
                current_image_index       = 0;

                if (current_subject.AllObjectImages.Count == 0)
                {
                    ObjectLocation_FileHandler.ReadObjectLocationFile(current_subject);

                    /*var res_folder = HumanAcceleratedLearningConfiguration.GetInstance().ResourcesFolder;
                     * var img_path = HumanAcceleratedLearningConfiguration.GetInstance().ObjectLocationImagesPath;
                     * var all_images = Directory.GetFiles(res_folder + img_path).ToList();
                     *
                     * current_subject.AllObjectImages = all_images;*/
                }

                if (current_subject.AllObjectImages.Count > 0)
                {
                    //Remove images that have already been correctly answered
                    usable_images          = current_subject.AllObjectImages.Where((y, x) => !current_subject.CorrectlyAnsweredImageList.Contains(x)).ToList();
                    usable_image_positions = current_subject.AllObjectImageLocations.Where((y, x) => !current_subject.CorrectlyAnsweredImageList.Contains(x)).ToList();

                    //Create a shuffled list of image indices for this study session
                    var all_indices = Enumerable.Range(0, usable_images.Count).ToList();
                    shuffled_list_of_image_indices = MathHelperMethods.ShuffleList(all_indices);

                    //Create a file for this study session
                    fid = TestBlock.CreateTestBlockFile(current_subject.UserName);

                    HasPhaseStarted = true;
                    StartTime       = DateTime.Now;
                }
            }
        }