Ejemplo n.º 1
0
    def _process_args(self):
        # get args from kivy_overrides
        # and config variables from kivy
        args = kivy_overrides.args
        kconfig = kivy_overrides._get_config()

        # set up the subject and subj dir
        self._subj = args.subject

        self._subj_dir = os.path.join(kconfig['default_data_dir'], "data",
                                      self._name, self._subj)

        if not os.path.exists(self._subj_dir):
            os.makedirs(self._subj_dir)

        # check for fullscreen
        if args.fullscreen:
            self._fullscreen = False
        else:
            self._fullscreen = None

        if args.resolution:
            x, y = map(int, args.resolution.split("x"))
            self._resolution = x, y
        else:
            self._resolution = None

        # set the additional info from command line (sometimes useful)
        self._info = args.info

        # set whether to log csv
        self._csv = args.csv
Ejemplo n.º 2
0
    def _change_smile_subj(self, subj_id):
        kconfig = kivy_overrides._get_config()

        self._subject = subj_id
        self._subject_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, subj_id)

        self._session_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, subj_id,
                                         self._session)

        if not os.path.isdir(self._session_dir):
            os.makedirs(self._session_dir)

        os.rename(self._sysinfo_slog,
                  os.path.join(self._session_dir, "log_sysinfo_0.slog"))

        for filename, logger in self._state_loggers.itervalues():
            logger.close()
            os.remove(filename)

        self._reserved_data_filenames = set(os.listdir(self._session_dir))
        self._reserved_data_filenames_lock = threading.Lock()
        self._state_loggers = {}
        self._root_state.begin_log()
        return self._subject_dir
Ejemplo n.º 3
0
    def get_flip_interval(self):
        # hard code to 60 Hz for now
        kconfig = kivy_overrides._get_config()
        self.flip_interval = 1./kconfig['frame_rate']
        return self.flip_interval

        """    OLD WAY
Ejemplo n.º 4
0
    def get_flip_interval(self):
        # hard code to 60 Hz for now
        kconfig = kivy_overrides._get_config()
        self.flip_interval = 1./kconfig['frame_rate']
        return self.flip_interval

        """    OLD WAY
Ejemplo n.º 5
0
    def _change_smile_subj(self, subj_id):
        kconfig = kivy_overrides._get_config()

        for filename, logger in self._state_loggers.itervalues():
            logger.close()
            os.remove(filename)

        self._subj = subj_id

        self._subj_dir = os.path.join(kconfig['default_data_dir'], "data",
                                      self._name, subj_id)

        if not os.path.isdir(self._subj_dir):
            os.makedirs(self._subj_dir)

        self._reserved_data_filenames = set(os.listdir(self._subj_dir))
        self._reserved_data_filenames_lock = threading.Lock()
        self._state_loggers = {}
        self._root_state.begin_log()
Ejemplo n.º 6
0
    def _change_smile_subj(self, subj_id):
        kconfig = kivy_overrides._get_config()

        for filename, logger in self._state_loggers.itervalues():
            logger.close()
            os.remove(filename)

        self._subject = subj_id

        self._subject_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, subj_id)

        self._session_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, subj_id,
                                         self._session)

        if not os.path.isdir(self._session_dir):
            os.makedirs(self._session_dir)

        self._reserved_data_filenames = set(os.listdir(self._session_dir))
        self._reserved_data_filenames_lock = threading.Lock()
        self._state_loggers = {}
        self._root_state.begin_log()
Ejemplo n.º 7
0
    def _process_args(self):
        # get args from kivy_overrides
        # and config variables from kivy
        args = kivy_overrides.args
        kconfig = kivy_overrides._get_config()

        # set up the subject and subj dir
        self._subject = args.subject

        self._subject_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, self._subject)

        self._session_dir = os.path.join(kconfig['default_data_dir'],
                                         self._exp_name, self._subject,
                                         self._session)

        if not os.path.exists(self._session_dir):
            os.makedirs(self._session_dir)

        # check for fullscreen
        if args.fullscreen:
            self._fullscreen = False
        else:
            self._fullscreen = None

        if args.resolution:
            x, y = map(int, args.resolution.split("x"))
            self._resolution = x, y
        else:
            self._resolution = None

        # set the additional info from command line (sometimes useful)
        self._info = args.info

        # set whether to log csv
        self._csv = args.csv
Ejemplo n.º 8
0
    def __init__(self,
                 fullscreen=None,
                 resolution=None,
                 scale_box=None,
                 scale_up=False,
                 scale_down=False,
                 background_color=None,
                 name="SMILE",
                 debug=False,
                 Touch=None,
                 show_splash=True):

        self._platform = platform
        self._exp_name = name
        self._session = time.strftime("%Y%m%d_%H%M%S")
        self._debug = debug
        self._process_args()

        # handle fullscreen and resolution before Window is imported
        if fullscreen is not None:
            self._fullscreen = fullscreen
        self._resolution = self._resolution or resolution

        # set scale box
        scale._set_scale_box(scale_box=scale_box,
                             scale_up=scale_up,
                             scale_down=scale_down)

        # process background color
        self._background_color = background_color

        # make custom experiment app instance
        #self._app = ExpApp(self)
        self._screen = Screen()
        self._app = None

        # set up instance for access throughout code
        self.__class__._last_instance = weakref.ref(self)

        # set up initial root state and parent stack
        # interacts with Meanwhile and UntilDone at top of experiment
        ss = Serial(name="EXPERIMENT BODY", parent=self)

        self._root_state.set_instantiation_context(self)
        self._parents = [self._root_state]
        if Touch is None:
            Touch = (platform == "android") or (platform == "ios")

        if show_splash:
            from startup import Splash
            Splash(Touch=Touch, parent=ss)

        if self._monitor:
            from startup import ConfigWindow
            ConfigWindow(parent=ss)

        self._sysinfo_slog = os.path.join(self._session_dir, "sysinfo.slog")
        self._sysinfo = kivy_overrides._get_config()
        self._sysinfo.update({
            "fullscreen": self._fullscreen,
            "data_time": self._session,
            "debug": self._debug,
            "resolution": self._resolution,
            "background_color": self._background_color,
            "scale_box": scale_box,
            "scale_up": scale_up,
            "scale_down": scale_down,
            "expname": name,
            "processor": pf.processor(),
            "python_version": pf.python_version(),
            "system": pf.system(),
            "version": version.__version__,
            "author": version.__author__,
            "email": version.__email__,
            "date_last_update": version.__date__,
            "uname": pf.uname()
        })

        # place to save experimental variables
        self._vars = {}
        self.__issued_refs = weakref.WeakValueDictionary()

        self._reserved_data_filenames = set(
            os.listdir(os.path.join(self._session_dir)))
        self._reserved_data_filenames_lock = threading.Lock()
        self._state_loggers = {}