|
20 | 20 | "outputs": [],
|
21 | 21 | "source": [
|
22 | 22 | "import numpy as np\n",
|
23 |
| - "import fastplotlib as fpl\n", |
24 |
| - "\n", |
25 |
| - "from tqdm import tqdm" |
| 23 | + "import fastplotlib as fpl" |
26 | 24 | ]
|
27 | 25 | },
|
28 | 26 | {
|
29 | 27 | "cell_type": "markdown",
|
30 | 28 | "id": "908f93f8-68c3-4a36-8f40-e0aab560955d",
|
31 | 29 | "metadata": {},
|
32 | 30 | "source": [
|
33 |
| - "## Generate some random neural-like data" |
| 31 | + "## Generate some sine and cosine data" |
34 | 32 | ]
|
35 | 33 | },
|
36 | 34 | {
|
|
42 | 40 | },
|
43 | 41 | "outputs": [],
|
44 | 42 | "source": [
|
45 |
| - "def generate_traces(n_components, n_frames):\n", |
46 |
| - " n_frames = n_frames + 50\n", |
47 |
| - " n_components = n_components\n", |
48 |
| - " \n", |
49 |
| - " out = np.zeros((n_components, n_frames), dtype=np.float16)\n", |
50 |
| - " \n", |
51 |
| - " xs = np.arange(0, 50, 1)\n", |
52 |
| - " # exponential decay\n", |
53 |
| - " _lambda = 0.1\n", |
54 |
| - " ys = np.e**-(_lambda * xs)\n", |
55 |
| - " \n", |
56 |
| - " for component_num in tqdm(range(n_components)):\n", |
57 |
| - " time_step = 0\n", |
58 |
| - " while time_step < n_frames - 50:\n", |
59 |
| - " firing_prop = np.random.randint(0, 20)\n", |
60 |
| - " if np.random.poisson() > firing_prop:\n", |
61 |
| - " out[component_num, time_step:min(time_step + 50, n_frames - 1)] = ys.astype(np.float16)\n", |
62 |
| - " time_step += 100\n", |
63 |
| - " else:\n", |
64 |
| - " time_step += 2\n", |
65 |
| - " \n", |
66 |
| - " return out[:, :n_frames - 50]" |
67 |
| - ] |
68 |
| - }, |
69 |
| - { |
70 |
| - "cell_type": "markdown", |
71 |
| - "id": "fc1070d9-f9e9-405f-939c-a130cc5c456a", |
72 |
| - "metadata": {}, |
73 |
| - "source": [ |
74 |
| - "Generate an array that is `10,000 x 30,000`, this may take a few minutes" |
| 43 | + "xs = np.linspace(0, 50, 10_000)\n", |
| 44 | + "\n", |
| 45 | + "sine_data = np.sin(xs)\n", |
| 46 | + "\n", |
| 47 | + "cosine_data = np.cos(xs)\n", |
| 48 | + "\n", |
| 49 | + "data = np.vstack([(sine_data, cosine_data) for i in range(5)])" |
75 | 50 | ]
|
76 | 51 | },
|
77 | 52 | {
|
78 | 53 | "cell_type": "code",
|
79 | 54 | "execution_count": null,
|
80 |
| - "id": "8a1b83f6-c0d8-4237-abd6-b483e7d978ee", |
| 55 | + "id": "02b072eb-2909-40c8-8739-950f07efbbc2", |
81 | 56 | "metadata": {
|
82 | 57 | "tags": []
|
83 | 58 | },
|
84 | 59 | "outputs": [],
|
85 | 60 | "source": [
|
86 |
| - "temporal = generate_traces(10_000, 30_000)" |
| 61 | + "data.shape" |
87 | 62 | ]
|
88 | 63 | },
|
89 | 64 | {
|
90 | 65 | "cell_type": "code",
|
91 | 66 | "execution_count": null,
|
92 |
| - "id": "f89bd740-7397-43e7-9e66-d6cfb14de884", |
| 67 | + "id": "84deb31b-5464-4cce-a938-694371011021", |
93 | 68 | "metadata": {
|
94 | 69 | "tags": []
|
95 | 70 | },
|
96 | 71 | "outputs": [],
|
97 | 72 | "source": [
|
98 | 73 | "plot = fpl.Plot()\n",
|
99 | 74 | "\n",
|
100 |
| - "plot.add_heatmap(temporal, cmap=\"viridis\")\n", |
| 75 | + "plot.add_heatmap(data, cmap=\"viridis\")\n", |
101 | 76 | "\n",
|
102 | 77 | "plot.show(maintain_aspect=False)"
|
103 | 78 | ]
|
104 | 79 | },
|
105 | 80 | {
|
106 | 81 | "cell_type": "code",
|
107 | 82 | "execution_count": null,
|
108 |
| - "id": "84deb31b-5464-4cce-a938-694371011021", |
| 83 | + "id": "df3f8994-0f5b-4578-a36d-4cd9bf0733c0", |
109 | 84 | "metadata": {},
|
110 | 85 | "outputs": [],
|
111 | 86 | "source": []
|
|
0 commit comments