-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error when trying to populate PoseEstimation #1207
Comments
Immediate solution from spyglass.common import convert_epoch_interval_name_to_position_interval_name, TaskEpoch
key = {"nwb_file_name": "RS2120241016_.nwb",}
for k in (TaskEpoch & key).fetch("KEY"):
convert_epoch_interval_name_to_position_interval_name(k) Spyglass solution |
@MichaelCoulter if you can test the branch for the #1208 PR on another one that hit this error that would be great |
thanks! i will test this branch. |
that change didnt work for me. i recreated deleting that line in my own repo and got this error ---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[3], line 101
87 pose_estimation_key = (
88 sgp.DLCPoseEstimationSelection().insert_estimation_task(
89 {
(...)
97 )
98 )
100 ##populate DLC Pose Estimation
--> 101 sgp.DLCPoseEstimation().populate(pose_estimation_key)
103 ##start smooth interpolation
104 si_params_name = "just_nan"
File ~/spyglass/src/spyglass/utils/dj_mixin.py:608, in SpyglassMixin.populate(self, *restrictions, **kwargs)
606 if use_transact: # Pass single-process populate to super
607 kwargs["processes"] = processes
--> 608 return super().populate(*restrictions, **kwargs)
609 else: # No transaction protection, use bare make
610 for key in keys:
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/autopopulate.py:241, in AutoPopulate.populate(self, suppress_errors, return_exception_objects, reserve_jobs, order, limit, max_calls, display_progress, processes, make_kwargs, *restrictions)
237 if processes == 1:
238 for key in (
239 tqdm(keys, desc=self.__class__.__name__) if display_progress else keys
240 ):
--> 241 error = self._populate1(key, jobs, **populate_kwargs)
242 if error is not None:
243 error_list.append(error)
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/autopopulate.py:292, in AutoPopulate._populate1(self, key, jobs, suppress_errors, return_exception_objects, make_kwargs)
290 self.__class__._allow_insert = True
291 try:
--> 292 make(dict(key), **(make_kwargs or {}))
293 except (KeyboardInterrupt, SystemExit, Exception) as error:
294 try:
File ~/spyglass/src/spyglass/position/v1/position_dlc_pose_estimation.py:213, in DLCPoseEstimation.make(self, key)
209 """.populate() method will launch training for each PoseEstimationTask"""
210 self.log_path = (
211 Path(infer_output_dir(key=key, makedir=False)) / "log.log"
212 )
--> 213 self._logged_make(key)
File ~/spyglass/src/spyglass/position/v1/dlc_utils.py:198, in file_log.<locals>.decorator.<locals>.wrapper(self, *args, **kwargs)
196 logger.removeHandler(logger.handlers[0])
197 try:
--> 198 return func(self, *args, **kwargs)
199 finally:
200 if not console:
File ~/spyglass/src/spyglass/position/v1/position_dlc_pose_estimation.py:252, in DLCPoseEstimation._logged_make(self, key)
246 creation_time = datetime.fromtimestamp(
247 dlc_result.creation_time
248 ).strftime("%Y-%m-%d %H:%M:%S")
250 logger.info("getting raw position")
251 interval_list_name = (
--> 252 convert_epoch_interval_name_to_position_interval_name(
253 {
254 "nwb_file_name": key["nwb_file_name"],
255 "epoch": key["epoch"],
256 },
257 #populate_missing=False,
258 )
259 )
260 if interval_list_name:
261 spatial_series = (
262 RawPosition()
263 & {**key, "interval_list_name": interval_list_name}
264 ).fetch_nwb()[0]["raw_position"]
File ~/spyglass/src/spyglass/common/common_behav.py:646, in convert_epoch_interval_name_to_position_interval_name(key, populate_missing)
644 if null_entry:
645 pos_query.delete(safemode=False) # no prompt
--> 646 PositionIntervalMap()._no_transaction_make(key)
647 pos_query = PositionIntervalMap & key
649 if pos_query.fetch(pos_str)[0] == "":
File ~/spyglass/src/spyglass/common/common_behav.py:547, in PositionIntervalMap._no_transaction_make(self, key)
545 if len(pos_intervals) == 0:
546 logger.error(f"NO POS INTERVALS FOR {key};\n{no_pop_msg}")
--> 547 self.insert1(null_key, **insert_opts)
548 return
550 valid_times = (IntervalList & key).fetch1("valid_times")
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/table.py:337, in Table.insert1(self, row, **kwargs)
330 def insert1(self, row, **kwargs):
331 """
332 Insert one data record into the table. For ``kwargs``, see ``insert()``.
333
334 :param row: a numpy record, a dict-like object, or an ordered sequence to be inserted
335 as one row.
336 """
--> 337 self.insert((row,), **kwargs)
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/table.py:419, in Table.insert(self, rows, replace, skip_duplicates, ignore_extra_fields, allow_direct_insert)
416 return
418 field_list = [] # collects the field list from first row (passed by reference)
--> 419 rows = list(
420 self.__make_row_to_insert(row, field_list, ignore_extra_fields)
421 for row in rows
422 )
423 if rows:
424 try:
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/table.py:420, in <genexpr>(.0)
416 return
418 field_list = [] # collects the field list from first row (passed by reference)
419 rows = list(
--> 420 self.__make_row_to_insert(row, field_list, ignore_extra_fields)
421 for row in rows
422 )
423 if rows:
424 try:
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/table.py:871, in Table.__make_row_to_insert(self, row, field_list, ignore_extra_fields)
865 attributes = [
866 self.__make_placeholder(name, row[name], ignore_extra_fields)
867 for name in self.heading
868 if name in row.dtype.fields
869 ]
870 elif isinstance(row, collections.abc.Mapping): # dict-based
--> 871 check_fields(row)
872 attributes = [
873 self.__make_placeholder(name, row[name], ignore_extra_fields)
874 for name in self.heading
875 if name in row
876 ]
877 else: # positional
File ~/mambaforge/envs/spyglass-position/lib/python3.9/site-packages/datajoint/table.py:857, in Table.__make_row_to_insert.<locals>.check_fields(fields)
855 for field in fields:
856 if field not in self.heading:
--> 857 raise KeyError(
858 "`{0:s}` is not in the table heading".format(field)
859 )
860 elif set(field_list) != set(fields).intersection(self.heading.names):
861 raise DataJointError("Attempt to insert rows with different fields.")
KeyError: '`epoch` is not in the table heading' |
@MichaelCoulter what is the value of |
Ah, I see. The |
this is the code i am running
and this is the error.
it looks like for a different nwbfile ("RS2120241020_.nwb") there are entries in the 'PositionIntervalMap' table, but i can't seem to populate this table for the nwbfile i am working with now ("RS2120241016_.nwb"). any ideas would be appreciated, thank you.
The text was updated successfully, but these errors were encountered: