<commit_before>#!/usr/bin/env python
"""Sinusoidal grating stimulus with complex control from metaPyroGUI

This demo illustrates a very easy way to exert complex control of
visual stimuli in an experimental setting.  A Vision Egg server is
started, which opens the display and will do all the drawing.  There
is a "meta-controller" which is served (via Pyro) to another program
which controls the stimuli.  The meta-controller can store information
in a higher-level format than the Controllers used on individual
instances of the Stimulus class.

You will need to have a Pyro Name Server running on your network for
this to work.  It comes with the Pyro distribution as a script in the
bin directory called ns.  Run it, run this script, and then run
metaPyroGUI.py from any computer on your network.

"""

# Copyright (c) 2002 <NAME>.  Distributed under the terms
# of the GNU Lesser General Public License (LGPL).

import sys
import VisionEgg.Core
import VisionEgg.Gratings
import VisionEgg.PyroHelpers
import Pyro.core

from metaPyroGUI import GratingMetaParameters

class GratingExperimentMetaController( Pyro.core.ObjBase ):
    """Encapsulates all parameters controlling a grating"""
    def __init__(self,presentation,grating_stimulus):
        self.server_close_callback = None
        Pyro.core.ObjBase.__init__(self)
        self.meta_params = GratingMetaParameters()
        if not isinstance(presentation,VisionEgg.Core.Presentation):
            raise ValueError("Expecting instance of VisionEgg.Core.Presentation")
        if not isinstance(grating_stimulus,VisionEgg.Gratings.SinGrating2D):
            raise ValueError("Expecting instance of VisionEgg.Gratings.SinGrating2D")
        self.p = presentation
        self.stim = grating_stimulus

        self.p.add_controller(self.stim,'on',VisionEgg.Core.FunctionController(during_go_func=self.on_function))

    def set_server_closed_instance(self,instance):
        self.server_closed_instance = instance

    def get_parameters(self):
        return self.meta_params

    def set_parameters(self, new_parameters):
        if isinstance(new_parameters, GratingMetaParameters):
            self.meta_params = new_parameters
        else:
            raise ValueError("Argument to set_parameters must be instance of GratingMetaParameters")
#        self.meta_params = new_parameters
        self.update()

    def on_function(self,t=-1.0): # default time to between trials time
        """Compute when the grating is on"""
        if t <= self.meta_params.pre_stim_sec:
            return 0 # not on yet
        elif t <= (self.meta_params.pre_stim_sec + self.meta_params.stim_sec):<commit_msg>Removed unused code<commit_after>#!/usr/bin/env python
"""Sinusoidal grating stimulus with complex control from metaPyroGUI

This demo illustrates a very easy way to exert complex control of
visual stimuli in an experimental setting.  A Vision Egg server is
started, which opens the display and will do all the drawing.  There
is a "meta-controller" which is served (via Pyro) to another program
which controls the stimuli.  The meta-controller can store information
in a higher-level format than the Controllers used on individual
instances of the Stimulus class.

You will need to have a Pyro Name Server running on your network for
this to work.  It comes with the Pyro distribution as a script in the
bin directory called ns.  Run it, run this script, and then run
metaPyroGUI.py from any computer on your network.

"""

# Copyright (c) 2002 <NAME>.  Distributed under the terms
# of the GNU Lesser General Public License (LGPL).

import sys
import VisionEgg.Core
import VisionEgg.Gratings
import VisionEgg.PyroHelpers
import Pyro.core

from metaPyroGUI import GratingMetaParameters

class GratingExperimentMetaController( Pyro.core.ObjBase ):
    """Encapsulates all parameters controlling a grating"""
    def __init__(self,presentation,grating_stimulus):
        Pyro.core.ObjBase.__init__(self)
        self.meta_params = GratingMetaParameters()
        if not isinstance(presentation,VisionEgg.Core.Presentation):
            raise ValueError("Expecting instance of VisionEgg.Core.Presentation")
        if not isinstance(grating_stimulus,VisionEgg.Gratings.SinGrating2D):
            raise ValueError("Expecting instance of VisionEgg.Gratings.SinGrating2D")
        self.p = presentation
        self.stim = grating_stimulus

        self.p.add_controller(self.stim,'on',VisionEgg.Core.FunctionController(during_go_func=self.on_function))

    def get_parameters(self):
        return self.meta_params

    def set_parameters(self, new_parameters):
        if isinstance(new_parameters, GratingMetaParameters):
            self.meta_params = new_parameters
        else:
            raise ValueError("Argument to set_parameters must be instance of GratingMetaParameters")
#        self.meta_params = new_parameters
        self.update()

    def on_function(self,t=-1.0): # default time to between trials time
        """Compute when the grating is on"""
        if t <= self.meta_params.pre_stim_sec:
            return 0 # not on yet
        elif t <= (self.meta_params.pre_stim_sec + self.meta_params.stim_sec):
{'fraction_non_alphanumeric': 0.06675670461122901, 'fraction_numerical': 0.003472892147404978, 'mean_word_length': 3.764705882352941, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1331976', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1396, 'n_words': 493}