Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path1"></param>
        /// <param name="path2"></param>
        /// <returns></returns>
        public static double PathDistance(List <PointF> path1, List <PointF> path2)
        {
            double distance = 0;

            for (int i = 0; i < Math.Min(path1.Count, path2.Count); i++)
            {
                distance += GeotrigEx.Distance(path1[i], path2[i]);
            }
            return(distance / path1.Count);
        }
Пример #2
0
 /// <summary>
 /// Gets the actual trial amplitude for this trial as the effective amplitude (Ae).
 /// </summary>
 public override double GetAe(bool bivariate)
 {
     if (bivariate) // two-dimensional distance
     {
         return(GeotrigEx.Distance(_start, _end));
     }
     else // only consider x-coordinate
     {
         PointF nstart = this.NormalizedStart;  // relative to a target at (0,0)
         PointF nend   = this.NormalizedEnd;
         return(Math.Abs(nend.X - nstart.X));
     }
 }
Пример #3
0
        /// <summary>
        /// Shows all the information for a trial-level node highlighted in the treeview.
        /// </summary>
        /// <param name="node">The highlighted node in the left treeview, assumed to represent an individual trial.</param>
        private void ShowTrialInfo(TreeNode node)
        {
            //
            // Get the trial and its condition from the 'Tag' field from the selected node.
            //
            _tdata = (TrialData)node.Tag;
            _cdata = (ConditionData)node.Parent.Tag;

            //
            // Get the resampled and smoothed velocity, acceleration, and jerk profiles.
            //
            MovementData.Profiles resampled = _tdata.Movement.CreateResampledProfiles();
            MovementData.Profiles smoothed  = _tdata.Movement.CreateSmoothedProfiles();

            //
            // Clear any series in the graphs.
            //
            grfDistance.ClearSeries();
            grfVelocity.ClearSeries();
            grfAcceleration.ClearSeries();
            grfJerk.ClearSeries();

            //
            // Graph the resampled distance to the target over time.
            //
            List <PointF> rdist = new List <PointF>(resampled.Position.Count);

            for (int i = 0; i < resampled.Position.Count; i++)
            {
                long   t  = resampled.Position[i].Time - resampled.Position[0].Time;
                double dx = GeotrigEx.Distance(resampled.Position[i], _tdata.TargetCenterFromStart);
                rdist.Add(new PointF(t, (float)dx));
            }
            Graph.Series rd = new Graph.Series("resampled distance", Color.Salmon, Color.Salmon, false, true);
            rd.AddPoints(rdist);

            //
            // Graph the smoothed distance from the target over time.
            //
            List <PointF> sdist = new List <PointF>(smoothed.Position.Count);

            for (int i = 0; i < smoothed.Position.Count; i++)
            {
                long   t  = smoothed.Position[i].Time - smoothed.Position[0].Time;
                double dx = GeotrigEx.Distance(smoothed.Position[i], _tdata.TargetCenterFromStart);
                sdist.Add(new PointF(t, (float)dx));
            }
            Graph.Series sd = new Graph.Series("smoothed distance", Color.MediumBlue, Color.MediumBlue, false, true);
            sd.AddPoints(sdist);

            grfDistance.AddSeries(rd);
            grfDistance.AddSeries(sd);

            //
            // Graph the velocity.
            //
            Graph.Series rv = new Graph.Series("resampled velocity", Color.Salmon, Color.Salmon, false, true);
            rv.AddPoints(resampled.Velocity);

            Graph.Series sv = new Graph.Series("smoothed velocity", Color.MediumBlue, Color.MediumBlue, false, true);
            sv.AddPoints(smoothed.Velocity);

            grfVelocity.AddSeries(rv);
            grfVelocity.AddSeries(sv);

            //
            // Graph the acceleration.
            //
            Graph.Series aaxis = new Graph.Series("zero line", Color.Gray, Color.Gray, false, true);
            aaxis.AddPoint(0f, 0f);
            aaxis.AddPoint(resampled.Acceleration[resampled.Acceleration.Count - 1].X, 0f);

            Graph.Series ra = new Graph.Series("resampled acceleration", Color.Salmon, Color.Salmon, false, true);
            ra.AddPoints(resampled.Acceleration);

            Graph.Series sa = new Graph.Series("smoothed acceleration", Color.MediumBlue, Color.MediumBlue, false, true);
            sa.AddPoints(smoothed.Acceleration);

            grfAcceleration.AddSeries(aaxis);
            grfAcceleration.AddSeries(ra);
            grfAcceleration.AddSeries(sa);

            //
            // Graph the jerk.
            //
            Graph.Series jaxis = new Graph.Series("zero line", Color.Gray, Color.Gray, false, true);
            jaxis.AddPoint(0f, 0f);
            jaxis.AddPoint(resampled.Jerk[resampled.Jerk.Count - 1].X, 0f);

            Graph.Series rj = new Graph.Series("resampled jerk", Color.Salmon, Color.Salmon, false, true);
            rj.AddPoints(resampled.Jerk);

            Graph.Series sj = new Graph.Series("smoothed jerk", Color.MediumBlue, Color.MediumBlue, false, true);
            sj.AddPoints(smoothed.Jerk);

            grfJerk.AddSeries(jaxis);
            grfJerk.AddSeries(rj);
            grfJerk.AddSeries(sj);

            //
            // Now show the trial-level XML in the web control.
            //
            XmlTextWriter writer = null;
            string        tmpXml = String.Format("{0}{1}.xml", Path.GetTempPath(), Path.GetRandomFileName());

            try
            {
                writer            = new XmlTextWriter(tmpXml, Encoding.UTF8);
                writer.Formatting = Formatting.Indented;
                _tdata.WriteXmlHeader(writer);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                tmpXml = String.Empty;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
                if (tmpXml != String.Empty)
                {
                    webXml.Navigate(tmpXml);
                    rtxXml.LoadFile(tmpXml, RichTextBoxStreamType.PlainText);
                    _tmpXml.Add(tmpXml);
                }
            }

            //
            // Invalidate everything that needs to be repainted based on the node just selected.
            //
            pnlTrial.Invalidate();
            grfDistance.Invalidate();
            grfVelocity.Invalidate();
            grfAcceleration.Invalidate();
            grfJerk.Invalidate();
        }
Пример #4
0
 /// <summary>
 /// Gets the distance from the center of the target. For circle targets, the bivariate outcome is
 /// the Euclidean distance to the target center. The univariate outcome is the x-distance to the
 /// x-coordinate of the target center.
 /// </summary>
 /// <remarks>This is NOT used to compute We as 4.133 * SDx. Instead, we must compute We
 /// more carefully using the standard deviation of normalized distances from the normalized selection
 /// mean.</remarks>
 public override double GetDx(bool bivariate)
 {
     return(bivariate ? GeotrigEx.Distance(_thisCircle.Center, _end) : this.NormalizedEnd.X); // nend is relative to (0,0)
 }