LorenFrankLab / rec_to_nwb

Data Migration REC -> NWB 2.0 Service
Other
2 stars 8 forks source link

key error with offline position tracking #35

Closed MichaelCoulter closed 2 years ago

MichaelCoulter commented 2 years ago

KeyError Traceback (most recent call last) /tmp/ipykernel_3135872/2747406067.py in 20 overwrite = False) 21 ---> 22 builder.build_nwb() 23

~/rec_to_nwb/rec_to_nwb/processing/builder/raw_to_nwb_builder.py in build_nwb(self, run_preprocessing, process_mda_valid_time, process_mda_invalid_time, process_pos_valid_time, process_pos_invalid_time) 230 process_mda_invalid_time=process_mda_invalid_time, 231 process_pos_valid_time=process_pos_valid_time, --> 232 process_pos_invalid_time=process_pos_invalid_time) 233 234 logger.info('Done...\n')

~/rec_to_nwb/rec_to_nwb/processing/builder/raw_to_nwb_builder.py in __build_nwb_file(self, process_mda_valid_time, process_mda_invalid_time, process_pos_valid_time, process_pos_invalid_time) 245 logger.info('Date: {}'.format(date)) 246 nwb_builder = self.get_nwb_builder(date) --> 247 content = nwb_builder.build() 248 nwb_builder.write(content) 249 if self.is_old_dataset:

~/rec_to_nwb/rec_to_nwb/processing/builder/nwb_file_builder.py in build(self) 369 self.associated_files_originator.make(nwb_content) 370 --> 371 self.position_originator.make(nwb_content) 372 373 valid_map_dict = self.__build_corrupted_data_manager()

~/rec_to_nwb/rec_to_nwb/processing/tools/beartype/beartype.py in func_beartyped(__beartype_func, *args, **kwargs)

~/rec_to_nwb/rec_to_nwb/processing/builder/originators/position_originator.py in make(self, nwb_content) 50 zip(meters_per_pixels, position_tracking_paths)): 51 position_df = self.get_position_with_corrected_timestamps( ---> 52 position_tracking_path) 53 position.create_spatialseries( 54 name=f'series{series_id}',

~/rec_to_nwb/rec_to_nwb/processing/builder/originators/position_originator.py in get_position_with_corrected_timestamps(position_tracking_path) 101 # Additionally, for offline tracking, frames can be skipped if the 102 # frame is labeled as bad. --> 103 video_info = video_info.loc[position_tracking.index.unique()] 104 frame_count = np.asarray(video_info.HWframeCount) 105 ptp_systime = np.asarray(video_info.HWTimestamp)

~/anaconda3/envs/rec_to_nwb/lib/python3.7/site-packages/pandas/core/indexing.py in getitem(self, key) 929 930 maybe_callable = com.apply_if_callable(key, self.obj) --> 931 return self._getitem_axis(maybe_callable, axis=axis) 932 933 def _is_scalar_access(self, key: tuple):

~/anaconda3/envs/rec_to_nwb/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis) 1151 raise ValueError("Cannot index with multidimensional key") 1152 -> 1153 return self._getitem_iterable(key, axis=axis) 1154 1155 # nested tuple slicing

~/anaconda3/envs/rec_to_nwb/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_iterable(self, key, axis) 1091 1092 # A collection of keys -> 1093 keyarr, indexer = self._get_listlike_indexer(key, axis) 1094 return self.obj._reindex_with_indexers( 1095 {axis: [keyarr, indexer]}, copy=True, allow_dups=True

~/anaconda3/envs/rec_to_nwb/lib/python3.7/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis) 1312 keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr) 1313 -> 1314 self._validate_read_indexer(keyarr, indexer, axis) 1315 1316 if needs_i8_conversion(ax.dtype) or isinstance(

~/anaconda3/envs/rec_to_nwb/lib/python3.7/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis) 1372 if use_interval_msg: 1373 key = list(key) -> 1374 raise KeyError(f"None of [{key}] are in the [{axis_name}]") 1375 1376 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())

KeyError: "None of [UInt64Index([ 15318149, 15319121, 15320092, 15321063, 15322035, 15323006,\n 15323978, 15340762, 15341733, 15342704,\n ...\n 127631504, 127632472, 127633448, 127634416, 127635392, 127636360,\n 127637328, 127638304, 127639272, 127640248],\n dtype='uint64', name='time', length=115617)] are in the [index]"

data directory: '/cumulus/david/Scn2a/coh5/CH65/20211125/preprocessing'