Exemple #1
0
    def set_data(self, trace=None, freq=None, channel_height=None, channel_names=None, ignored_channels=None, channel_colors=None):

        # default settings
        self.max_size = 1000
        self.duration_initial = 10.
        self.default_channel_height = 0.25
        self.channel_height_limits = (0.01, 20.)
        self.nticks = 10
        
        # these variables will be overwritten after initialization (used to check if init is complete)
        self.slice_ref = (-1, -1) # slice paging
        self.paintinitialized = False # to stop first slice from being loaded until correctly-shaped data drawn
        self.real_data = True # hides grid and painting if we've made up false data of zeros
        self.size = 1
        
        if trace is None:
            # make up some data to keep the GPU happy, warm, and feeling loved
            trace = np.zeros((self.duration_initial * 2, 32))
            freq = 1
            
            # don't worry, we won't tell the GPU that it's not actually rendering any useful data, but we need to keep track
            self.real_data = False
            
        if channel_colors is None:
            channel_colors = pd.Series(generate_colors(trace.shape[1]))
            
        # load initial variables
        self.trace = trace
        self.channel_colors = channel_colors
        self.ignored_channels = ignored_channels
        self.freq = freq
        self.totalduration = (self.trace.shape[0] - 1) / self.freq
        self.totalsamples, self.nchannels = self.trace.shape
        self.channels = np.arange(self.nchannels)
        
        if channel_height is None:
            channel_height = self.default_channel_height
        else:
            self.default_channel_height = channel_height
        self.channel_height = channel_height
        
        if channel_names is None:
            channel_names = pd.Series(['ch{0:d}'.format(i) for i in xrange(self.nchannels)])
        self.channel_names = channel_names

        x = np.tile(np.linspace(0., self.totalduration, 2), (self.nchannels, 1))
        y = np.zeros_like(x)+ np.linspace(-1, 1, self.nchannels).reshape((-1, 1))
        
        self.position, self.shape = process_coordinates(x=x, y=y)
        
        # activate the grid
        if self.real_data == True:
            self.interaction_manager.get_processor('viewport').update_viewbox()
            self.interaction_manager.activate_grid()
        
        # register the updater threads
        self.slice_retriever = inthread(SliceRetriever)(impatient=True)
        self.slice_retriever.sliceLoaded.connect(self.slice_loaded)
Exemple #2
0
    def initialize(self, x=None, y=None, color=None, point_size=1.0,
            position=None, nprimitives=None, index=None,
            color_array_index=None, channel_height=CHANNEL_HEIGHT,
            options=None, autocolor=None):
            
        position, shape = process_coordinates(x=x, y=y)
        
        # register the size of the data
        self.size = np.prod(shape)
        
        # there is one plot per row
        if not nprimitives:
            nprimitives = shape[0]
            nsamples = shape[1]
        else:
            nsamples = self.size // nprimitives
        
        # register the bounds
        if nsamples <= 1:
            self.bounds = [0, self.size]
        else:
            self.bounds = np.arange(0, self.size + 1, nsamples)
        
        # automatic color with color map
        if autocolor is not None:
            if nprimitives <= 1:
                color = get_next_color(autocolor)
            else:
                color = np.array([get_next_color(i + autocolor) for i in xrange(nprimitives)])
            
        # set position attribute
        self.add_attribute("position0", ndim=2, data=position, autonormalizable=True)
        
        index = np.array(index)
        self.add_index("index", data=index)
    
        if color_array_index is None:
            color_array_index = np.repeat(np.arange(nprimitives), nsamples)
        color_array_index = np.array(color_array_index)
            
        ncolors = color.shape[0]
        ncomponents = color.shape[1]
        color = color.reshape((1, ncolors, ncomponents))
        
        dx = 1. / ncolors
        offset = dx / 2.
        
        self.add_texture('colormap', ncomponents=ncomponents, ndim=1, data=color)
        self.add_attribute('index', ndim=1, vartype='int', data=color_array_index)
        self.add_varying('vindex', vartype='int', ndim=1)
        self.add_uniform('nchannels', vartype='float', ndim=1, data=float(nprimitives))
        self.add_uniform('channel_height', vartype='float', ndim=1, data=channel_height)
        
        self.add_vertex_main("""
        vec2 position = position0;
        position.y = channel_height * position.y + .9 * (2 * index - (nchannels - 1)) / (nchannels - 1);
        vindex = index;
        """)
        
        self.add_fragment_main("""
        float coord = %.5f + vindex * %.5f;
        vec4 color = texture1D(colormap, coord);
        out_color = color;
        """ % (offset, dx))

        # add point size uniform (when it's not specified, there might be some
        # bugs where its value is obtained from other datasets...)
        self.add_uniform("point_size", data=point_size)
        self.add_vertex_main("""gl_PointSize = point_size;""")
Exemple #3
0
    def set_data(self,
                 trace=None,
                 freq=None,
                 channel_height=None,
                 channel_names=None,
                 ignored_channels=None,
                 channel_colors=None):

        # default settings
        self.max_size = 1000
        self.duration_initial = 10.
        self.default_channel_height = 0.25
        self.channel_height_limits = (0.01, 20.)
        self.nticks = 10

        # these variables will be overwritten after initialization (used to check if init is complete)
        self.slice_ref = (-1, -1)  # slice paging
        self.paintinitialized = False  # to stop first slice from being loaded until correctly-shaped data drawn
        self.real_data = True  # hides grid and painting if we've made up false data of zeros
        self.size = 1

        if trace is None:
            # make up some data to keep the GPU happy, warm, and feeling loved
            trace = np.zeros((self.duration_initial * 2, 32))
            freq = 1

            # don't worry, we won't tell the GPU that it's not actually rendering any useful data, but we need to keep track
            self.real_data = False

        if channel_colors is None:
            channel_colors = pd.Series(generate_colors(trace.shape[1]))

        # load initial variables
        self.trace = trace
        self.channel_colors = channel_colors
        self.ignored_channels = ignored_channels
        self.freq = freq
        self.totalduration = (self.trace.shape[0] - 1) / self.freq
        self.totalsamples, self.nchannels = self.trace.shape
        self.channels = np.arange(self.nchannels)

        if channel_height is None:
            channel_height = self.default_channel_height
        else:
            self.default_channel_height = channel_height
        self.channel_height = channel_height

        if channel_names is None:
            channel_names = pd.Series(
                ['ch{0:d}'.format(i) for i in xrange(self.nchannels)])
        self.channel_names = channel_names

        x = np.tile(np.linspace(0., self.totalduration, 2),
                    (self.nchannels, 1))
        y = np.zeros_like(x) + np.linspace(-1, 1, self.nchannels).reshape(
            (-1, 1))

        self.position, self.shape = process_coordinates(x=x, y=y)

        # activate the grid
        if self.real_data == True:
            self.interaction_manager.get_processor('viewport').update_viewbox()
            self.interaction_manager.activate_grid()

        # register the updater threads
        self.slice_retriever = inthread(SliceRetriever)(impatient=True)
        self.slice_retriever.sliceLoaded.connect(self.slice_loaded)
Exemple #4
0
    def initialize(self, x=None, y=None, color=None, point_size=1.0,
            position=None, nprimitives=None, index=None,
            color_array_index=None, channel_height=CHANNEL_HEIGHT,
            options=None, autocolor=None):
            
        position, shape = process_coordinates(x=x, y=y)
        
        # register the size of the data
        self.size = np.prod(shape)
        
        # there is one plot per row
        if not nprimitives:
            nprimitives = shape[0]
            nsamples = shape[1]
        else:
            nsamples = self.size // nprimitives
        
        # register the bounds
        if nsamples <= 1:
            self.bounds = [0, self.size]
        else:
            self.bounds = np.arange(0, self.size + 1, nsamples)
        
        # automatic color with color map
        if autocolor is not None:
            if nprimitives <= 1:
                color = get_next_color(autocolor)
            else:
                color = np.array([get_next_color(i + autocolor) for i in xrange(nprimitives)])
            
        # set position attribute
        self.add_attribute("position0", ndim=2, data=position, autonormalizable=True)
        
        index = np.array(index)
        self.add_index("index", data=index)
    
        if color_array_index is None:
            color_array_index = np.repeat(np.arange(nprimitives), nsamples)
        color_array_index = np.array(color_array_index)
            
        ncolors = color.shape[0]
        ncomponents = color.shape[1]
        color = color.reshape((1, ncolors, ncomponents))
        
        dx = 1. / ncolors
        offset = dx / 2.
        
        self.add_texture('colormap', ncomponents=ncomponents, ndim=1, data=color)
        self.add_attribute('index', ndim=1, vartype='int', data=color_array_index)
        self.add_varying('vindex', vartype='int', ndim=1)
        self.add_uniform('nchannels', vartype='float', ndim=1, data=float(nprimitives))
        self.add_uniform('channel_height', vartype='float', ndim=1, data=channel_height)
        
        self.add_vertex_main("""
        vec2 position = position0;
        position.y = channel_height * position.y + .9 * (2 * index - (nchannels - 1)) / (nchannels - 1);
        vindex = index;
        """)
        
        self.add_fragment_main("""
        float coord = %.5f + vindex * %.5f;
        vec4 color = texture1D(colormap, coord);
        out_color = color;
        """ % (offset, dx))

        # add point size uniform (when it's not specified, there might be some
        # bugs where its value is obtained from other datasets...)
        self.add_uniform("point_size", data=point_size)
        self.add_vertex_main("""gl_PointSize = point_size;""")