Conversation
theodchrn
commented
Feb 4, 2026
- clean: remove old notebooks
- fix: typos and minor errors in dealing w bayes matrices
- add: tests and possibility to save and load datasets to tfrec and parquet format
- improve: plotting modules
- improve: test units
- change global classes behaviour: no need for duplicate in Mouse_Results, remove dependency on window size and fix copy/paste issues for datahelper (different phases kepts the same Ref)
- add: possibility to randomize the spikes inside the dataset for control
- add: helper function for comparing bayes and ann
- add: data helper behaviour without windowsize ms
- fix: lots of typos and ruff linting issues
remove dependency on window size and fix copy/paste issues for datahelper (different phases kepts the same Ref) This allows for lighter mouse results, more focuses ref on datahelper
There was a problem hiding this comment.
Pull request overview
This PR performs extensive code cleanup and adds new functionality for dataset management. The main objectives are to fix linting errors, remove unused code, and add capabilities for saving/loading datasets in TFRecord and Parquet formats.
Changes:
- Fixed numerous linting issues: replaced bare except clauses with specific exceptions, converted lambda functions to named functions, fixed type comparisons to use isinstance()
- Removed old notebooks and deprecated code (old_code.py with ~1800 lines)
- Added dataset saving/loading functionality for TFRecord and Parquet formats
- Refactored global classes to remove window size dependencies and fix copy/paste issues
- Added spike randomization capability for control experiments
- Improved plotting modules and test coverage
Reviewed changes
Copilot reviewed 31 out of 38 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock, pyproject.toml | Added pyarrow, pdf2image, python-pptx dependencies |
| tests/test_*.py | Improved test coverage, removed unused variables, added dataset saving tests |
| runAllMice.py | Logic changes for force flag, mouse filtering, experiment selection; added dry-run flag |
| neuroencoders/utils/* | Extensive linting fixes, improved exception handling, refactored global classes |
| neuroencoders/fullEncoder/an_network.py | Added dataset save/load functionality, model rebuilding methods |
| neuroencoders/simpleBayes/decode_bayes.py | Added spike loading methods, fixed lambda to named function |
| neuroencoders/importData/* | Linting fixes, improved GUI time formatting, added linear spike sorting |
| neuroencoders/resultAnalysis/* | Removed old_code.py, updated function calls for API changes |
| neuroEncoder | Updated function calls, removed try-except wrappers, added debug print |
| .pre-commit-config.yaml | Fixed YAML formatting, removed --exit-zero from ruff |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| helper.get_true_target( | ||
| l_function, in_place=True, show=show_figures, speedMask=True | ||
| windowSizeMS, l_function, in_place=True, show=show_figures, speedMask=True | ||
| ) |
There was a problem hiding this comment.
Incorrect function call: The method signature for get_true_target was changed to accept windowSizeMS as the first parameter (line 436-438), but this call doesn't provide it. This will cause a TypeError since windowSizeMS is now a required positional argument. The call should be: helper.get_true_target(windowSizeMS, l_function, in_place=True, show=show_figures, speedMask=True)
| if not hasattr( | ||
| self.trainerBayes, "spikeMatTimes" | ||
| ) or not hasattr(self.trainerBayes, "spikeMat"): | ||
| raise ValueError( | ||
| """ | ||
| trainerBayes does not have spikeMatTimes or spikeMat attributes needed to extract spike counts. | ||
| Make sure to run decoding with extract_spike_counts=True first. You can run trainerBayes.train_order_by_pos. | ||
| """ | ||
| ) | ||
| total_count, _ = extract_spike_counts_keops( | ||
| timesBayes[-1], self.trainerBayes.spikeMatTimes, ws / 1000 | ||
| ) | ||
| total_spikes_count.append(total_count) | ||
| matrix_count, _ = extract_spike_counts_from_matrix( | ||
| matrix_count, _ = extract_spike_counts_matrix_keops( | ||
| timesBayes[-1], | ||
| self.trainerBayes.spikeMat, | ||
| self.trainerBayes.spikeMatLabels, | ||
| self.trainerBayes.spikeMatTimes, | ||
| ws / 1000, | ||
| ) |
There was a problem hiding this comment.
Missing null handling: The try-except at lines 529-537 attempts to extract spike counts, but if trainerBayes.spikeMatTimes or trainerBayes.spikeMat don't exist (as checked in lines 529-531), the code will raise a ValueError but then continues to try accessing these attributes at lines 538-547. The control flow should either return early after raising the ValueError or ensure these attributes exist before proceeding.
runAllMice.py
Outdated
| "--target", | ||
| target_bayes, | ||
| "--flat_prior", | ||
| # "--flat_prior", |
There was a problem hiding this comment.
Commented out critical parameter: The '--flat_prior' flag has been commented out at line 251. This changes the behavior of the Bayesian decoder. If this is intentional, consider removing the line entirely or adding a comment explaining why. If it's temporary for testing, it should be uncommented before merging.
|
|
||
| # regarding data augmentation | ||
| self.dataAugmentation = kwargs.pop("dataAugmentation", True) | ||
| self.dataAugmentation = kwargs.pop("dataAugmentation", False) |
There was a problem hiding this comment.
The dataAugmentation default has been changed from True to False (line 1706). This is a significant behavior change that will affect model training. Ensure this is intentional and documented, as it may impact model performance. Consider whether this should be mentioned in the PR description or release notes.
| self.dataAugmentation = kwargs.pop("dataAugmentation", False) | |
| self.dataAugmentation = kwargs.pop("dataAugmentation", True) |
| self.xyOutput, positions = self._get_XYOutput_morph_maze( | ||
| positions, self.shock_zone_mask, self.ref, self.ratioIMAonREAL | ||
| ) |
There was a problem hiding this comment.
Missing return statement: The function _get_XYOutput_morph_maze now returns both XYOutput and positions (line 1027), but the assignment at line 865 captures only xyOutput, discarding the updated positions. This should be: self.xyOutput, positions = self._get_XYOutput_morph_maze(...). Without this change, the positions variable will not reflect any transformations applied inside the function.
| try: | ||
| ls[dim][2][iaxis].remove() | ||
| except: | ||
| except (AttributeError, KeyError): |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| try: | ||
| ls[dim][2].remove() | ||
| except: | ||
| except (AttributeError, KeyError): |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| try: | ||
| l3.remove() | ||
| except: | ||
| except (AttributeError, KeyError): |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| try: | ||
| mask = indices == frame | ||
| except: | ||
| except (TypeError, AttributeError): |
There was a problem hiding this comment.
This statement is unreachable.
| try: | ||
| mask = indices == frame | ||
| except: | ||
| except (TypeError, AttributeError): |
There was a problem hiding this comment.
This statement is unreachable.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@theodchrn I've opened a new pull request, #62, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ming Co-authored-by: theodchrn <48409582+theodchrn@users.noreply.github.com>
…g builtin Co-authored-by: theodchrn <48409582+theodchrn@users.noreply.github.com>
…nused code Co-authored-by: theodchrn <48409582+theodchrn@users.noreply.github.com>
Co-authored-by: theodchrn <48409582+theodchrn@users.noreply.github.com>
Address PR review comments: remove debug code, fix variable shadowing, improve error handling