Exemplo n.º 1
0
class SimilarityMatrixView(KlustaView):

    # Raise the list of highlighted spike absolute indices.
    clustersSelected = QtCore.pyqtSignal(np.ndarray)

    def initialize(self):
        self.set_bindings(SimilarityMatrixBindings)
        self.set_companion_classes(
            paint_manager=SimilarityMatrixPaintManager,
            info_manager=SimilarityMatrixInfoManager,
            interaction_manager=SimilarityMatrixInteractionManager,
            data_manager=SimilarityMatrixDataManager,
        )

    def set_data(self, *args, **kwargs):
        # if kwargs.get('similarity_matrix', None) is None:
        # return
        self.data_manager.set_data(*args, **kwargs)

        # update?
        if self.initialized:
            self.paint_manager.update()
            self.updateGL()

    def clear(self):
        self.set_data()
        self.paint_manager.set_data(visible=False, visual='clusterinfo')
        self.paint_manager.set_data(visible=False, visual='square')

    def show_selection(self, clu0, clu1):
        self.interaction_manager.show_square(clu0, clu1)
        self.interaction_manager.show_cluster(clu0, clu1)
        self.updateGL()
Exemplo n.º 2
0
class SliceRetriever(QtCore.QObject):
    sliceLoaded = QtCore.pyqtSignal(object, object, long)

    def __init__(self, parent=None):
        super(SliceRetriever, self).__init__(parent)

    def load_new_slice(self, trace, slice, xlim, totalduration,
                       duration_initial):

        total_size = trace.shape[0]
        samples = trace[slice, :]

        # Convert the data into floating points.
        samples = np.array(samples, dtype=np.float32)

        # Normalize the data.
        samples *= (1. / 65535)

        # Size of the slice.
        nsamples, nchannels = samples.shape
        # Create the data array for the plot visual.
        M = np.empty((nsamples * nchannels, 2))
        samples = samples.T
        M[:, 1] = samples.ravel()
        # Generate the x coordinates.
        x = np.arange(slice.start, slice.stop,
                      slice.step) / float(total_size - 1)

        x = x * 2 * totalduration / duration_initial - 1
        M[:, 0] = np.tile(x, nchannels)

        bounds = np.arange(nchannels + 1) * nsamples
        size = bounds[-1]

        self.sliceLoaded.emit(M, bounds, size)
Exemplo n.º 3
0
def qCleanupResources():
    QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
Exemplo n.º 4
0
def qInitResources():
    QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)