Skip to content
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

Session module #127

Merged
merged 12 commits into from
Apr 12, 2021
Merged

Session module #127

merged 12 commits into from
Apr 12, 2021

Conversation

lawhead
Copy link
Collaborator

@lawhead lawhead commented Apr 6, 2021

Overview

Refactored session data from a dict to a class-based data structure. Refactored copy phrase task and session helpers to use the new data structures.

Ticket

https://www.pivotaltracker.com/story/show/176150973

Contributions

  • Refactored session data into separate data classes
  • Refactored Copy Phrase task to use new data classes
  • Refactored session helper to use new classes
  • Added unit tests for session helper

Test

  • Ran the Copy Phrase task and confirmed that the session output was consistent with previously generated data.
  • Used the session tools on the generated output to confirm that the session helper was still working correctly and that the output was correct.
  • Ran unit tests.

@lawhead lawhead requested a review from tab-cmd April 6, 2021 21:42
Copy link
Contributor

@tab-cmd tab-cmd left a comment

Choose a reason for hiding this comment

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

Still testing locally, but this is enough to get you rolling! Great refactoring effort here!

We should add session to the glossary in this PR - this is the latest from my last PR: https://github.com/CAMBI-tech/BciPy/blob/bids-trigger-fix/README.md#glossary

The glossary terms themselves are negotiable (ex. mode vs paradigm) but we should document them and make tickets to update as needed!

from collections import Counter


class StimSequence:
Copy link
Contributor

Choose a reason for hiding this comment

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

We can call this an inquiry I think?


def __init__(self,
stimuli: List[str],
eeg_len: int,
Copy link
Contributor

Choose a reason for hiding this comment

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

We could make this a little more generic. data_len.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was looking through the usage and what this is referring to is the number of channels in the EEG data. This is going to be the same value for all Inquiries, so I'm not sure it makes sense to store this here. If anything it should be a Session variable, but I'm wondering if it even pertains to sessions at all. It seems like the concern of session-related data should be around what was presented and how decisions were made. Maybe this parameter should be removed. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, let's remove it. I think it was used for debugging at one point.

def __init__(self,
stimuli: List[str],
eeg_len: int,
timing_sti: List[float],
Copy link
Contributor

Choose a reason for hiding this comment

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

timing may be sufficient as a name

target_info: List[str],
target_letter: str,
current_text: str,
copy_phrase: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be optional in the case of other tasks (free_spell). Perhaps, target_text?

self.copy_phrase = copy_phrase
self.next_display_state = next_display_state

# TODO: refactor for multimodal; List of Evidences?
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that idea. We can make another ticket for that if you'd like

'lm_evidence': dict(zip(alphabet, self.lm_evidence)),
'eeg_evidence': dict(zip(alphabet, self.eeg_evidence)),
'likelihood': likelihood,
'most_likely': dict(Counter(likelihood).most_common(5))
Copy link
Contributor

Choose a reason for hiding this comment

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

implement n here but rename to most_likely or something related

def __init__(self,
save_location: str,
session_type: str = 'Copy Phrase',
paradigm: str = 'RSVP'):
Copy link
Contributor

Choose a reason for hiding this comment

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

mode

],
[
"F",
1.984226447995752
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a test, we could reduce this to a few inquiries? It could reduce the difficulty in looking over this data in tests

{
"session": "data/default/test_user_001/test_user_001_RSVP_Copy_Phrase_Wed_17_Mar_2021_17hr11min05sec_-0700",
"session_type": "Copy Phrase",
"paradigm": "RSVP",
Copy link
Contributor

Choose a reason for hiding this comment

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

Wherever we write this it should be mode

@@ -0,0 +1,2431 @@
{
"session": "data/default/test_user_001/test_user_001_RSVP_Copy_Phrase_Wed_17_Mar_2021_17hr11min05sec_-0700",
"session_type": "Copy Phrase",
Copy link
Contributor

@tab-cmd tab-cmd Apr 8, 2021

Choose a reason for hiding this comment

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

We might rename this to task

@lawhead
Copy link
Collaborator Author

lawhead commented Apr 12, 2021

I like the naming suggestions. They make the code/data a lot more readable and consistent.

@@ -60,7 +60,7 @@ To use all the goodies locally (including the GUI and demo scripts)
If wanting the latest version from PyPi:
1. `pip install bcipy`

Alternatley, if [Make](http://www.mingw.org/) is installed, you may run the follow command to install:
Alternately, if [Make](http://www.mingw.org/) is installed, you may run the follow command to install:
Copy link
Contributor

@tab-cmd tab-cmd Apr 12, 2021

Choose a reason for hiding this comment

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

Thanks for catching the typos 🙈

@lawhead lawhead merged commit b3b3a84 into 1.5.1 Apr 12, 2021
@lawhead lawhead deleted the session-module branch April 12, 2021 22:16
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