DARTsort 0.3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. dartsort/__init__.py +68 -0
  2. dartsort/cli.py +105 -0
  3. dartsort/clustering/__init__.py +3 -0
  4. dartsort/clustering/cluster_util.py +392 -0
  5. dartsort/clustering/clustering.py +765 -0
  6. dartsort/clustering/clustering_features.py +202 -0
  7. dartsort/clustering/density.py +1299 -0
  8. dartsort/clustering/forward_backward.py +219 -0
  9. dartsort/clustering/gmm/mixture.py +5790 -0
  10. dartsort/clustering/gmm/stable_features.py +993 -0
  11. dartsort/clustering/kmeans.py +448 -0
  12. dartsort/clustering/merge.py +501 -0
  13. dartsort/clustering/modes.py +214 -0
  14. dartsort/clustering/refine_util.py +191 -0
  15. dartsort/clustering/relocate.py +109 -0
  16. dartsort/clustering/split.py +1285 -0
  17. dartsort/config.py +288 -0
  18. dartsort/detect/__init__.py +2 -0
  19. dartsort/detect/detect.py +449 -0
  20. dartsort/detect/detect_filters.py +37 -0
  21. dartsort/evaluate/__init__.py +1 -0
  22. dartsort/evaluate/analysis.py +594 -0
  23. dartsort/evaluate/comparison.py +534 -0
  24. dartsort/evaluate/hybrid_util.py +599 -0
  25. dartsort/evaluate/noise_recording_tools.py +184 -0
  26. dartsort/evaluate/sim_template_tools.py +842 -0
  27. dartsort/evaluate/simkit.py +840 -0
  28. dartsort/evaluate/simlib.py +270 -0
  29. dartsort/localize/__init__.py +0 -0
  30. dartsort/localize/localize_torch.py +291 -0
  31. dartsort/localize/localize_util.py +313 -0
  32. dartsort/main.py +657 -0
  33. dartsort/peel/__init__.py +6 -0
  34. dartsort/peel/grab.py +208 -0
  35. dartsort/peel/matching.py +628 -0
  36. dartsort/peel/matching_util/__init__.py +3 -0
  37. dartsort/peel/matching_util/compressed_upsampled.py +718 -0
  38. dartsort/peel/matching_util/drifty.py +791 -0
  39. dartsort/peel/matching_util/matching_base.py +616 -0
  40. dartsort/peel/matching_util/pairwise.py +359 -0
  41. dartsort/peel/matching_util/pairwise_util.py +1317 -0
  42. dartsort/peel/peel_base.py +1000 -0
  43. dartsort/peel/running_template.py +1498 -0
  44. dartsort/peel/subtract.py +1123 -0
  45. dartsort/peel/threshold.py +471 -0
  46. dartsort/peel/universal.py +191 -0
  47. dartsort/pretrained/default_temporal_kernel.npy +0 -0
  48. dartsort/pretrained/detect_np1.pt +0 -0
  49. dartsort/pretrained/detect_np2.pt +0 -0
  50. dartsort/pretrained/glasbey1024.npz +0 -0
  51. dartsort/pretrained/offset_trained_denoiser.pt +0 -0
  52. dartsort/pretrained/offset_trained_denoiser_added_temp.pt +0 -0
  53. dartsort/pretrained/offset_trained_denoiser_added_temp_boost.pt +0 -0
  54. dartsort/pretrained/original_single_chan_denoiser.pt +0 -0
  55. dartsort/pretrained/single_chan_denoiser.pt +0 -0
  56. dartsort/templates/__init__.py +11 -0
  57. dartsort/templates/get_templates.py +771 -0
  58. dartsort/templates/postprocess_util.py +555 -0
  59. dartsort/templates/realignment.py +466 -0
  60. dartsort/templates/superres_util.py +204 -0
  61. dartsort/templates/template_util.py +518 -0
  62. dartsort/templates/templates.py +528 -0
  63. dartsort/transform/__init__.py +2 -0
  64. dartsort/transform/_multichan_denoiser_kit.py +650 -0
  65. dartsort/transform/all_transformers.py +58 -0
  66. dartsort/transform/amortized_localization.py +503 -0
  67. dartsort/transform/amplitudes.py +197 -0
  68. dartsort/transform/decollider.py +635 -0
  69. dartsort/transform/enforce_decrease.py +158 -0
  70. dartsort/transform/localize.py +86 -0
  71. dartsort/transform/matching_denoiser.py +44 -0
  72. dartsort/transform/pipeline.py +391 -0
  73. dartsort/transform/single_channel_denoiser.py +153 -0
  74. dartsort/transform/single_channel_templates.py +98 -0
  75. dartsort/transform/supervised_denoiser.py +486 -0
  76. dartsort/transform/temporal_pca.py +413 -0
  77. dartsort/transform/transform_base.py +255 -0
  78. dartsort/util/__init__.py +0 -0
  79. dartsort/util/cli_util.py +179 -0
  80. dartsort/util/data_util.py +1128 -0
  81. dartsort/util/drift_util.py +1054 -0
  82. dartsort/util/internal_config.py +1074 -0
  83. dartsort/util/interpolation_util.py +1012 -0
  84. dartsort/util/job_util.py +19 -0
  85. dartsort/util/logging_util.py +91 -0
  86. dartsort/util/main_util.py +235 -0
  87. dartsort/util/more_operators.py +269 -0
  88. dartsort/util/multiprocessing_util.py +211 -0
  89. dartsort/util/nn_util.py +461 -0
  90. dartsort/util/noise_util.py +1461 -0
  91. dartsort/util/peel_util.py +223 -0
  92. dartsort/util/py_util.py +213 -0
  93. dartsort/util/registration_util.py +128 -0
  94. dartsort/util/residual_util.py +30 -0
  95. dartsort/util/sparse_util.py +81 -0
  96. dartsort/util/spikeio.py +227 -0
  97. dartsort/util/spiketorch.py +1198 -0
  98. dartsort/util/testing_util/__init__.py +0 -0
  99. dartsort/util/testing_util/matching_debug_util.py +517 -0
  100. dartsort/util/testing_util/mixture_testing_util.py +291 -0
  101. dartsort/util/torch_optimization_util.py +156 -0
  102. dartsort/util/torch_util.py +75 -0
  103. dartsort/util/universal_util.py +269 -0
  104. dartsort/util/waveform_util.py +809 -0
  105. dartsort/vis/__init__.py +19 -0
  106. dartsort/vis/analysis_plots.py +392 -0
  107. dartsort/vis/colors.py +36 -0
  108. dartsort/vis/gt.py +392 -0
  109. dartsort/vis/layout.py +149 -0
  110. dartsort/vis/metrics_util.py +23 -0
  111. dartsort/vis/mixture.py +1489 -0
  112. dartsort/vis/over_time.py +514 -0
  113. dartsort/vis/recanim.py +429 -0
  114. dartsort/vis/scatterplots.py +779 -0
  115. dartsort/vis/sorting.py +163 -0
  116. dartsort/vis/unit.py +917 -0
  117. dartsort/vis/unit_comparison.py +1017 -0
  118. dartsort/vis/versus.py +300 -0
  119. dartsort/vis/vismain.py +537 -0
  120. dartsort/vis/waveforms.py +357 -0
  121. dartsort-0.3.5.dist-info/METADATA +93 -0
  122. dartsort-0.3.5.dist-info/RECORD +125 -0
  123. dartsort-0.3.5.dist-info/WHEEL +5 -0
  124. dartsort-0.3.5.dist-info/entry_points.txt +2 -0
  125. dartsort-0.3.5.dist-info/top_level.txt +1 -0
@@ -0,0 +1,19 @@
1
+ from .analysis_plots import *
2
+ from .over_time import *
3
+ from .scatterplots import *
4
+ from .sorting import *
5
+ from .unit import *
6
+ from .vismain import *
7
+ from .waveforms import *
8
+ from .gt import *
9
+ from .versus import *
10
+ from .unit_comparison import *
11
+ from .colors import *
12
+ from .recanim import RecordingAnimation
13
+ from .mixture import (
14
+ make_mixture_component_summary,
15
+ make_mixture_summaries,
16
+ MixtureVisData,
17
+ fit_mixture_for_vis,
18
+ fit_mixture_and_visualize_all_components,
19
+ )
@@ -0,0 +1,392 @@
1
+ import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import scipy.cluster.hierarchy
4
+ from matplotlib.collections import LineCollection
5
+ from matplotlib.colors import to_hex, Colormap
6
+ from scipy.cluster.hierarchy import dendrogram, fcluster, linkage
7
+
8
+ from .colors import glasbey1024
9
+ from ..clustering.cluster_util import leafsets
10
+
11
+
12
+ def scatter_max_channel_waveforms(
13
+ axis,
14
+ template_data,
15
+ waveform_height=0.05,
16
+ waveform_width=0.95,
17
+ show_geom=True,
18
+ geom=None,
19
+ geom_scatter_kwargs={"marker": "s", "lw": 0, "s": 3},
20
+ lw=1,
21
+ colors=glasbey1024,
22
+ **plot_kwargs,
23
+ ):
24
+ rgeom = template_data.registered_geom
25
+ if rgeom is None:
26
+ rgeom = geom
27
+ dx = np.ptp(waveform_width * rgeom[:, 0])
28
+ dz = np.ptp(rgeom[:, 1])
29
+ max_abs_amp = np.abs(template_data.templates).max()
30
+ zscale = dz * waveform_height / max_abs_amp
31
+
32
+ xrel = np.linspace(-dx / 2, dx / 2, num=template_data.templates.shape[1])
33
+ locsx, locsz = template_data.template_locations().T
34
+
35
+ if show_geom:
36
+ axis.scatter(*rgeom.T, **geom_scatter_kwargs)
37
+
38
+ for j, (u, temp) in enumerate(zip(template_data.unit_ids, template_data.templates)):
39
+ ptpvec = np.ptp(temp, 0)
40
+ if ptpvec.max() == 0:
41
+ continue
42
+ mc = ptpvec.argmax()
43
+ mctrace = temp[:, mc]
44
+
45
+ xc = locsx[j]
46
+ zc = locsz[j]
47
+ c = colors[u % len(colors)]
48
+ axis.plot(xc + xrel, zc + zscale * mctrace, lw=lw, color=c, **plot_kwargs)
49
+
50
+
51
+ def annotated_dendro(
52
+ ax,
53
+ Z,
54
+ annotations,
55
+ brute_indicator=None,
56
+ group_ids=None,
57
+ cluster_ids=None,
58
+ threshold=1.0,
59
+ above_threshold_color=0.0,
60
+ leaf_labels=None,
61
+ annotations_offset_by_n=True,
62
+ rotation=45,
63
+ ):
64
+ n = len(Z) + 1
65
+ res = dendrogram(
66
+ Z,
67
+ ax=ax,
68
+ distance_sort=True,
69
+ color_threshold=1.0,
70
+ get_leaves=True,
71
+ no_plot=True,
72
+ )
73
+ dcoords = np.array(res["dcoord"])[:, 1]
74
+ depth_order = np.argsort(dcoords)
75
+ if brute_indicator is not None:
76
+ leaf_descendants = leafsets(Z)
77
+
78
+ lines = np.zeros((len(Z), 4, 2))
79
+ colors = np.zeros((len(Z), 3))
80
+ for jj, (ic, dc) in enumerate(zip(res["icoord"], res["dcoord"])):
81
+ j = depth_order[jj]
82
+ lines[j, :, 0] = ic
83
+ lines[j, :, 1] = dc
84
+ if dc[1] < threshold:
85
+ colors[j] = glasbey1024[n + j]
86
+ else:
87
+ colors[j] = above_threshold_color
88
+
89
+ lc = LineCollection(lines, colors=colors)
90
+ ax.add_collection(lc)
91
+ ax.autoscale_view()
92
+ if leaf_labels is None:
93
+ leaf_labels = np.arange(len(res["leaves"]))
94
+ leaf_labels = np.asarray(leaf_labels)
95
+ ax.set_xticks(
96
+ 5 + 10 * np.arange(len(res["leaves"])), labels=leaf_labels[res["leaves"]]
97
+ )
98
+ for tick, leaf in zip(ax.get_xticklabels(), res["leaves"]):
99
+ tick.set_color(glasbey1024[leaf_labels[leaf]])
100
+
101
+ for jj, (ic, dc) in enumerate(zip(res["icoord"], res["dcoord"])):
102
+ j = depth_order[jj]
103
+ cluix = n + j if annotations_offset_by_n else j
104
+ isbrute = brute_indicator is not None and brute_indicator[j]
105
+ top = np.mean(ic[1:3]), np.mean(dc[1:3])
106
+ fc = colors[j]
107
+ lc = invert(fc)
108
+ if isbrute:
109
+ leaves = leaf_descendants[n + j]
110
+ gids = group_ids[leaves]
111
+ groups = []
112
+ nomerge = True
113
+ for gid in np.unique(gids):
114
+ ing = np.flatnonzero(gids == gid)
115
+ nomerge = nomerge and ing.size == 1
116
+ groups.append(
117
+ ",".join([str(int(leaf_labels[leaves[ii]])) for ii in ing])
118
+ )
119
+ gstr = " ".join(groups)
120
+ if nomerge:
121
+ gstr = "pass"
122
+ annot = f"brute {gstr} {annotations[cluix]}"
123
+ ax.text(
124
+ *top,
125
+ annot,
126
+ fontsize="medium",
127
+ color=lc,
128
+ va="center",
129
+ ha="center",
130
+ rotation=rotation,
131
+ rotation_mode="anchor",
132
+ bbox=dict(fc=fc, ec="none", boxstyle="square,pad=0."),
133
+ )
134
+ elif cluix in annotations:
135
+ ax.text(
136
+ *top,
137
+ annotations[cluix],
138
+ fontsize="medium",
139
+ color=lc,
140
+ va="center",
141
+ ha="center",
142
+ rotation=rotation,
143
+ rotation_mode="anchor",
144
+ bbox=dict(fc=fc, ec="none", boxstyle="square,pad=0."),
145
+ )
146
+
147
+
148
+ def distance_matrix_dendro(
149
+ panel,
150
+ distances,
151
+ unit_ids=None,
152
+ dendrogram_linkage=None,
153
+ dendrogram_threshold=0.25,
154
+ show_unit_labels=False,
155
+ vmax=1.0,
156
+ image_cmap: str | Colormap = "RdGy",
157
+ show_values=False,
158
+ show_values_from=None,
159
+ label_colors=glasbey1024,
160
+ label=None,
161
+ hspace=0.01,
162
+ with_colorbar=True,
163
+ value_color=None,
164
+ ):
165
+ image_cmap = plt.get_cmap(image_cmap)
166
+ show_dendrogram = dendrogram_linkage is not None
167
+ dendro_width = (0.7,) if show_dendrogram else ()
168
+ cbar_width = (0.15,) if with_colorbar else ()
169
+ if show_values_from is None:
170
+ show_values_from = distances
171
+
172
+ gs = panel.add_gridspec(
173
+ nrows=3,
174
+ ncols=1 + with_colorbar + show_dendrogram,
175
+ height_ratios=[0.5, 1, 0.5],
176
+ width_ratios=[2, *cbar_width, *dendro_width],
177
+ hspace=hspace,
178
+ wspace=0.00,
179
+ )
180
+ ax_im = panel.add_subplot(gs[:, 0])
181
+ if with_colorbar:
182
+ ax_cbar = panel.add_subplot(gs[1, 1])
183
+ if show_dendrogram:
184
+ scipy.cluster.hierarchy.set_link_color_palette(list(map(to_hex, label_colors)))
185
+ ax_dendro = panel.add_subplot(gs[:, 2], sharey=ax_im)
186
+ ax_dendro.axis("off")
187
+
188
+ Z, labels = get_linkage(
189
+ distances, method=dendrogram_linkage, threshold=dendrogram_threshold
190
+ )
191
+ dendro = dendrogram(
192
+ Z,
193
+ ax=ax_dendro,
194
+ color_threshold=dendrogram_threshold,
195
+ distance_sort=True,
196
+ orientation="right",
197
+ above_threshold_color="k",
198
+ )
199
+ order = np.array(dendro["leaves"])
200
+ else:
201
+ order = np.arange(distances.shape[0])
202
+
203
+ im = ax_im.imshow(
204
+ distances[order][:, order],
205
+ vmin=0,
206
+ vmax=vmax,
207
+ cmap=image_cmap,
208
+ extent=(
209
+ [0, len(distances) * 10, 0, len(distances) * 10]
210
+ if show_dendrogram
211
+ else None
212
+ ),
213
+ origin="lower",
214
+ )
215
+ if show_values:
216
+ sc = 10 if show_dendrogram else 1
217
+ so = 5 if show_dendrogram else 0
218
+ for (j, i), val in np.ndenumerate(show_values_from[order][:, order]):
219
+ if value_color is None:
220
+ lc = invert(image_cmap(val / vmax))
221
+ else:
222
+ lc = value_color
223
+ ax_im.text(
224
+ so + sc * i,
225
+ so + sc * j,
226
+ f"{val:.2f}",
227
+ ha="center",
228
+ va="center",
229
+ clip_on=True,
230
+ color=lc,
231
+ )
232
+ if show_unit_labels:
233
+ if unit_ids is None:
234
+ unit_ids = np.arange(distances.shape[0])
235
+ sc = 10 if show_dendrogram else 1
236
+ so = 5 if show_dendrogram else 0
237
+ ax_im.set_xticks(so + sc * np.arange(len(order)), unit_ids[order])
238
+ ax_im.set_yticks(so + sc * np.arange(len(order)), unit_ids[order])
239
+ for i, (tx, ty) in enumerate(
240
+ zip(ax_im.xaxis.get_ticklabels(), ax_im.yaxis.get_ticklabels())
241
+ ):
242
+ tx.set_color(label_colors[unit_ids[i]])
243
+ ty.set_color(label_colors[unit_ids[i]])
244
+ else:
245
+ ax_im.set_xticks([])
246
+ ax_im.set_yticks([])
247
+
248
+ if with_colorbar:
249
+ plt.colorbar(im, cax=ax_cbar, label=label, pad=0)
250
+ ax_cbar.set_yticks([0, vmax])
251
+ if label:
252
+ ax_cbar.set_ylabel("template distance", labelpad=-5)
253
+ return ax_im
254
+
255
+
256
+ _k = np.array([0.0, 0.0, 0.0, 1.0])
257
+ _w = np.array([1.0, 1.0, 1.0, 1.0])
258
+
259
+
260
+ def invert(color):
261
+ color = np.array(color)
262
+ if color[:3].mean() > 0.5:
263
+ return _k
264
+ return _w
265
+
266
+
267
+ def get_linkage(dists, method="complete", threshold=0.25):
268
+ pdist = dists[np.triu_indices(dists.shape[0], k=1)].copy()
269
+ pdist[~np.isfinite(pdist)] = 1_000_000 + pdist[np.isfinite(pdist)].max()
270
+ # complete linkage: max dist between all pairs across clusters.
271
+ Z = linkage(pdist, method=method)
272
+ # extract flat clustering using our max dist threshold
273
+ labels = fcluster(Z, threshold, criterion="distance")
274
+ return Z, labels
275
+
276
+
277
+ def density_peaks_study(
278
+ X,
279
+ density_result,
280
+ dims=[0, 1],
281
+ fig=None,
282
+ axes=None,
283
+ idx=None,
284
+ inv=None,
285
+ **scatter_kw,
286
+ ):
287
+ if inv is None:
288
+ idx = np.arange(len(X))
289
+ inv = np.arange(len(X))
290
+ if fig is None and axes is None:
291
+ fig, axes = plt.subplots(
292
+ ncols=3, layout="constrained", figsize=(9, 3), sharey=True
293
+ )
294
+ elif axes is None:
295
+ axes = fig.subplots(ncols=3, sharey=True)
296
+
297
+ scatter_kw = dict(lw=0, s=5) | scatter_kw
298
+
299
+ density = density_result["density"][inv]
300
+ labels = density_result["labels"][inv]
301
+ good = density_result["nhdn"][inv] < len(density_result["density"])
302
+ nhdns = np.full_like(inv, -1)
303
+ nhdns[good] = idx[density_result["nhdn"][inv][good]]
304
+
305
+ axes[0].scatter(*X[:, dims].T, c=density, **scatter_kw)
306
+ missed = labels < 0
307
+ if missed.any():
308
+ axes[1].scatter(*X[missed][:, dims].T, c="gray", **scatter_kw)
309
+ if ~missed.any():
310
+ axes[1].scatter(*X[~missed][:, dims].T, c=density[~missed], **scatter_kw)
311
+ for i in range(len(X)):
312
+ nhdn = nhdns[i]
313
+ if nhdn < 0:
314
+ continue
315
+ x = X[i, dims]
316
+ dx = X[nhdn, dims] - x
317
+ axes[1].arrow(*x, *dx, length_includes_head=True, width=0, color="k")
318
+ colors = np.concatenate([[[0.5, 0.5, 0.5]], glasbey1024])
319
+ axes[2].scatter(*X[:, dims].T, c=colors[labels + 1], **scatter_kw)
320
+ axes[2].scatter(*X[missed][:, dims].T, c="gray", **scatter_kw)
321
+ return fig, axes
322
+
323
+
324
+ def isi_hist(
325
+ times_s,
326
+ axis,
327
+ max_ms=5,
328
+ bin_ms=0.1,
329
+ color="k",
330
+ label=None,
331
+ histtype="bar",
332
+ alpha=1.0,
333
+ ):
334
+ dt_ms = np.diff(times_s) * 1000
335
+ bin_edges = np.arange(0, max_ms + bin_ms, bin_ms)
336
+ # counts, _ = np.histogram(dt_ms, bin_edges)
337
+ # bin_centers = 0.5 * (bin_edges[1:] + bin_edges[:-1])
338
+ # axis.bar(bin_centers, counts)
339
+ axis.hist(
340
+ dt_ms, bin_edges, color=color, label=label, histtype=histtype, alpha=alpha
341
+ )
342
+ axis.set_xlabel("isi (ms)")
343
+ axis.set_ylabel(f"count (out of {dt_ms.size} total isis)")
344
+
345
+
346
+ def correlogram(times_a, times_b=None, max_lag=50):
347
+ lags = np.arange(-max_lag, max_lag + 1)
348
+ ccg = np.zeros(len(lags), dtype=int)
349
+
350
+ times_a = np.sort(times_a)
351
+ auto = times_b is None
352
+ if auto:
353
+ times_b = times_a
354
+ else:
355
+ times_b = np.sort(times_b)
356
+
357
+ for i, lag in enumerate(lags):
358
+ lagged_b = times_b + lag
359
+ insertion_inds = np.searchsorted(times_a, lagged_b)
360
+ found = insertion_inds < len(times_a)
361
+ ccg[i] = np.sum(times_a[insertion_inds[found]] == lagged_b[found])
362
+
363
+ if auto:
364
+ ccg[lags == 0] = 0
365
+
366
+ return lags, ccg
367
+
368
+
369
+ def bar(ax, x, y, **kwargs):
370
+ dx = np.diff(x).min()
371
+ x0 = np.concatenate((x - dx, x[-1:] + dx))
372
+ return ax.stairs(y, x0, **kwargs)
373
+
374
+
375
+ def stackbar(ax, x, y, colors, labels, fill=True):
376
+ bottom = np.zeros_like(y[0]) if fill else None
377
+ handles = []
378
+ for yy, cc, ll in zip(y, colors, labels):
379
+ ckw = dict(facecolor=cc, edgecolor=None, lw=0) if fill else dict(color=cc)
380
+ h = bar(ax, x, yy + bottom, baseline=bottom, label=ll, fill=fill, **ckw)
381
+ handles.append(h)
382
+ if fill:
383
+ bottom += yy
384
+ return handles
385
+
386
+
387
+ def plot_correlogram(
388
+ axis, times_a, times_b=None, max_lag=50, color="k", fill=True, **stairs_kwargs
389
+ ):
390
+ lags, ccg = correlogram(times_a, times_b=times_b, max_lag=max_lag)
391
+ axis.set_xlabel("lag (samples)")
392
+ return bar(axis, lags, ccg, fill=fill, color=color, **stairs_kwargs)
dartsort/vis/colors.py ADDED
@@ -0,0 +1,36 @@
1
+ import numpy as np
2
+
3
+ from ..util.py_util import resolve_path
4
+
5
+ try:
6
+ from importlib.resources import files
7
+ except ImportError:
8
+ try:
9
+ from importlib_resources import files # type: ignore
10
+ except ImportError:
11
+ raise ValueError("Need python>=3.10 or pip install importlib_resources.")
12
+
13
+ data_dir = files("dartsort.pretrained")
14
+ glasbey1024_npz = resolve_path(data_dir.joinpath("glasbey1024.npz"))
15
+
16
+ with np.load(glasbey1024_npz) as npz:
17
+ glasbey1024 = npz["glasbey1024"]
18
+
19
+ gray = (0.5, 0.5, 0.5, 1.0)
20
+
21
+ __all__ = ["glasbey1024", "gray"]
22
+
23
+
24
+ try:
25
+ import colorcet as cc # type: ignore
26
+ from matplotlib.colors import to_rgba
27
+
28
+ glasbey_cool = 10 * list(map(to_rgba, cc.glasbey_cool))
29
+ glasbey_cool.append(gray)
30
+ glasbey_warm = 10 * list(map(to_rgba, cc.glasbey_warm))
31
+ glasbey_warm.append(gray)
32
+ glasbey_cool = np.array(glasbey_cool)
33
+ glasbey_warm = np.array(glasbey_warm)
34
+ __all__ += ["glasbey_cool", "glasbey_warm"]
35
+ except ImportError:
36
+ pass