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

added ssvep to cvep method #232

Merged
merged 3 commits into from
Aug 19, 2022
Merged

added ssvep to cvep method #232

merged 3 commits into from
Aug 19, 2022

Conversation

AidaFakhry
Copy link
Contributor

Overview

A method that uses the refresh rate on the monitor and returns a code for SSVEP. every frame of / on for x seconds.

Ticket

Ticket 2

Contributions

  • Created method that uses the refresh rate on the monitor and returns a code for SSVEP. every frame of / on for x seconds.

Test

  • Unit tested.

Documentation

Are documentation updates required? In-line, README, or documentation? Verify the updates you did here.

Changelog

Is the CHANGELOG.md updated with your detailed changes? N/a

Copy link
Collaborator

@lawhead lawhead left a comment

Choose a reason for hiding this comment

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

I don't understand what the returned list represents in the ssvep_to_cvep function and how the calling function would use the results. I would expect that for a given refresh_rate it would return the same number of items, but

ssvep_to_cvep(refresh_rate=50, flicker_rate=10)
=> [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]
ssvep_to_cvep(refresh_rate=50, flicker_rate=25)
=> [0, 0, 1, 1]

If the intent is to communicate a flash pattern, we need to know how much time each entry in the list represents, so the units are important to consider. For instance, if we are returning a pattern for 1 second display, the items in the list could each be 1hz worth of data (50 items for a 50hz refresh rate). Alternatively, this could be a tuple with the on/off duration in seconds . For the second example, this would be (0.5, 0.5) for half second off, followed by half second on.

@sci-tab, how would it be easiest to consume this data when writing displays?

@@ -679,3 679,25 @@ def get_fixation(is_txt: bool) -> str:
return ' '
else:
return DEFAULT_FIXATION_PATH


def ssvep_to_cvep(refresh_rate: int = 60, flicker_rate: float = 10.0):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need some documentation for this function to give a summary of what it's for (particularly if someone doesn't know what SSVEP and CVEP are abbreviations for), it's parameters (units?), etc.

Also, there should be a return type (List[float]), and the documentation should explain what this represents.


length_flicker = refresh_rate / flicker_rate

# determine if lenth_flickerr is an integer using .is_integer()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a typo in the comment: lenth_flickerr -> length_flicker. But you can probably just remove this comment since it's redundant with the code.


# determine if lenth_flickerr is an integer using .is_integer()
if not length_flicker.is_integer():
raise Exception("Provided flicker rate must divide into refresh rate.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

length_flicker is only used as a float to check the whether it's evenly divisible so we might want to immediately cast it as an int:

if length_flicker.is_integer():
    length_flicker = int(length_flicker)
else:
     raise Exception("Provided flicker rate must divide into refresh rate.")

t = 0
else:
t = 1
return test_array
Copy link
Collaborator

Choose a reason for hiding this comment

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

Python has a couple of list methods that may be helpful here. The operator can be used to concatenate lists ([1,2] [3,4] => [1,2,3,4]), and the * operator is a shortcut for constructing a list of consecutive elements with the same value ([0] * 3 => [0,0,0]).

Another observation is that we're basically just toggling between 0 (for even indices) and 1 (for odd indices). We can determine if a number is even or odd by using the modulus operator %.

So with all that, one way to shorten the above code is something like:

test_array = []
for i in range(length_flicker):
    test_array  = [i % 2] * length_flicker

@tab-cmd
Copy link
Contributor

tab-cmd commented Aug 15, 2022

I don't understand what the returned list represents in the ssvep_to_cvep function and how the calling function would use the results. I would expect that for a given refresh_rate it would return the same number of items, but

ssvep_to_cvep(refresh_rate=50, flicker_rate=10)
=> [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]
ssvep_to_cvep(refresh_rate=50, flicker_rate=25)
=> [0, 0, 1, 1]

If the intent is to communicate a flash pattern, we need to know how much time each entry in the list represents, so the units are important to consider. For instance, if we are returning a pattern for 1 second display, the items in the list could each be 1hz worth of data (50 items for a 50hz refresh rate). Alternatively, this could be a tuple with the on/off duration in seconds . For the second example, this would be (0.5, 0.5) for half second off, followed by half second on.

@sci-tab, how would it be easiest to consume this data when writing displays?

That is the intended output and how the VEP display would be able to use it. I'll pick it up from here and see if I can spot the issue!

@tab-cmd tab-cmd force-pushed the aida_test_branch branch 2 times, most recently from 3246299 to 71f91f7 Compare August 15, 2022 20:40
@tab-cmd tab-cmd requested a review from lawhead August 15, 2022 20:46
Aida Fakhry and others added 3 commits August 19, 2022 09:04
@tab-cmd tab-cmd merged commit 115f5e4 into 2.0.0rc2 Aug 19, 2022
@tab-cmd tab-cmd deleted the aida_test_branch branch August 19, 2022 16:28
tab-cmd added a commit that referenced this pull request Sep 26, 2022
Co-authored-by: Aida Fakhry <[email protected]>
Co-authored-by: Tab Memmott <[email protected]>
tab-cmd added a commit that referenced this pull request Oct 3, 2022
* add timer to prevent double clicking (#218)

* #181963356 ; added better alerting to inform users when fake data mode is on

* Added changelog entry

* Refactoring to reduce duplication

* #182040775 ; option to summarize session at the end of a copy phrase task

* Update README.md

High level GPT2 documentation added, word level prediction described, contact information added

* Matrix Display Fixes (#221)

* fixes bug with last stimuli lagging in matrix calibration, added entire grid flash before each inquiry

* Address PR comment   cleanup

Co-authored-by: Tab Memmott <[email protected]>

* Refactored session helper to generate spreadsheets without first creating a sqlite database

* ERP plotting improvements and MNE data support (#220)

* #182005453 ; added parameter for signal model path; updated initialization code to use this for typing tasks

* #182406904 ; Fix bug when generating a spreadsheet from active session data

* [Bug fix] Two presses needed to start copy phrase (#225)

* Documentation and formatting

* #182200897 ; check for internet connection and confirm before proceeding with the session

* Added logging for GPU information, if available

* Whitespace fix

* Added changes

* Move session validation to validate module; update internet connectivity test to work with VPN

* #182106570 ; added functionality for configuration channel specifications for a given device.

* Added a test mock to prevent a GUI interaction during testing

* Fix test issue by switching to a different acquisition client for mocking

* use a better default timeout (#228)

* #182776686 ; prevent widgets scrolling on parameters form

* Jitter (#233)

Jitter for calibration   parameter. copy phrase ip

cleanup stimuli tests

* User ID reset bug and cleanup (#235)

User id reset fix

* Add support for Tobii Nano (#234)

* Add support for Tobii Nano

* address PR feedback

* update changelog

* added ssvep to cvep method (#232)

Co-authored-by: Aida Fakhry <[email protected]>
Co-authored-by: Tab Memmott <[email protected]>

* #183037159 ; alert when using battery power

* Better documentation on return values and potential impacts

* VEP Display (#237)

* upgrade psychopy  (#239)

* ERP viz demo fix (#240)

* #175193924 infrastructure for changed parameters ; #183134229 Fixed issue with params_form rounding some float values ; #183133776  allow static offset to be input with more precision

* Remove unneeded parameters  (#241)

* signal model loaded log (#244)

better signal model logging

* Devices config update && BciPy running outside of root (#242)

* Refactor param changes GUI to use a scroll area for displaying a large number of changes

* Refinements; parameters changes start out collapsed if empty; minor refactorings

* #182408060 ; Ensure that spelled text is provided to the language model when using fake data

* Export the device used as a useable config file (#247)

* Convert: add BDF support and fix static offset bug (#246)

* #182031676 ; remove TCP-based acquisition code

* Added PR number to changelog

* Added function type information; better string representations of channel specs and device specs; removed unused code in tests

* Updated max_buffer_len parameter name for lsl_client

* fix rebase issue in parameters module

* Bug fixes: jitter, offline analysis, task complete alerting  (#250)

* Matrix Bug: fix for scp flashing (#252)

* Matrix documentation (#253)

Co-authored-by: lawhead <[email protected]>
Co-authored-by: Shijia Liu <37078018 [email protected]>
Co-authored-by: jcgangemi1 <87331189 [email protected]>
Co-authored-by: AidaFakhry <92689243 [email protected]>
Co-authored-by: Aida Fakhry <[email protected]>
Co-authored-by: Basak Celik <[email protected]>
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.

3 participants