-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from DuguidLab/develop
Add viariable contrast gratings
- Loading branch information
Showing
16 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,3 +137,4 @@ dmypy.json | |
.nova/ | ||
|
||
/devices/ | ||
visiomode_data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ | |
def run(): | ||
"""Application entry point.""" | ||
visiomode.core.Visiomode() | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file is part of visiomode. | ||
# Copyright (c) 2022 Constantinos Eleftheriou <[email protected]> | ||
# Distributed under the terms of the MIT Licence. | ||
|
||
import random | ||
import pygame as pg | ||
|
||
import visiomode.stimuli as stimuli | ||
import visiomode.stimuli.grating as grating | ||
|
||
|
||
class VariableContrastGrating(grating.Grating): | ||
form_path = "" | ||
|
||
def __init__(self, background, contrasts=(0, 0.06, 0.12, 0.25, 0.5, 1.0), **kwargs): | ||
super().__init__(background, **kwargs) | ||
|
||
self.contrasts = contrasts | ||
self.sinusoid_array = grating.Grating._sinusoid( | ||
self.width, self.height, self.period | ||
) | ||
|
||
self.generate_new_trial() | ||
|
||
def generate_new_trial(self): | ||
self.trial_contrast = random.choice(self.contrasts) | ||
|
||
_grating = stimuli.grayscale_array(self.sinusoid_array, self.trial_contrast) | ||
self.image = pg.surfarray.make_surface(_grating) | ||
self.rect = self.image.get_rect() | ||
self.area = self.screen.get_rect() | ||
|
||
def get_details(self): | ||
return {"trial_contrast": self.trial_contrast} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This file is part of visiomode. | ||
# Copyright (c) 2022 Constantinos Eleftheriou <[email protected]> | ||
# Distributed under the terms of the MIT Licence. | ||
|
||
import random | ||
import pygame as pg | ||
|
||
import visiomode.stimuli as stimuli | ||
import visiomode.stimuli.grating as grating | ||
import visiomode.stimuli.moving_grating as moving_grating | ||
|
||
|
||
class VariableContrastMovingGrating(moving_grating.MovingGrating): | ||
form_path = "" | ||
|
||
def __init__(self, background, contrasts=(0, 0.06, 0.12, 0.25, 0.5, 1.0), **kwargs): | ||
super().__init__(background, **kwargs) | ||
|
||
self.contrasts = contrasts | ||
self.sinusoid_array = grating.Grating._sinusoid( | ||
self.width, self.height, self.period | ||
) | ||
|
||
self.generate_new_trial() | ||
|
||
def generate_new_trial(self): | ||
self.trial_contrast = random.choice(self.contrasts) | ||
|
||
_grating = stimuli.grayscale_array(self.sinusoid_array, self.trial_contrast) | ||
self.image = pg.surfarray.make_surface(_grating) | ||
self.rect = self.image.get_rect() | ||
self.area = self.screen.get_rect() | ||
|
||
def get_details(self): | ||
return {"trial_contrast": self.trial_contrast} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters