-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I'm attempting to render neuropixel probes with ccfwidgets and set the marker colors within a jupyter notebook. This yields an error an itk widgets.
Here is my code;
colors = [(1.00, 0, 0.5) for i in range(len(points))]
ccf = CCFWidget(markers=[points])
ccf.marker_colors = colorswhere points is a numpy array with shape (2304, 3)
Here is the traceback;
IndexError Traceback (most recent call last)
Cell In [49], line 2
1 ccf = CCFWidget(markers=[points])
----> 2 ccf.marker_colors = colors
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:715, in TraitType.__set__(self, obj, value)
713 raise TraitError('The "%s" trait is read-only.' % self.name)
714 else:
--> 715 self.set(obj, value)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:2865, in List.set(self, obj, value)
2863 return super().set(obj, [value])
2864 else:
-> 2865 return super().set(obj, value)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:689, in TraitType.set(self, obj, value)
688 def set(self, obj, value):
--> 689 new_value = self._validate(obj, value)
690 try:
691 old_value = obj._trait_values[self.name]
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:723, in TraitType._validate(self, obj, value)
721 value = self.validate(obj, value) # type:ignore[attr-defined]
722 if obj._cross_validation_lock is False:
--> 723 value = self._cross_validate(obj, value)
724 return value
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:729, in TraitType._cross_validate(self, obj, value)
727 if self.name in obj._trait_validators:
728 proposal = Bunch({"trait": self, "value": value, "owner": obj})
--> 729 value = obj._trait_validators[self.name](obj, proposal)
730 elif hasattr(obj, "_%s_validate" % self.name):
731 meth_name = "_%s_validate" % self.name
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:1132, in EventHandler.__call__(self, *args, **kwargs)
1130 """Pass `*args` and `**kwargs` to the handler's function if it exists."""
1131 if hasattr(self, "func"):
-> 1132 return self.func(*args, **kwargs)
1133 else:
1134 return self._init_call(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\ccfwidget\widget_ccf.py:289, in CCFWidget._validate_marker_colors(self, proposal)
286 @validate('marker_colors')
287 def _validate_marker_colors(self, proposal):
288 value = proposal['value']
--> 289 self.itk_viewer.point_set_colors = [(1.0, 0.0, 0.0),]*len(self.swc_point_sets) + value
290 return value
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:715, in TraitType.__set__(self, obj, value)
713 raise TraitError('The "%s" trait is read-only.' % self.name)
714 else:
--> 715 self.set(obj, value)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traittypes\traittypes.py:108, in Array.set(self, obj, value)
107 def set(self, obj, value):
--> 108 new_value = self._validate(obj, value)
109 old_value = obj._trait_values.get(self.name, self.default_value)
110 obj._trait_values[self.name] = new_value
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:723, in TraitType._validate(self, obj, value)
721 value = self.validate(obj, value) # type:ignore[attr-defined]
722 if obj._cross_validation_lock is False:
--> 723 value = self._cross_validate(obj, value)
724 return value
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:729, in TraitType._cross_validate(self, obj, value)
727 if self.name in obj._trait_validators:
728 proposal = Bunch({"trait": self, "value": value, "owner": obj})
--> 729 value = obj._trait_validators[self.name](obj, proposal)
730 elif hasattr(obj, "_%s_validate" % self.name):
731 meth_name = "_%s_validate" % self.name
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\traitlets\traitlets.py:1132, in EventHandler.__call__(self, *args, **kwargs)
1130 """Pass `*args` and `**kwargs` to the handler's function if it exists."""
1131 if hasattr(self, "func"):
-> 1132 return self.func(*args, **kwargs)
1133 else:
1134 return self._init_call(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\itkwidgets\widget_viewer.py:633, in Viewer._validate_point_set_colors(self, proposal)
631 result = np.zeros((n_colors, 3), dtype=np.float32)
632 for index, color in enumerate(value):
--> 633 result[index, :] = matplotlib.colors.to_rgb(color)
634 if len(value) < n_colors:
635 for index in range(len(value), n_colors):
IndexError: index 1 is out of bounds for axis 0 with size 1I looked in the examples and found no documentation about the usage of setting marker_colors, so I'm not 100% my usage is correct. The same error is given when passing marker_colors in the ccf constructor. Is this a problem with itkwidgets?
Metadata
Metadata
Assignees
Labels
No labels