示例#1
0
        public void AnnotateActogram(Actigraph.ActogramStats _stats)
        {
            int y_sun = 30;

            AddStrip_date("Rest", Color.Aquamarine, _stats.rest_starttime_chart, _stats.rest_endtime_chart);
            AddStrip_date("Sleep", Color.LightSkyBlue, _stats.sleep_starttime_chart, _stats.sleep_endtime_chart);

            AddSunsetSunrise(_stats.sunset, _stats.sunrise, y_sun);

            DateTime xpos1     = Convert.ToDateTime("1900-01-01 21:30:00");
            DateTime xpos2     = Convert.ToDateTime("1900-01-02 02:20:00");
            int      ypos1     = 95;
            int      yinterval = -12;

            AddTextAnnotation(String.Format("Hrs Sleep: {0}", _stats.hrssleep), xpos1, ypos1 + (0 * yinterval), 9, Color.Black);
            AddTextAnnotation(String.Format("Hrs In Bed: {0}", _stats.hrsinbed), xpos1, ypos1 + (1 * yinterval), 9, Color.Black);

            AddTextAnnotation(String.Format("Onset Latency: {0} mins", _stats.onsetlatency), xpos2, ypos1 + (0 * yinterval), 9, Color.Black);
            AddTextAnnotation(String.Format("WASO: {0} mins", _stats.waso), xpos2, ypos1 + (1 * yinterval), 9, Color.Black);
            AddTextAnnotation(String.Format("Effic: {0}%", _stats.efficiency), xpos2, ypos1 + (2 * yinterval), 9, Color.Black);

            AddTextAnnotation(String.Format("# Awakenings: {0}", _stats.numwakebouts), xpos2, ypos1 + (3 * yinterval), 9, Color.Black);
        }
示例#2
0
 public DxActogram(DxLineplotSettings settings, DataTable dt, Actigraph.ActogramStats mystats) : base((DxLineplotSettings)settings, dt)
 {
     _settings = (DxActogramSettings)settings;
     _stats    = mystats;
     _markers  = new DxMarkerKinds();
 }
示例#3
0
    protected void ActigraphPlots()
    {
        panel.Controls.Clear();

        SQL_utils sql = new SQL_utils("data");

        int iswake_negvalue    = -15;
        int cap_activity       = 2000;
        int cap_whitelight     = 300;
        int scaleto_activity   = 100;
        int scaleto_whitelight = 100;


        lblSetupInfo.Text = String.Format("Activity capped at {0}, White light capped at {1}<br/>Activity scaled 0:{2}, White light scaled 0:{3}"
                                          , cap_activity, cap_whitelight, scaleto_activity, scaleto_whitelight);

        List <SqlParameter> ps = new List <SqlParameter>();

        ps.Add(sql.CreateParam("id", cboSubject.Value.ToString(), "text"));
        ps.Add(sql.CreateParam("smID_epoch", cboStudymeas.Value.ToString(), "int"));
        ps.Add(sql.CreateParam("cap_activity", cap_activity.ToString(), "int"));
        ps.Add(sql.CreateParam("cap_whitelight", cap_whitelight.ToString(), "int"));
        ps.Add(sql.CreateParam("iswake_neg_value", iswake_negvalue.ToString(), "int"));



        DataSet ds = sql.DataSet_from_ProcName("spActigraphData", ps);

        ds.Tables[0].TableName = "epoch";
        ds.Tables[1].TableName = "stats";



        DxActogramSettings s = new DxActogramSettings();

        s.W             = 1200;
        s.H             = 300;
        s.seriesby      = "id";
        s.xaxisvar      = "time_of_day";
        s.xaxis_is_date = true;

        s.AddVarsFromList(new List <string>()
        {
            "activity", "is_wake", "white_light"
        });
        //Changed Feb 2019
        //s.numvars = new List<string>() { "activity", "is_wake", "white_light"};
        s.colorvar         = "variable";
        s.panelvar         = "report_date";
        s.colors           = Actigraph.colors;
        s.legend_pos_h     = "RightOutside";
        s.legend_pos_v     = "Top";
        s.maxy             = scaleto_whitelight;
        s.miny             = iswake_negvalue;
        s.maxCol           = 1;
        s.geom             = LineplotGeom.Bar;
        s.altgeom          = LineplotGeom.Star;
        s.vars_for_altgeom = new List <string> {
            "white_light"
        };
        s.markersize = 8;



        DxHistogramSettings hist = new DxHistogramSettings((DxChartSettings)s);

        hist.AddVarsFromList(new List <string>()
        {
            "activity", "white_light"
        });
        //Changed Feb 2019
        //hist.numvars = new List<string>() { "activity", "white_light" };
        hist.W      = 400; hist.H = 200;
        hist.colors = Actigraph.colors;

        DxChartOrder order = new DxChartOrder();

        order.list_settings.Add(s);
        order.list_settings.Add(hist);


        DataTable stats1 = utilStats.DataTable_DescStats(ds.Tables["epoch"], true);

        ds.Tables["epoch"].RescaleColumn("activity", 0, scaleto_activity);
        ds.Tables["epoch"].RescaleColumn("white_light", 0, scaleto_whitelight);

        DataTable stats2 = utilStats.DataTable_DescStats(ds.Tables["epoch"], true);


        DxChartFactory factory = new DxChartFactory(ds.Tables["epoch"], new List <DxChartOrder> {
            order
        });


        int counter = 0;

        foreach (DxChartOrder myorder in factory.orders)
        {
            foreach (DxChartBatch batch in myorder.batches)
            {
                if (batch.batchsettings.outputtype == DxOutputtype.Actogram)
                {
                    foreach (DxActogram ch in batch.charts)
                    {
                        XYDiagram xy = ch.xydiagram;
                        xy.AxisX.DateTimeScaleOptions.MeasureUnit   = DateTimeMeasureUnit.Hour;
                        xy.AxisX.DateTimeScaleOptions.GridAlignment = DateTimeGridAlignment.Hour;
                        xy.AxisX.Label.TextPattern = "{A:t}";

                        DataTable dt = ds.Tables[1];


                        string date_txt = String.Format("{0}, {1}", ch.date_txt, Convert.ToDateTime(ch.date_txt).DayOfWeek.ToString());
                        ch.SetMainTitle(date_txt);                          //Place date in the title


                        foreach (DataRow row in dt.Rows)
                        {
                            DateTime rpt_date = Convert.ToDateTime(row["report_date"].ToString());
                            if (rpt_date == Convert.ToDateTime(date_txt))
                            {
                                Actigraph.ActogramStats stats = new Actigraph.ActogramStats(row);
                                ch.AnnotateActogram(stats);
                                counter++;
                            }
                        }
                    }

                    batch.SetYAxisRange();
                    batch.SetXAxisRange_1day();
                }
                else
                {
                    foreach (DxChart ch in batch.charts)
                    {
                        XYDiagram xy = ch.xydiagram;
                        xy.AxisX.Label.TextPattern = "{A:n}";
                    }
                }

                System.Web.UI.WebControls.Table t = LayoutOutput.LayoutBatch(batch);
                panel.Controls.Add(t);
            }
        }


        gridDaily.DataSource = ds.Tables[1];
        gridDaily.DataBind();
        gridDaily.Visible = true;


        //DxChartOrder order2 = LinePlot_BedTimes();
        //DxChartFactory fatory2 = new DxChartFactory(ds.Tables["stats"], order2);
    }