AdaptiveMotorControlLab / CEBRA

Learnable latent embeddings for joint behavioral and neural analysis - Official implementation of CEBRA
https://cebra.ai
Other
875 stars 66 forks source link

Plotly integration #84

Closed nastya236 closed 10 months ago

nastya236 commented 10 months ago

Also see https://github.com/AdaptiveMotorControlLab/CEBRA/pull/82 which was merged into main.

requires matplotlib ~3.6.2 ie, less than 3.7.1

Example:

import cebra
import numpy as np
from plotly.subplots import make_subplots
import cebra.integrations.plotly

data = cebra.datasets.init("rat-hippocampus-single-achilles")

X = np.random.uniform(0, 1, (100, 50))
y = np.random.uniform(0, 10, (100, 5))
cebra_model = cebra.CEBRA(max_iterations=3000, batch_size = 512, verbose = True)
cebra_model.fit(data.neural)

embedding = cebra_model.transform(data.neural)
time = np.arange(len(data))

fig = cebra.integrations.plotly.plot_embedding_interactive(embedding, embedding_labels=data.index[:,0])
fig.show()
Screenshot 2023-10-03 at 09 42 01
stes commented 10 months ago

merging this over to the other PR, thanks @nastya236 !