chongxi / playground

Low-latency interactive multi-stream Behavior Platform: a control console that integrate Jovian (Virtual Reality Platform) and FPGA&Spiketag (Real-time Ephys) and other sensor streams
Other
3 stars 0 forks source link

Real-time display posterior with trajectory #22

Closed chongxi closed 4 years ago

chongxi commented 4 years ago

Set the posterior as assigning a NumPy matrix In maze_view:

    @property
    def posterior(self):
        return self._posterior

    @posterior.setter
    def posterior(self, posterior):
        self._posterior = posterior
        self.image.set_data(posterior)
        if self.mirror:
            self.image.transform.translate = np.array([self.x_range[0], self.y_range[0], 100])
        else:
            self.image.transform.translate = np.array([self.x_range[0], self.y_range[0], -100])
        self.image.transform.scale = ((self.x_range[1] - self.x_range[0])/posterior.shape[0], 
                                      (self.y_range[1] - self.y_range[0])/posterior.shape[1])
        self.image.update()

Leads to rendering:

image

The key to show trajectory simultaneously is to set the transform.traslate such that the image and the trajectory are not in the same z-plane. The sign of the z traslation is dependent on whether we use mirror projection (.mirror is True or False) or not.