AllenInstitute / openscope_databook

OpenScope databook: a collaborative, versioned, data-centric collection of foundational analyses for reproducible systems neuroscience 🐁🧠🔬🖥️📈
https://alleninstitute.github.io/openscope_databook
Other
58 stars 18 forks source link

Error in Cell # 7 for "Visualizing Neuropixel Probe Locations" #393

Open cspurandare opened 1 month ago

cspurandare commented 1 month ago

Hello, I am following the notebook to check Neuropixel probe tracks. I was able to setup the environment on DandiHub, and follow the tutorial upto cell #7. Upon checking print(points.shape) I get the correct output like the notebook (1920,3). But in the next cell, I get an error, appended below.


TraitError Traceback (most recent call last) Cell In[9], line 2 1 # the 'markers' parameter will expect an iterable where each point is represented as [x,y,z] ----> 2 ccf = CCFWidget(markers=[points])

File /opt/conda/envs/allen/lib/python3.8/site-packages/ccfwidget/widget_ccf.py:122, in CCFWidget.init(self, tree, swc_morphologies, markers, marker_sizes, marker_opacities, marker_colors, selected_allen_ids, selected_acronyms, rotate, *kwargs) 118 camera = np.array([[ 1.3441567e+03, -2.1723846e+04, 1.7496496e+04], 119 [ 6.5500000e+03, 3.9750000e+03, 5.6750000e+03], 120 [ 3.6606243e-01, -4.4908229e-01, -8.1506038e-01]], dtype=np.float32) 121 size_limit_3d = [256,256,256] --> 122 self.itk_viewer = view(image=self._image, 123 label_image=self._label_image, 124 opacity_gaussians=opacity_gaussians, 125 label_image_blend=0.65, 126 point_sets=markers.copy(), 127 camera=camera, 128 ui_collapsed=True, 129 shadow=False, 130 size_limit_3d=size_limit_3d, 131 background=(0.85,)3, 132 units="μm", 133 gradient_opacity=0.1) 134 # Todo: initialization should work 135 self.itk_viewer.opacity_gaussians = opacity_gaussians

File /opt/conda/envs/allen/lib/python3.8/site-packages/itkwidgets/widget_viewer.py:1090, in view(image, label_image, label_image_names, label_image_weights, label_image_blend, cmap, lut, select_roi, interpolation, gradient_opacity, opacity_gaussians, channels, slicing_planes, shadow, blend_mode, point_sets, point_set_colors, point_set_opacities, point_set_representations, point_set_sizes, geometries, geometry_colors, geometry_opacities, ui_collapsed, rotate, annotations, axes, mode, kwargs) 1087 if image is None and len(images): # only one image is rendered 1088 image = images[0] -> 1090 viewer = Viewer(image=image, 1091 label_image=label_image, 1092 label_image_names=label_image_names, 1093 label_image_blend=label_image_blend, 1094 label_image_weights=label_image_weights, 1095 cmap=cmap, 1096 lut=lut, 1097 select_roi=select_roi, 1098 interpolation=interpolation, 1099 gradient_opacity=gradient_opacity, 1100 opacity_gaussians=opacity_gaussians, 1101 slicing_planes=slicing_planes, 1102 shadow=shadow, blend_mode=blend_mode, 1103 point_sets=point_sets, 1104 point_set_colors=point_set_colors, 1105 point_set_opacities=point_set_opacities, 1106 point_set_representations=point_set_representations, 1107 point_set_sizes=point_set_sizes, 1108 geometries=geometries, geometry_colors=geometry_colors, 1109 geometry_opacities=geometry_opacities, 1110 rotate=rotate, ui_collapsed=ui_collapsed, 1111 annotations=annotations, axes=axes, mode=mode, 1112 kwargs) 1113 return viewer

File /opt/conda/envs/allen/lib/python3.8/site-packages/itkwidgets/widget_viewer.py:369, in Viewer.init(self, kwargs) 365 if have_label_image: 366 # Interpolation is not currently supported with label maps 367 kwargs['interpolation'] = False --> 369 super(Viewer, self).init(kwargs) 371 if not self.image and not self.label_image: 372 return

File /opt/conda/envs/allen/lib/python3.8/site-packages/ipywidgets/widgets/widget.py:443, in Widget.init(self, kwargs) 441 """Public constructor""" 442 self._model_id = kwargs.pop('model_id', None) --> 443 super().init(kwargs) 445 Widget._call_widget_constructed(self) 446 self.open()

File /opt/conda/envs/allen/lib/python3.8/site-packages/traitlets/traitlets.py:1370, in HasTraits.init(self, *args, **kwargs) 1368 for key in changed: 1369 value = self._traits[key]._cross_validate(self, getattr(self, key)) -> 1370 self.set_trait(key, value) 1371 changes[key]["new"] = value 1372 self._cross_validation_lock = False

File /opt/conda/envs/allen/lib/python3.8/site-packages/traitlets/traitlets.py:1764, in HasTraits.set_trait(self, name, value) 1762 if not self.has_trait(name): 1763 raise TraitError(f"Class {cls.name} does not have a trait named {name}") -> 1764 getattr(cls, name).set(self, value)

File /opt/conda/envs/allen/lib/python3.8/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 /opt/conda/envs/allen/lib/python3.8/site-packages/traitlets/traitlets.py:722, in TraitType._validate(self, obj, value) 720 return value 721 if hasattr(self, "validate"): --> 722 value = self.validate(obj, value) 723 if obj._cross_validation_lock is False: 724 value = self._cross_validate(obj, value)

File /opt/conda/envs/allen/lib/python3.8/site-packages/ipydatawidgets/ndarray/traits.py:25, in NDArray.validate(self, obj, value) 24 def validate(self, obj, value): ---> 25 value = super(NDArray, self).validate(obj, value) 26 if value is None or value is Undefined: 27 return value

File /opt/conda/envs/allen/lib/python3.8/site-packages/traittypes/traittypes.py:105, in Array.validate(self, obj, value) 103 except (ValueError, TypeError) as e: 104 raise TraitError(e) --> 105 return super(Array, self).validate(obj, value)

File /opt/conda/envs/allen/lib/python3.8/site-packages/traittypes/traittypes.py:76, in SciType.validate(self, obj, value) 74 try: 75 for validator in self.validators: ---> 76 value = validator(self, value) 77 return value 78 except (ValueError, TypeError) as e:

File /opt/conda/envs/allen/lib/python3.8/site-packages/ipydatawidgets/ndarray/traits.py:40, in shape_constraints..validator(trait, value) 38 return value 39 if len(value.shape) != len(args): ---> 40 raise TraitError('%s shape expected to have %s components, but got %s components' % ( 41 trait.name, len(args), value.shape)) 42 for i, constraint in enumerate(args): 43 if constraint is not None:

TraitError: label_image_weights shape expected to have 1 components, but got () components.

Since I followed the notebook in all steps before that and it went fine, I am a bit confused where the error creeps in. Let me know if any other information would be helpful, Thanks, Chinmay

jeromelecoq commented 1 month ago

Can you try running it locally on your machine? I just want to rule out potential UI components.