AllenInstitute / AllenSDK

code for reading and processing Allen Institute for Brain Science data
https://allensdk.readthedocs.io/en/latest/
Other
335 stars 149 forks source link

Error #2594

Closed zhixinlu closed 1 year ago

zhixinlu commented 1 year ago

Describe the bug When running the example python notebook given in https://allensdk.readthedocs.io/en/latest/_static/examples/nb/ecephys_session.html, the allensdk2.13.6 showed two errors in two different cells.

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/allensdk/brain_observatory/ecephys/ecephys_session.py:1039, in EcephysSession.get_stimulus_parameter_values(self, stimulus_presentation_ids, drop_nulls) 1037 non_null = np.array(uniques[uniques != "null"]) 1038 non_null = non_null -> 1039 non_null = np.sort(non_null) 1041 if not drop_nulls and "null" in uniques: 1042 non_null = np.concatenate([non_null, ["null"]])

File <__array_function__ internals>:5, in sort(*args, **kwargs)

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/numpy/core/fromnumeric.py:996, in sort(a, axis, kind, order) 994 else: 995 a = asanyarray(a).copy(order="K") --> 996 a.sort(axis=axis, kind=kind, order=order) 997 return a

TypeError: '<' not supported between instances of 'float' and 'str'

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/pandas/_libs/index.pyx:138, in pandas._libs.index.IndexEngine.get_loc()

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/pandas/_libs/index.pyx:165, in pandas._libs.index.IndexEngine.get_loc()

File pandas/_libs/hashtable_class_helper.pxi:5745, in pandas._libs.hashtable.PyObjectHashTable.get_item()

File pandas/_libs/hashtable_class_helper.pxi:5753, in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'local_index'

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last) Input In [31], in <cell line: 3>() 1 units_of_interest = high_snr_unit_ids[:35] ----> 3 waveforms = {uid: session.mean_waveforms[uid] for uid in units_of_interest} 4 peak_channels = {uid: session.units.loc[uid, 'peak_channel_id'] for uid in units_of_interest} 6 # plot the mean waveform on each unit's peak channel/

Input In [31], in (.0) 1 units_of_interest = high_snr_unit_ids[:35] ----> 3 waveforms = {uid: session.mean_waveforms[uid] for uid in units_of_interest} 4 peak_channels = {uid: session.units.loc[uid, 'peak_channel_id'] for uid in units_of_interest} 6 # plot the mean waveform on each unit's peak channel/

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/allensdk/core/lazy_property/lazy_property_mixin.py:15, in LazyPropertyMixin.getattribute(self, name) 13 curr_attr = super(LazyPropertyMixin, self).getattribute(name) 14 if isinstance(curr_attr, lazy_class): ---> 15 return curr_attr.get(curr_attr) 16 else: 17 return super(LazyPropertyMixin, self).getattribute(name)

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/allensdk/core/lazy_property/lazy_property.py:20, in LazyProperty.get(self, obj, objtype) 17 return self 19 if self.value is None: ---> 20 self.value = self.calculate() 21 return self.value

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/allensdk/core/lazy_property/lazy_property.py:32, in LazyProperty.calculate(self) 30 result = self.api_method(*self.args, **self.kwargs) 31 for wrapper in self.wrappers: ---> 32 result = wrapper(result) 33 return result

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/allensdk/brain_observatory/ecephys/ecephys_session.py:1244, in EcephysSession._build_mean_waveforms(self, mean_waveforms) 1242 channel_id_lut = defaultdict(lambda: -1) 1243 for cid, row in self.channels.iterrows(): -> 1244 channel_id_lut[(row["local_index"], row["probe_id"])] = cid 1246 probe_id_lut = { 1247 uid: row['probe_id'] for uid, row in self._units.iterrows() 1248 } 1250 output_waveforms = {}

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/pandas/core/series.py:981, in Series.getitem(self, key) 978 return self._values[key] 980 elif key_is_scalar: --> 981 return self._get_value(key) 983 if is_hashable(key): 984 # Otherwise index.get_value will raise InvalidIndexError 985 try: 986 # For labels that don't resolve as scalars like tuples and frozensets

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/pandas/core/series.py:1089, in Series._get_value(self, label, takeable) 1086 return self._values[label] 1088 # Similar to Index.get_value, but we do not fall back to positional -> 1089 loc = self.index.get_loc(label) 1090 return self.index._get_values_for_loc(self, loc, label)

File ~/.conda/envs/TorchOnGPUs/lib/python3.8/site-packages/pandas/core/indexes/base.py:3805, in Index.get_loc(self, key, method, tolerance) 3803 return self._engine.get_loc(casted_key) 3804 except KeyError as err: -> 3805 raise KeyError(key) from err 3806 except TypeError: 3807 # If we have a listlike key, _check_indexing_error will raise 3808 # InvalidIndexError. Otherwise we fall through and re-raise 3809 # the TypeError. 3810 self._check_indexing_error(key)

KeyError: 'local_index'

To Reproduce

Run the notebook cell by cell The notebook I downloaded is from https://allensdk.readthedocs.io/en/latest/_static/examples/nb/ecephys_session.html. Just run from the top to the cell number 17 and cell number 28 should reproduce this error.

Expected behavior

Actual Behavior The errors are mentioned above.

Environment (please complete the following information):

Additional context

Do you want to work on this issue? I am not capable of solving this problem.