コード例 #1
0
        public MainInterface()
        {
            InitializeComponent();
            database = new DatabaseControl();
            bw.WorkerSupportsCancellation = true;
            bw.WorkerReportsProgress = true;

            blankList = new List<bool>();

            //studies = database.Load();
            currentStudy = new Study();
            studyDisplay.DataSource = database.GetStudies();

            currentSubject = new Subject();
            //subjectDisplay.DataSource = currentStudy.subjects;

            currentSession = new Session();
            //sessionDisplay.DataSource = currentSubject.sessions;

            currentTrial = new Trial();
            //trialDisplay.DataSource = currentSession.trials;

            radiusSettings.SelectedIndex = 1;

            this.Refresh();
        }
コード例 #2
0
        public SensorReading(Study study, Subject subject, Session session, Trial trial, long recordnum, TrackerInterface.Record rec)
        {
            this.study = study;
            this.subject = subject;
            this.session = session;
            this.trial = trial;
            this.time = rec.time[0];

            sensors = new Sensor[32];

            for (int i = 0; i < sensors.Length; i++)
            {
                sensors[i] = new Sensor();
                sensors[i].active = rec.active[i];
                sensors[i].x = rec.x[i];
                sensors[i].y = rec.y[i];
                sensors[i].z = rec.z[i];
                sensors[i].pitch = rec.pitch[i];
                sensors[i].yaw = rec.yaw[i];
                sensors[i].roll = rec.roll[i];
                sensors[i].time = rec.time[i];
                if (this.time == 0)
                {
                    time = rec.time[i];
                }
                sensors[i].quality = rec.quality[i];
                sensors[i].button = rec.button[i];
            }
        }
コード例 #3
0
 public Trial_PreMongo(string name, string time, Study study, Subject subject, Session session)
 {
     this.study = study;
     this.subject = subject;
     this.session = session;
     this.name = name;
     this.data = new ConcurrentQueue<SensorReading>();
 }
コード例 #4
0
 public Session_PreMongo(string name, string tdate, Study study, Subject subject)
 {
     this.study = study;
     this.subject = subject;
     this.name = name;
     this.tdate = tdate;
     this.trials = new ObservableCollection<Trial>();
 }
コード例 #5
0
ファイル: Session.cs プロジェクト: smidget/AscensionControl
 public Session(string name, string tdate, Study study, Subject subject)
 {
     this.study = study;
     this.subject = subject;
     this.name = name;
     this.tdate = tdate;
     this.sync1_on = -1;
     this.sync1_off = -1;
     this.sync2_on = -1;
     this.sync2_off = -1;
     //this.trials = new ObservableCollection<Trial>();
 }
コード例 #6
0
ファイル: Exporter.cs プロジェクト: smidget/AscensionControl
        public void ExportSubjectToMultipleFiles(DatabaseControl db, Study study, Subject subject, string directory)
        {
            string header = "StudyName,SubjectID,SessionName,SessionDate,TrialName,SessionSync1.Onset,SessionSync1.Offset,SessionSync2.Onset,SessionSync2.Offset,";

            for (int i = 0; i < 15; i++)
            {
                header += string.Format("Sensor{0}.ID,Sensor{0}.Time,Sensor{0}.Switch,Sensor{0}.X,Sensor{0}.Y,Sensor{0}.Z,Sensor{0}.Pitch,Sensor{0}.Roll,Sensor{0}.Yaw,Sensor{0}.quality,", i);
            }

                foreach (Session sess in db.GetSessions(subject))
                {
                    foreach (Trial trial in db.GetTrials(sess))
                    {
                        Console.WriteLine("Dumping trial : " + trial.name);
                        string filename = directory + "\\" + study.name + "-" + subject.id + "-" + sess.name + "-" + trial.name + ".csv";
                        status = string.Format("{0} - {1} - {2} - {3}", study.name, subject.id, sess.name, trial.name);
                        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@filename))
                        {
                            file.Write(header + "\n");
                            int total = db.GetSensorReadings(trial).Count();
                            int count = 0;
                            foreach (SensorReading pt in db.GetSensorReadings(trial))
                            {
                                count++;
                                percent = Convert.ToInt32(Math.Ceiling((float)count / (float)total * 100.0));

                                Sensor[] sensors = pt.sensors;

                                // Append study/sub/sess/trial data
                                file.Write(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", study.name, subject.id, sess.name, sess.tdate, trial.name, sess.sync1_on, sess.sync1_off, sess.sync2_on, sess.sync2_off));
                                for (int i = 0; i < sensors.Length; i++)
                                {
                                    if (sensors[i].active == 1)
                                    {
                                        // Append sensor data whether sensor is active or not
                                        file.Write(string.Format(",{0},{9},{1},{2:0.00},{3:0.00},{4:0.00},{5:0.00},{6:0.00},{7:0.00},{8}",
                                            i, sensors[i].button, sensors[i].x, sensors[i].y, sensors[i].z, sensors[i].pitch, sensors[i].roll, sensors[i].yaw, sensors[i].quality, sensors[i].time));
                                    }
                                    else
                                    {
                                        // If the sensor wasn't active then append a blank filler
                                        file.Write(",,,,,,,,,,");
                                    }
                                }
                                file.Write("\n");
                            }
                        }
                        percent = 0;
                    }
                }
        }
コード例 #7
0
 public void SetTrial(Trial trial)
 {
     this.trial = trial;
     this.session = trial.session;
     this.subject = session.subject;
     this.study = session.study;
 }
コード例 #8
0
 public void RemoveSubject(Subject s)
 {
     var query = Query.Or(
         Query.EQ("_id", s._Id),
         Query.EQ("subject._id", s._Id)
         );
     subject_collection.Remove(query);
     session_collection.Remove(query);
     trial_collection.Remove(query);
     sensor_readings_collection.Remove(query);
 }
コード例 #9
0
 public int GetSubjectIndex(Subject subject)
 {
     ObservableCollection<Subject> subjects = GetSubjects(subject.study);
     for (int i = 0; i < subjects.Count; i++)
     {
         Subject s = subjects[i];
         if (subject._Id == s._Id)
         {
             Console.WriteLine("Found subject at {0}.", i);
             return i;
         }
     }
     Console.WriteLine("ERROR: Could not find subject.");
     return -1;
 }
コード例 #10
0
 public Exporter runExportSubjectByTrial(DatabaseControl database, Study currentStudy, Subject currentSubject, String directory)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToMultipleFiles(database, currentStudy, currentSubject, directory);
     return exporter;
 }
コード例 #11
0
 public void AddSubject(Subject s)
 {
     subject_collection.Insert(s);
 }
コード例 #12
0
        private void subjectDisplay_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine(subjectDisplay.SelectedIndex);
            if (subjectDisplay.SelectedIndex == -1)
            {
                subjectDisplay.ClearSelected();
            }
            else
            {
                currentSubject = database.GetSubjects(currentStudy)[subjectDisplay.SelectedIndex];
                Console.WriteLine(currentStudy.ToString());

                // Refresh the data windows
                sessionDisplay.DataSource = null;
                sessionDisplay.DataSource = database.GetSessions(currentSubject);
                //((CurrencyManager)sessionDisplay.BindingContext[sessionDisplay.DataSource]).Refresh();
                sessionDisplay.ClearSelected();

                trialDisplay.DataSource = blankList;
                ((CurrencyManager)trialDisplay.BindingContext[trialDisplay.DataSource]).Refresh();
                trialDisplay.ClearSelected();

            }
        }
コード例 #13
0
        private void removeSubject_Click(object sender, EventArgs e)
        {
            if (subjectDisplay.SelectedIndex > -1)
            {
                DialogResult result = MessageBox.Show("Are you sure you want to delete this subject?", "Remove Subject", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    currentSubject = database.GetSubjects(currentStudy)[subjectDisplay.SelectedIndex];
                    database.RemoveSubject(currentSubject);
                    currentSubject = null;

                    subjectDisplay.DataSource = null;
                    subjectDisplay.DataSource = database.GetSubjects(currentStudy);
                }
            }
        }
コード例 #14
0
        private void addNewSubject_Click(object sender, EventArgs e)
        {
            List<string> values = new List<string>();
            if (studyDisplay.SelectedIndex > -1)
            {
                DialogResult result = MainInterface.InputBox3("New Subject", "New Subject ID:", "New Subject Birthdate:", "New Subject Gender:", ref values);
                if (result == DialogResult.OK && values.Count > 0)
                {
                    Subject s = new Subject(values[0], values[1], values[2], currentStudy);
                    database.AddSubject(s);

                    subjectDisplay.DataSource = null;
                    subjectDisplay.DataSource = database.GetSubjects(currentStudy);
                    subjectDisplay.ClearSelected();
                    subjectDisplay.SetSelected(database.GetSubjectIndex(s), true);

                }
                else if (result == DialogResult.OK)
                {
                    MessageBox.Show("Invalid study name.");
                }
            }
        }
コード例 #15
0
ファイル: Exporter.cs プロジェクト: smidget/AscensionControl
        // This function will return a list of all of the times that the sync key was hit
        public List<int> FindSyncTimes(DatabaseControl db, Study study, Subject sub, Session sess)
        {
            List<int> times = new List<int>();

            return times;
        }
コード例 #16
0
 public ObservableCollection<Session> GetSessions(Subject subject)
 {
     ObservableCollection<Session> sessions = new ObservableCollection<Session>();
     var query = Query.And(
         Query.EQ("study._id", subject.study._Id),
         Query.EQ("subject._id", subject._Id)
         );
     foreach (Session session in session_collection.Find(query))
     {
         sessions.Add(session);
     }
     ObservableCollection<Session> sessionsSort = new ObservableCollection<Session>(
         sessions.OrderBy(session => session.name)
         );
     return sessions;
 }
コード例 #17
0
 public Exporter runExportSubject(DatabaseControl database, Study currentStudy, Subject currentSubject, String filename)
 {
     Thread.Sleep(100);
     exporter.ExportSubjectToCSVOneFile(database, currentStudy, currentSubject, filename);
     return exporter;
 }