Conversation
…alls the actual functions Logical switches are whether you are using an EDF-file or an mne-Object, the backend you want to use and whether you want to use individual channels or channels groups
Summary of ChangesHello @lamasmithueten, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the sleep scoring utility functions to improve flexibility and expand backend options. The primary goal is to provide a single, consistent interface for users to score sleep data, regardless of whether the input is a raw MNE object or an EDF file, and to allow for easy selection between different scoring service backends. This change streamlines the API and introduces a new local processing capability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the sleep scoring utilities by introducing a unified score_sleep function and adding a new sleepyland backend. The overall structure is improved, but there are several areas that need attention. I've identified issues such as debugging print statements left in the code, a critical bug involving an undefined variable, a resource leak from an unclosed file, inefficient string manipulation, and inadequate error handling for network requests. My review includes specific suggestions to enhance the code's robustness, maintainability, and correctness.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@lamasmithueten let me know when it's ready for my review, please mark all outdated conversations as resolved and address the remaining gemini comments, or comment if they are not relevant or useful suggestions |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
I closed all Gemini suggestions and merged the ones that make sense. I reran the changes and it worked without any error messages. |
|
New rewrite-request: change the new structure: # (pseudocode)
is_temp_file = False
if raw is not None:
assert isinstance(raw, mne.BaseRaw)
is_temp_file = True
edf_file = _raw_to_edf_tempfile(raw)
_score_sleep_file(edf_file, ...)
if is_temp_file:
os.remove(edf_file)alternatively, or even better: Use the tempfile interface to create a temporary file and then later call ".close()" on it later. This is slightly safer and gives you everything more easily i'll do mroe comments later, please wait before working on it until my go |
|
I moved the logic from the wraper function into the function |
Co-authored-by: Simon Kern <14980558+skjerns@users.noreply.github.com>
Co-authored-by: Simon Kern <14980558+skjerns@users.noreply.github.com>
The following functions where rewritten in
usleep_utils.py:predict_usleep()->_score_sleep_file()predict_usleep_raw()->_score_sleep_raw()The following functions were added:
score_sleep()_score_usleep_denmark()_score_sleepyland()Previously usleep_utils.py had two functions
predict_usleep()for EDF-files andpredict_usleep_raw()formne.io.Raw object. I have combined both of these functions into onescore_sleep()function, which can take either an EDF-file or anmne.io.Raw object. Based on that either_score_sleep_raw()or_score_sleep_file()is called. You need to set either theraworedf_fileparameter to call the corresponding function. If both are set, therawparameter has priority.Furthermore the backend for scoring has been extended. Previously you could only send to https://sleep.ai.ku.dk/ using their usleep API to score sleep. Now you can use the internal CIMH
sleepylandservice as a local backend. To choose which backend you want to use, you need to set thebackendvariable to eitherdenmarkorsleepylandto access the corresponding backend. I also added another variable calledbackend_urlfor future backends, but isn't used as of now, because both URLs use hard coded URLs.