Skip to content

Add motion and emg datatypes #515

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

Merged
merged 10 commits into from
Jun 19, 2025
Merged

Add motion and emg datatypes #515

merged 10 commits into from
Jun 19, 2025

Conversation

JoeZiminski
Copy link
Member

@JoeZiminski JoeZiminski commented May 8, 2025

This PR extends the narrow datatypes to include motion and emg, as per NeuroBlueprint PRs #67 and #68.

It required extending the backwards-compatibility checking for the TUI arguments, to fill-in the settings for missing datatypes. In general, the narrow-datatype machinery is not very extensible, this should be addressed in issue #516.

@JoeZiminski JoeZiminski force-pushed the add_motion_emg_datatypes branch from 304ab50 to 8573a44 Compare June 6, 2025 12:36
@JoeZiminski JoeZiminski requested a review from cs7-shrey June 6, 2025 13:13
@JoeZiminski
Copy link
Member Author

Hey @cs7-shrey thanks a lot for this review and catching so many mistakes! Really goes to show the importance of code review, and writing tests (which I had lazily skipped 😅). I've rewritten the function as suggested and added some regression tests, let me know what you think.

Copy link
Collaborator

@cs7-shrey cs7-shrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JoeZiminski the logic is great and seems to work correctly. I have added some review comments regarding tests.

v0.6.0 is the first version with narrow datatypes, and the checkboxes was refactored to
be a {"on": bool, "displayed": bool} dict rather than a bool indicating whether the checkbox is on.
However, this version is missing narrow datatypes added later (e.g. "motion").
In the test file, all 'displayed' are turned off except f2pe.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very good at testing strategy but do you think it would be better if instead of having a hardcoded file, we had a function generate_v0_6_0_persistent_settings which would take arguments to turn checkboxes on and off in a dictionary and then write that to a yaml. Something like this

def generate_v0_6_0_persistent_settings(checkbox_type: Literal["transfer" | "create"], displayed_or_on: Literal["on", "displayed"], datatypes_turned_off: list[str]):
    settings = {... the persistent_settings.yaml as a dict }
    for dtype in datatypes:
        settings["tui"][f"{checkbox_type}_checkboxes_on"][dtype][displayed_or_on] = False
    
    # write settings to yaml file

WIth this we can parametrize some arguments in the tests and test a range of inputs.

Tbh, this function has a lot of moving parts and maybe it's not worth the effort to even include it and then write corresponding code in the test function. Also, the keys you've chosen to test on cover a lot of edge cases themselves so, I'll leave it to you in the end.

Copy link
Member Author

@JoeZiminski JoeZiminski Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cs7-shrey this is a great idea and would ideally be the best approach. In practice, it is a little fiddly because the script would have to do something like uninstall datashuttle, reinstall the version for each yaml and then build the yaml file settings in different ways depending on the datashuttle version. Because it's anticipated that we shouldn't have to do this too often, to avoid that complexity as you mention we can continue doing it manually for now. However, if we find we are continually having to manually create new yaml files, for basic stuff like adding a new narrow datatype, we should definitely take this approach. I'll resolve this for now but good to think about for the future.

and persistent settings match the structure of the
files loaded from the old datashuttle version.
"""
project = DataShuttle("test_project")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project actually exists even after the test code exits and also leaves some folders in the top level directory of the codebase. I think we could use some existing testing machinery to ensure temporary paths for "test_project"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'll make a fixture for it

@JoeZiminski JoeZiminski requested a review from cs7-shrey June 16, 2025 11:38
@JoeZiminski JoeZiminski added this to the v2. milestone Jun 17, 2025
Copy link
Collaborator

@cs7-shrey cs7-shrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one small comment.

@JoeZiminski JoeZiminski merged commit be550d5 into main Jun 19, 2025
16 checks passed
@JoeZiminski JoeZiminski deleted the add_motion_emg_datatypes branch June 19, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants