Ejemplo n.º 1
0
        public virtual List <string> RunData()
        {
            List <string> data         = new List <string>();
            string        subjectGroup = (run.Subject.SubjectGroup != null) ? run.Subject.SubjectGroup.ToString() : "";

            initializeCounters();
            initializeRunEventsInRange();
            calculateCounters(runEventsInRange);

            data.Add(run.Trial.Session.BehavioralTest.Project.ToString());
            data.Add(run.Subject.ToString());

            data.Add(subjectGroup);
            data.Add(run.Subject.Strain);
            data.Add(run.Subject.Sex);
            data.Add(run.Trial.ToString());
            data.Add(run.Trial.Duration.ToString());
            data.Add(run.TmRun.ToString("dd/MM/yyyy"));
            data.Add(run.TmRun.ToString("HH:mm:ss"));

            data.Add(runEventsInRange.Count.ToString());

            foreach (var behaviorTotal in stateBehaviorTotalDuration)
            {
                data.Add(behaviorTotal.Value.ToString("F3"));
            }

            foreach (var behaviorCount in behaviorFrequency)
            {
                data.Add(behaviorCount.Value.ToString());
            }

            foreach (var behaviorTime in stateBehaviorLatency)
            {
                double?latency = stateBehaviorLatency[behaviorTime.Key];
                if (latency == null)
                {
                    latency = exportSettings.ExportEnd;
                }
                data.Add(latency.Value.ToString("F3"));
            }

            if (exportSettings.UseTimeBins)
            {
                ExportTimeBin  exportTimeBin = new ExportTimeBin(run, exportSettings, stateRunEventsInRange);
                List <TimeBin> timeBins      = exportTimeBin.calculateTimeBins();
                data.AddRange(exportTimeBin.data());
            }

            return(data);
        }
Ejemplo n.º 2
0
        public virtual List <string> Headers()
        {
            Trial          trial          = run.Trial;
            List <string>  headers        = new List <string>();
            BehavioralTest behavioralTest = trial.Session.BehavioralTest;

            headers.Add("Project");
            headers.Add("SubjectID");
            headers.Add("SubjectGroup");
            headers.Add("Strain");
            headers.Add("Sex");
            headers.Add("TrialName");
            headers.Add("TrialDuration");
            headers.Add("DateRun");
            headers.Add("TimeRun");
            headers.Add("Number of Events");

            // Duration
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                if (behavior.Type == Behavior.BehaviorType.State)
                {
                    headers.Add(behavior.Name + " Duration");
                }
            }

            // Frequency
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                headers.Add(behavior.Name + " Frequency");
            }

            // Latency
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                if (behavior.Type == Behavior.BehaviorType.State)
                {
                    headers.Add(behavior.Name + " Latency");
                }
            }

            if (exportSettings.UseTimeBins)
            {
                if (trial.Runs.Count > 0)
                {
                    ExportTimeBin exportTimeBin = new ExportTimeBin(trial.Runs[0], exportSettings, stateRunEventsInRange);
                    headers.AddRange(exportTimeBin.headers());
                }
            }
            return(headers);
        }
Ejemplo n.º 3
0
        public virtual List<string> Headers()
        {
            Trial trial = run.Trial;
            List<string> headers = new List<string>();
            BehavioralTest behavioralTest = trial.Session.BehavioralTest;

            headers.Add("Project");
            headers.Add("SubjectID");
            headers.Add("SubjectGroup");
            headers.Add("Strain");
            headers.Add("Sex");
            headers.Add("TrialName");
            headers.Add("TrialDuration");
            headers.Add("DateRun");
            headers.Add("TimeRun");
            headers.Add("Number of Events");

            // Duration
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                if (behavior.Type == Behavior.BehaviorType.State)
                {
                    headers.Add(behavior.Name + " Duration");
                }
            }

            // Frequency
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                headers.Add(behavior.Name + " Frequency");
            }

            // Latency
            foreach (Behavior behavior in behavioralTest.GetBehaviors())
            {
                if (behavior.Type == Behavior.BehaviorType.State)
                {
                    headers.Add(behavior.Name + " Latency");
                }
            }

            if (exportSettings.UseTimeBins)
            {
                if (trial.Runs.Count > 0)
                {
                    ExportTimeBin exportTimeBin = new ExportTimeBin(trial.Runs[0], exportSettings, stateRunEventsInRange);
                    headers.AddRange(exportTimeBin.headers());
                }
            }
            return headers;
        }
Ejemplo n.º 4
0
        public virtual List<string> RunData()
        {
            List<string> data = new List<string>();
            string subjectGroup = (run.Subject.SubjectGroup != null) ? run.Subject.SubjectGroup.ToString() : "";

            initializeCounters();
            initializeRunEventsInRange();
            calculateCounters(runEventsInRange);

            data.Add(run.Trial.Session.BehavioralTest.Project.ToString());
            data.Add(run.Subject.ToString());

            data.Add(subjectGroup);
            data.Add(run.Subject.Strain);
            data.Add(run.Subject.Sex);
            data.Add(run.Trial.ToString());
            data.Add(run.Trial.Duration.ToString());
            data.Add(run.TmRun.ToString("dd/MM/yyyy"));
            data.Add(run.TmRun.ToString("HH:mm:ss"));

            data.Add(runEventsInRange.Count.ToString());

            foreach (var behaviorTotal in stateBehaviorTotalDuration)
            {
                data.Add(behaviorTotal.Value.ToString("F3"));
            }

            foreach (var behaviorCount in behaviorFrequency)
            {
                data.Add(behaviorCount.Value.ToString());
            }

            foreach (var behaviorTime in stateBehaviorLatency)
            {
                double? latency = stateBehaviorLatency[behaviorTime.Key];
                if (latency == null)
                {
                    latency = exportSettings.ExportEnd;
                }
                data.Add(latency.Value.ToString("F3"));
            }

            if (exportSettings.UseTimeBins)
            {
                ExportTimeBin exportTimeBin = new ExportTimeBin(run, exportSettings, stateRunEventsInRange);
                List<TimeBin> timeBins = exportTimeBin.calculateTimeBins();
                data.AddRange(exportTimeBin.data());
            }

            return data;
        }
Ejemplo n.º 5
0
        public void testTimeBins()
        {
            Trial trial = Fixtures.Fixtures.fstLightTrial;
            Run run = Fixtures.Fixtures.createLightFstRun(trial);

            ExportTimeBin exportTimeBin = new ExportTimeBin(run, new ExportSettings(trial, 5), run.SortedStateRunEvents);
            List<TimeBin> timeBins = exportTimeBin.calculateTimeBins();

            // initialization
            Assert.AreEqual(3, timeBins.Count, "TimeBins Count");
            Assert.AreEqual(5000, timeBins[1].start);
            Assert.AreEqual(10000, timeBins[1].end);

            // calculation
            Assert.AreEqual(3800, timeBins[0].stateBehaviorTotalDuration[Fixtures.Fixtures.FstSwimming]);

            // export runData
            List<string> headers = exportTimeBin.headers();
            Assert.AreEqual(12, headers.Count);
            Assert.AreEqual("Climbing 0-5", headers[0]);
            Assert.AreEqual("Climbing 5-10", headers[1]);
            Assert.AreEqual("Swimming 0-5", headers[3]);
            Assert.AreEqual("Diving 10-15", headers[11]);

            // export data
            List<string> data = exportTimeBin.data();
            Assert.AreEqual(12, data.Count);
            Assert.AreEqual((1.2).ToString("F3"), data[0]);
            Assert.AreEqual((0.0).ToString("F3"), data[1]);
            Assert.AreEqual((3.8).ToString("F3"), data[3]);
            Assert.AreEqual((0.0).ToString("F3"), data[11]);

            //Exporter exporter = new Exporter(new ExportSettings(5));
            //exporter.export(run);
            run.RunEvents.Clear();
        }