Ejemplo n.º 1
0
    def run(self, results):
        par = self.getValueOfParameter("parameter")
        i = int(self.getValueOfParameter("iteration number"))
        title = self.getValueOfParameter("title")
        if(par==""):
            return False
        
        if(i >= results.__len__()):
            return False
        
        dialogform = Dialog(QApplication.activeWindow())
        fig = Figure((5.0, 4.0), dpi=100)
        ax = SubplotZero(fig, 1, 1, 1)
        fig.add_subplot(ax)

        for n in ["top", "right"]:
            ax.axis[n].set_visible(False)
            
        for n in ["bottom", "left"]:
            ax.axis[n].set_visible(True)
        
        x = results[i].getResults(par)   
        
        if(not(x.__len__())):
            return False

        ax.hist(x, 100, normed=1)
        ax.set_xlabel('Error')
        ax.set_ylabel('Probability')
        ax.grid(True)
        
        ax.set_title(title)
        dialogform.showFigure(fig)
        return True
Ejemplo n.º 2
0
    def renderGraph(self):  # pylint: disable=R0914
        assert len(self._oData.aoSeries) == 1
        oSeries = self._oData.aoSeries[0]

        # hacking
        #self.setWidth(512);
        #self.setHeight(128);
        # end

        oFigure = self._createFigure()
        from mpl_toolkits.axes_grid.axislines import SubplotZero
        # pylint: disable=E0401
        oAxis = SubplotZero(oFigure, 111)
        oFigure.add_subplot(oAxis)

        # Disable all the normal axis.
        oAxis.axis['right'].set_visible(False)
        oAxis.axis['top'].set_visible(False)
        oAxis.axis['bottom'].set_visible(False)
        oAxis.axis['left'].set_visible(False)

        # Use the zero axis instead.
        oAxis.axis['yzero'].set_axisline_style('-|>')
        oAxis.axis['yzero'].set_visible(True)
        oAxis.axis['xzero'].set_axisline_style('-|>')
        oAxis.axis['xzero'].set_visible(True)

        if oSeries.aoYValues[-1] == 100:
            sColor = 'green'
        elif oSeries.aoYValues[-1] > 75:
            sColor = 'yellow'
        else:
            sColor = 'red'
        oAxis.plot(oSeries.aoXValues,
                   oSeries.aoYValues,
                   '.-',
                   color=sColor,
                   linewidth=3)
        oAxis.fill_between(oSeries.aoXValues,
                           oSeries.aoYValues,
                           facecolor=sColor,
                           alpha=0.5)

        oAxis.set_xlim(left=-0.01)
        oAxis.set_xticklabels([])
        oAxis.set_xmargin(1)

        oAxis.set_ylim(bottom=0, top=100)
        oAxis.set_yticks([0, 50, 100])
        oAxis.set_ylabel('%')
        #oAxis.set_yticklabels([]);
        oAxis.set_yticklabels(['', '%', ''])

        return self._produceSvg(oFigure, False)
Ejemplo n.º 3
0
    def renderGraph(self):  # pylint: disable=R0914
        assert len(self._oData.aoSeries) == 1
        oSeries = self._oData.aoSeries[0]

        # hacking
        # self.setWidth(512);
        # self.setHeight(128);
        # end

        oFigure = self._createFigure()
        from mpl_toolkits.axes_grid.axislines import SubplotZero

        # pylint: disable=E0401
        oAxis = SubplotZero(oFigure, 111)
        oFigure.add_subplot(oAxis)

        # Disable all the normal axis.
        oAxis.axis["right"].set_visible(False)
        oAxis.axis["top"].set_visible(False)
        oAxis.axis["bottom"].set_visible(False)
        oAxis.axis["left"].set_visible(False)

        # Use the zero axis instead.
        oAxis.axis["yzero"].set_axisline_style("-|>")
        oAxis.axis["yzero"].set_visible(True)
        oAxis.axis["xzero"].set_axisline_style("-|>")
        oAxis.axis["xzero"].set_visible(True)

        if oSeries.aoYValues[-1] == 100:
            sColor = "green"
        elif oSeries.aoYValues[-1] > 75:
            sColor = "yellow"
        else:
            sColor = "red"
        oAxis.plot(oSeries.aoXValues, oSeries.aoYValues, ".-", color=sColor, linewidth=3)
        oAxis.fill_between(oSeries.aoXValues, oSeries.aoYValues, facecolor=sColor, alpha=0.5)

        oAxis.set_xlim(left=-0.01)
        oAxis.set_xticklabels([])
        oAxis.set_xmargin(1)

        oAxis.set_ylim(bottom=0, top=100)
        oAxis.set_yticks([0, 50, 100])
        oAxis.set_ylabel("%")
        # oAxis.set_yticklabels([]);
        oAxis.set_yticklabels(["", "%", ""])

        return self._produceSvg(oFigure, False)
    def renderGraph(self): # pylint: disable=R0914
        assert len(self._oData.aoSeries) == 1;
        oSeries = self._oData.aoSeries[0];

        # hacking
        #self.setWidth(512);
        #self.setHeight(128);
        # end

        oFigure = self._createFigure();
        from mpl_toolkits.axes_grid.axislines import SubplotZero;
        oAxis = SubplotZero(oFigure, 111);
        oFigure.add_subplot(oAxis);

        # Disable all the normal axis.
        oAxis.axis['right'].set_visible(False)
        oAxis.axis['top'].set_visible(False)
        oAxis.axis['bottom'].set_visible(False)
        oAxis.axis['left'].set_visible(False)

        # Use the zero axis instead.
        oAxis.axis['yzero'].set_axisline_style('-|>');
        oAxis.axis['yzero'].set_visible(True);
        oAxis.axis['xzero'].set_axisline_style('-|>');
        oAxis.axis['xzero'].set_visible(True);

        if oSeries.aoYValues[-1] == 100:
            sColor = 'green';
        elif oSeries.aoYValues[-1] > 75:
            sColor = 'yellow';
        else:
            sColor = 'red';
        oAxis.plot(oSeries.aoXValues, oSeries.aoYValues, '.-', color = sColor, linewidth = 3);
        oAxis.fill_between(oSeries.aoXValues, oSeries.aoYValues, facecolor = sColor, alpha = 0.5)

        oAxis.set_xlim(left = -0.01);
        oAxis.set_xticklabels([]);
        oAxis.set_xmargin(1);

        oAxis.set_ylim(bottom = 0, top = 100);
        oAxis.set_yticks([0, 50, 100]);
        oAxis.set_ylabel('%');
        #oAxis.set_yticklabels([]);
        oAxis.set_yticklabels(['', '%', '']);

        return self._produceSvg(oFigure, False);
Ejemplo n.º 5
0
    def run(self, results):
        par1 = self.getValueOfParameter("parameter 1")
        par2 = self.getValueOfParameter("parameter 2")
        i = int(self.getValueOfParameter("iteration number"))
        title = self.getValueOfParameter("title")
        
        if(par1==""):
            return False
        
        if(par2==""):
            return False
        
        if(i >= results.__len__()):
            return False
        
        
        dialogform = Dialog(QApplication.activeWindow())
        fig = Figure((5.0, 4.0), dpi=100)
        ax = SubplotZero(fig, 1, 1, 1)
        fig.add_subplot(ax)

        for n in ["top", "right"]:
            ax.axis[n].set_visible(False)
            
        for n in ["bottom", "left"]:
            ax.axis[n].set_visible(True)
        
        x = results[i].getResults(par1)
        y = results[i].getResults(par2)    
        
        if(not(x.__len__())):
            return False
        
        if(not(y.__len__())):
            return False
        
        ax.plot(x,y,'.')
        
        #plot middle
        xm = range(math.floor(min(ax.axis())),math.floor(max(ax.axis())+1),1)
        ax.plot(xm,xm)
        ax.set_xlabel(par1)
        ax.set_ylabel(par2)
        ax.set_title(title)
        dialogform.showFigure(fig)
        return True
Ejemplo n.º 6
0
    def draw_graph(self):
        min_time = 0
        max_time = 0
        for val in self.readings:
            if min_time == 0:
                min_time = val["time"]
            if val["time"] < min_time:
                min_time = val["time"]
            if max_time == 0:
                max_time = val["time"]
            if val["time"] > max_time:
                max_time = val["time"]
                
        fig = plt.figure(1)

        fig.subplots_adjust(right=0.85)
        ax = SubplotZero(fig, 1, 1, 1)
        fig.add_subplot(ax)
        plt.title("Score for Game: %s" % self.score)
        # make right and top axis invisible
        ax.axis["right"].set_visible(False)
        ax.axis["top"].set_visible(False)

        # make xzero axis (horizontal axis line through y=0) visible.
        ax.axis["xzero"].set_visible(False)

        ax.set_xlim(min_time, max_time)
        ax.set_ylim(0, 4)
        ax.set_xlabel("Time")
        ax.set_ylabel("HRV")

        t_hrv = []
        hrv = []
        for val in self.readings:
            if "hrv" in val.keys():
                t_hrv.append(val["time"])
                hrv.append(val["hrv"])
            else:
                ax.plot(val["time"], 2.0, 'r.')

        for peak in self.peaks:
            ax.plot(peak["time"], peak["hrv"], 'g.', markersize=10)
        ax.plot(t_hrv, hrv, 'b-')

        plt.savefig('pulse_graph')
Ejemplo n.º 7
0
        
        # four-sphere volume conductor
        sphere = FourSphereVolumeConductor(
            **PSET.foursphereParams
        )
        phi_p += sphere.calc_potential(p=p,
                                       rz=np.array([0, 0, PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3:][i % 2]]),)

    vlimround = plotting.draw_lineplot(ax=ax, data=plotting.decimate(phi_p, q=PSET.decimate_q)[::-1, ]*1E3, unit=r'$\mu$V', #mV -> µV unit conversion
                              dt=PSET.dt*PSET.decimate_q,
                              T=T, color='k', scalebarbasis='log10')

    ax.set_xticklabels([])
    ax.set_xlabel('')
    ax.set_yticklabels(['{}'.format(i+1) for i in range(sphere.rxyz.shape[0])])
    ax.set_ylabel('position', labelpad=10)

    ax.text(-0.1, 1.05, alphabet[6],
        horizontalalignment='center',
        verticalalignment='center',
        fontsize=16, fontweight='demibold',
        transform=ax.transAxes)




    # PANEL H. tangential component of MEG signal (as recorded by squid outside scull)
    
    # compute the radial unit vector from the center of the sphere to each
    # measurement point, then unit vectors along theta and phi
    r_hat = (sphere.rxyz.T / sphere.r).T
Ejemplo n.º 8
0
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero
if 1:
    fig = plt.figure(1)
    fig.subplots_adjust(right=0.85)
    ax = SubplotZero(fig, 1, 1, 1)
    fig.add_subplot(ax)
    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)
    ax.axis["xzero"].set_visible(True)
    ax.axis["xzero"].label.set_text("Axis Zero")
    ax.set_ylim(-2, 4)
    ax.set_xlabel("Label X")
    ax.set_ylabel("Label Y")
    offset = (20, 0)
    new_axisline = ax.get_grid_helper().new_fixed_axis
    ax.axis["right2"] = new_axisline(loc="right",
                                     offset=offset,
                                     axes=ax)
    ax.axis["right2"].label.set_text("Label Y2")
    ax.plot([-2,3,2])
    plt.draw()
    plt.show()
Ejemplo n.º 9
0
        )

    vlimround = plotting.draw_lineplot(
        ax=ax,
        data=plotting.decimate(phi_p, q=PSET.decimate_q)[::-1, ] * 1E3,
        unit=r'$\mu$V',  #mV -> µV unit conversion
        dt=PSET.dt * PSET.decimate_q,
        T=T,
        color='k',
        scalebarbasis='log10')

    ax.set_xticklabels([])
    ax.set_xlabel('')
    ax.set_yticklabels(
        ['{}'.format(i + 1) for i in range(sphere.rxyz.shape[0])])
    ax.set_ylabel('position', labelpad=10)

    ax.text(-0.1,
            1.05,
            alphabet[6],
            horizontalalignment='center',
            verticalalignment='center',
            fontsize=16,
            fontweight='demibold',
            transform=ax.transAxes)

    # PANEL H. tangential component of MEG signal (as recorded by squid outside scull)

    # compute the radial unit vector from the center of the sphere to each
    # measurement point, then unit vectors along theta and phi
    r_hat = (sphere.rxyz.T / sphere.r).T
Ejemplo n.º 10
0
    fig = plt.figure(1)
    fig.subplots_adjust(right=0.85)
    ax = SubplotZero(fig, 1, 1, 1)
    fig.add_subplot(ax)

    # make right and top axis invisible
    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)

    # make xzero axis (horizontal axis line through y=0) visible.
    ax.axis["xzero"].set_visible(True)
    ax.axis["xzero"].label.set_text("Axis Zero")

    ax.set_ylim(-2, 4)
    ax.set_xlabel("Label X")
    ax.set_ylabel("Label Y")
    # or
    #ax.axis["bottom"].label.set_text("Label X")
    #ax.axis["left"].label.set_text("Label Y")

    # make new (right-side) yaxis, but wth some offset
    offset = (20, 0)
    new_axisline = ax.get_grid_helper().new_fixed_axis

    ax.axis["right2"] = new_axisline(loc="right", offset=offset, axes=ax)
    ax.axis["right2"].label.set_text("Label Y2")

    ax.plot([-2, 3, 2])
    plt.draw()
    plt.show()
Ejemplo n.º 11
0
def main():
    f = open("game_output.txt", "r")
    l = json.load(f)
    min_time = 0
    for val in l:
        if min_time == 0:
            min_time = val["time"]
        if val["time"] < min_time:
            min_time = val["time"]
    max_time = 0
    for val in l:
        if max_time == 0:
            max_time = val["time"]
        if val["time"] > max_time:
            max_time = val["time"]

    print "%s %s" % (min_time, max_time)

    fig = plt.figure(1)
    fig.subplots_adjust(right=0.85)
    ax = SubplotZero(fig, 1, 1, 1)
    fig.add_subplot(ax)

    # make right and top axis invisible
    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)

    # make xzero axis (horizontal axis line through y=0) visible.
    ax.axis["xzero"].set_visible(False)
    #ax.axis["xzero"].label.set_text("Axis Zero")

    ax.set_xlim(min_time, max_time)
    ax.set_ylim(0, 4)
    ax.set_xlabel("Time")
    ax.set_ylabel("HRV")

    # make new (right-side) yaxis, but wth some offset
    # offset = (20, 0)
    # new_axisline = ax.get_grid_helper().new_fixed_axis

    # ax.axis["right2"] = new_axisline(loc="right",
    #                                  offset=offset,
    #                                  axes=ax)
    # ax.axis["right2"].label.set_text("Label Y2")

    #ax.plot([-2,3,2])
    t_hrv = []
    hrv = []
    for val in l:
        if "hrv" in val.keys():
            t_hrv.append(val["time"])
            hrv.append(val["hrv"])
            #ax.plot(val["time"], val["hrv"], 'b,')
        elif "key" in val.keys():
            ax.plot(val["time"], 2.0, 'r,')
    ax.plot(t_hrv, hrv, 'b-')

    hrv_dict = []
    for el in l:
        try:
            hrv_dict.append((el["time"], el["hrv"]))
        except KeyError:
            pass

    peak_dict = []

    current_peak = 0
    hrv_window = deque()
    hrv_limit = 20
    hrv_total = []
    stop_counter = 0
    hrv_itr = hrv_dict.__iter__()
    b = hrv_itr.next()

    while 1:
        a = [b[0], b[1], 0]
        hrv_window.append(a)
        hrv_total.append(a)
        if len(hrv_window) > hrv_limit:
            hrv_window.popleft()
        max_hrv = 0
        max_time = 0
        for h in hrv_window:
            if h[1] > max_hrv:
                max_time = h[0]
                max_hrv = h[1]
        for h in hrv_window:
            if h[0] == max_time:
                h[2] = h[2] + 1
                break
        try:
            c = hrv_itr.next()
            b = c
        except StopIteration:
            stop_counter = stop_counter + 1
            if stop_counter == hrv_limit:
                break
            
    pulse = 0
    for (time, hrv, score) in hrv_total:
        if score > 17:
            pulse = pulse + 1
            ax.plot(time, hrv, 'g,')

    print "Pulse: %s" % (pulse)
        
    plt.draw()
    plt.show()