Ejemplo n.º 1
0
def test_meta_analysis():
    outcome1 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('crime', 25, 25, effect_size=0.17, variance=0.03)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    outcome3 = Outcome('crime', 25, 25, effect_size=0.2, variance=0.01)
    outcome4 = Outcome('crime', 25, 25, effect_size=0.3, variance=0.025)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.5, variance=0.035)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome3, outcome4, outcome5])

    study_pool = StudyPool([study1, study2], outcome_label='crime')
    fe_effect_size = study_pool.calculate_ivw_effect_size(method='fe')
    re_effect_size = study_pool.calculate_ivw_effect_size(method='re')
    fe_variance = study_pool.calculate_variance(method='fe')
    re_variance = study_pool.calculate_variance(method='re')

    meta_es_fe, meta_var_fe = study_pool.meta_analysis(method='fe')
    meta_es_re, meta_var_re = study_pool.meta_analysis(method='re')
    meta_es_auto, meta_var_auto = study_pool.meta_analysis(method='auto')

    assert math.isclose(fe_effect_size, meta_es_fe)
    assert math.isclose(re_effect_size, meta_es_re)
    assert math.isclose(re_effect_size, meta_es_auto)
    assert math.isclose(fe_variance, meta_var_fe)
    assert math.isclose(re_variance, meta_var_re)
    assert math.isclose(re_variance, meta_var_auto)
 def toStudy(self, checked):
     config.progress.rooms_visited += 1
     if self.sy is None:
         self.sy = Study()
         self.sy.show()
     else:
         self.sy.close()
         self.sy = None
Ejemplo n.º 3
0
def test_get_outcomes_by_label():
    outcome1 = Outcome('education', 30, 30)
    outcome2 = Outcome('education', 25, 25)
    outcome3 = Outcome('crime', 25, 25)
    study = Study("hello",
                  "Kris et al 2019",
                  outcomes=[outcome1, outcome2, outcome3])
    edu_outcome_list = study.get_outcomes_by_label('education')
    assert len(edu_outcome_list) == 2
    for outcome in edu_outcome_list:
        assert outcome.label == 'education'
Ejemplo n.º 4
0
def test_get_outcome_by_id():
    outcome1 = Outcome('education', 30, 30)
    outcome2 = Outcome('education', 25, 25)
    outcome1_id = outcome1.id
    outcome2_id = outcome2.id
    study = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])

    outcome_pull1 = study.get_outcome_by_id(outcome1_id)
    assert outcome_pull1 == outcome1
    outcome_pull2 = study.get_outcome_by_id(outcome2_id)
    assert outcome_pull2 == outcome2
    assert outcome_pull1 != outcome_pull2
Ejemplo n.º 5
0
def test_calculate_re():
    outcome1 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('crime', 25, 25, effect_size=0.17, variance=0.03)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    outcome3 = Outcome('crime', 25, 25, effect_size=0.2, variance=0.01)
    outcome4 = Outcome('crime', 25, 25, effect_size=0.3, variance=0.025)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.5, variance=0.035)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome3, outcome4, outcome5])

    study_pool = StudyPool([study1, study2], outcome_label='crime')
    tau_square = study_pool.calculate_re()
    assert math.isclose(tau_square, 0.064488371103462, rel_tol=1e6)
Ejemplo n.º 6
0
def test_calculate_q():
    outcome1 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('crime', 25, 25, effect_size=0.17, variance=0.03)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    outcome3 = Outcome('crime', 25, 25, effect_size=0.2, variance=0.01)
    outcome4 = Outcome('crime', 25, 25, effect_size=0.3, variance=0.025)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.5, variance=0.035)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome3, outcome4, outcome5])

    study_pool = StudyPool([study1, study2], outcome_label='crime')
    q, dof, p = study_pool.calculate_q()
    assert math.isclose(q, 16.1418558826177, rel_tol=1e6)
    assert dof == 4
    assert math.isclose(p, 0.00283460303776, rel_tol=1e6)
Ejemplo n.º 7
0
def test_calculate_ivw_effect_size():
    outcome1 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('crime', 25, 25, effect_size=0.17, variance=0.03)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    outcome3 = Outcome('crime', 25, 25, effect_size=0.2, variance=0.01)
    outcome4 = Outcome('crime', 25, 25, effect_size=0.3, variance=0.025)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.5, variance=0.035)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome3, outcome4, outcome5])

    study_pool = StudyPool([study1, study2], outcome_label='crime')
    fe_effect_size = study_pool.calculate_ivw_effect_size(method='fe')
    re_effect_size = study_pool.calculate_ivw_effect_size(method='re')
    assert math.isclose(fe_effect_size, 0.226086956521739, rel_tol=1e6)
    assert math.isclose(re_effect_size, 0.246115055719316, rel_tol=1e6)
Ejemplo n.º 8
0
def test_calculate_variance():
    outcome1 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('crime', 25, 25, effect_size=0.17, variance=0.03)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    outcome3 = Outcome('crime', 25, 25, effect_size=0.2, variance=0.01)
    outcome4 = Outcome('crime', 25, 25, effect_size=0.3, variance=0.025)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.5, variance=0.035)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome3, outcome4, outcome5])

    study_pool = StudyPool([study1, study2], outcome_label='crime')
    fe_variance = study_pool.calculate_variance(method='fe')
    re_variance = study_pool.calculate_variance(method='re')
    assert math.isclose(fe_variance, 0.003969754253308, rel_tol=1e6)
    assert math.isclose(re_variance, 0.017522267928502, rel_tol=1e6)
Ejemplo n.º 9
0
def test_remove_outcome():
    outcome1 = Outcome('education', 30, 30)
    outcome2 = Outcome('education', 25, 25)
    outcome1_id = outcome1.id
    study = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])

    exists = False
    for outcome in study.outcomes:
        if outcome.id == outcome1_id:
            exists = True
    assert exists

    study = study.remove_outcome(outcome1_id)
    for outcome in study.outcomes:
        assert outcome.id != outcome1_id
Ejemplo n.º 10
0
def test_init_():
    outcome1 = Outcome('education', 10, 10)
    outcome2 = Outcome('education', 20, 20)
    study = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2])
    assert study.note == 'hello'
    assert study.citation == 'Kris et al 2019'
    assert len(study.outcomes) == 2
Ejemplo n.º 11
0
    def create_object(self, node_type):
        """
        Returns an empty object of the node_type provided. It must be a valid object,
        or else an exception is raised. 
        
        Args:
            node_type (str): The type of object desired. 
        
        Returns:
            A object of the specified type. 
        """
        self.logger.debug("In create_object. Type: %s" % node_type)

        node = None
        if node_type == "project":
            from Project import Project
            self.logger.debug("Creating a Project.")
            node = Project()
        elif node_type == "visit":
            from Visit import Visit
            self.logger.debug("Creating a Visit.")
            node = Visit()
        elif node_type == "subject":
            from Subject import Subject
            self.logger.debug("Creating a Subject.")
            node = Subject()
        elif node_type == "sample":
            from Sample import Sample
            self.logger.debug("Creating a Sample.")
            node = Sample()
        elif node_type == "study":
            from Study import Study
            self.logger.debug("Creating a Study.")
            node = Study()
        elif node_type == "wgs_dna_prep":
            from WgsDnaPrep import WgsDnaPrep
            self.logger.debug("Creating a WgsDnaPrep.")
            node = WgsDnaPrep()
        elif node_type == "16s_dna_prep":
            from SixteenSDnaPrep import SixteenSDnaPrep
            self.logger.debug("Creating a SixteenSDnaPrep.")
            node = SixteenSDnaPrep()
        elif node_type == "16s_raw_seq_set":
            from SixteenSRawSeqSet import SixteenSRawSeqSet
            self.logger.debug("Creating a SixteenSRawSeqSet.")
            node = SixteenSRawSeqSet()
        elif node_type == "wgs_raw_seq_set":
            from WgsRawSeqSet import WgsRawSeqSet
            self.logger.debug("Creating a WgsRawSeqSet.")
            node = WgsRawSeqSet()
        elif node_type == "16s_trimmed_seq_set":
            from SixteenSTrimmedSeqSet import SixteenSTrimmedSeqSet
            self.logger.debug("Creating a SixteenSTrimmedSeqSet.")
            node = SixteenSTrimmedSeqSet()
        else:
            raise ValueError("Invalid node type specified: %" % node_type)

        return node
Ejemplo n.º 12
0
def test_set_outcome():
    outcome1 = Outcome('education', 30, 30, effect_size=0.1, variance=0.02)
    outcome2 = Outcome('education', 25, 25, effect_size=0.1, variance=0.02)
    outcome3 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    study1 = Study("hello", "Kris et al 2019", outcomes=[outcome1, outcome2, outcome3])
    outcome4 = Outcome('education', 30, 30, effect_size=0.1, variance=0.02)
    outcome5 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome6 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    outcome7 = Outcome('crime', 25, 25, effect_size=0.1, variance=0.02)
    study2 = Study("hello", "Kris et al 2018", outcomes=[outcome4, outcome5, outcome6, outcome7])

    studies = StudyPool([study1, study2], outcome_label='education')
    assert studies.outcome_label == 'education'
    assert len(studies.effect_sizes) == 3

    studies.set_outcome('crime')
    assert studies.outcome_label == 'crime'
    assert len(studies.effect_sizes) == 4
Ejemplo n.º 13
0
def gen_study(app_username, study_name):
    ctx.add_crumb('gen_study', 'main', sys.argv)
    print(ctx)
    study = Study(app_username=app_username, study_name=study_name, ctx=ctx)
    try:
        print(ctx.get_last_crumb())
        print(ctx.print_crumbs())
    except Exception:
        study.log.critical("Unexpected Error Encountered", ctx)
        print(f'fallback for error stack: {sys.exc_info()}')
    else:
        print("No issues, chief.")
Ejemplo n.º 14
0
 def create_study(self):
     """
     Returns an empty Study object. 
     
     Args:
         None
     
     Returns:
         A Study object. 
     """
     self.logger.debug("In create_study.")
     from Study import Study
     study = Study()
     return study
Ejemplo n.º 15
0
    def studies(self):
        """
        Returns an iterator of all studies connected to this project.
        """
        linkage_query = '"{}"[linkage.part_of]'.format(self.id)
        query = iHMPSession.get_session().get_osdf().oql_query

        for page_no in count(1):
            res = query(Project.namespace, linkage_query, page=page_no)
            res_count = res['result_count']

            for doc in res['results']:
                yield Study.load_study(doc)

            res_count -= len(res['results'])

            if res_count < 1:
                break
Ejemplo n.º 16
0
 def __init__(self):
     self.player = Player(self.screen, self.x, self.y)
     self.study = Study(self.screen, self.player, self.desks,
                        self.invincibility_flag)
     self.wl = WL(self.screen)
Ejemplo n.º 17
0
    def sty(self):

        localctx = SettingParser.StyContext(self, self._ctx, self.state)
        self.enterRule(localctx, 2, self.RULE_sty)
        self.styobj = Study()
        self._la = 0  # Token type
        try:
            self.enterOuterAlt(localctx, 1)
            self.state = 27
            self.match(SettingParser.STUDY)
            self.state = 28
            localctx.name = self.match(SettingParser.ID)
            self.state = 30
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 29
                self.match(SettingParser.NL)
                self.state = 32
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la == SettingParser.NL):
                    break

            self.state = 35
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 34
                self.field()
                self.state = 37
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not ((((_la) & ~0x3f) == 0 and
                         ((1 << _la) & ((1 << SettingParser.DATA) |
                                        (1 << SettingParser.VARDEF) |
                                        (1 << SettingParser.METADATA) |
                                        (1 << SettingParser.WRESL))) != 0)):
                    break

            self.state = 39
            self.match(SettingParser.END)
            self.state = 41
            self._errHandler.sync(self)
            _la = self._input.LA(1)
            while True:
                self.state = 40
                self.match(SettingParser.NL)
                self.state = 43
                self._errHandler.sync(self)
                _la = self._input.LA(1)
                if not (_la == SettingParser.NL):
                    break

            self._ctx.stop = self._input.LT(-1)
            stycopy = copy.deepcopy(self.styobj)
            styName = str(
                (None if localctx.name is None else localctx.name.text))
            S.studyMap[styName] = stycopy
        except RecognitionException as re:
            localctx.exception = re
            self._errHandler.reportError(self, re)
            self._errHandler.recover(self, re)
        finally:
            self.exitRule()
        return localctx
Ejemplo n.º 18
0
    def __init__(self):
        super(MainWindow, self).__init__()

        # noinspection PyCallingNonCallable
        self._nao = Nao()
        self._actionQueue = ActionModel(self, self._nao)
        self._LEDTime = QtCore.QTime.currentTime()

        Study.setup()

        #=======================================================================
        # Create Menus
        #=======================================================================
        menubar = self.menuBar()

        #-----------------------------File Menu---------------------------------#
        actConnect = QtGui.QAction(QtGui.QIcon(), '&Connect', self)
        actConnect.setShortcut('Ctrl+Alt+C')
        actConnect.triggered.connect(self.on_actConnect_triggered)

        actDisconnect = QtGui.QAction(QtGui.QIcon(), '&Disconnect', self)
        actDisconnect.setShortcut('Ctrl+Alt+D')
        actDisconnect.triggered.connect(self.on_actDisconnect_triggered)

        actExit = QtGui.QAction(QtGui.QIcon('images/exit.png'), '&Exit', self)
        actExit.setShortcut('Ctrl+Alt+X')
        actExit.setStatusTip('Exit application')
        actExit.triggered.connect(self.close)

        fileMenu = menubar.addMenu('File')
        fileMenu.addAction(actConnect)
        fileMenu.addAction(actDisconnect)
        fileMenu.addAction(actExit)

        #-----------------------------Load Menu---------------------------------#
        loadMenu = menubar.addMenu('Load')
        self._loadActions = []

        for i in range(len(Study.TASKS)):
            actLoad = QtGui.QAction(QtGui.QIcon(), "Load " + Study.TASKS[i][Study.TASK_NAME], self)
            actLoad.setShortcut("Ctrl+Alt+" + str(i + 1))
            actLoad.triggered.connect(self.on_actLoad_specific)
            loadMenu.addAction(actLoad)
            self._loadActions.append(actLoad)
        # END for

        #---------------------------Help Menu---------------------------------#
        actAboutBox = QtGui.QAction(QtGui.QIcon(), '&About', self)
        actAboutBox.triggered.connect(self.on_actAbout_triggered)
        actAboutBox.setShortcut("Ctrl+Alt+H")

        helpMenu = menubar.addMenu('Help')
        helpMenu.addAction(actAboutBox)

        #=======================================================================
        # Create Widgets
        #=======================================================================
        self._wgtMain = QtGui.QWidget(self)
        splitter = QtGui.QSplitter(self._wgtMain)
        splitter.setOrientation(QtCore.Qt.Horizontal)

        wgtLeft = QtGui.QWidget(splitter)
        wgtLeft.setMinimumWidth(350)

        splitterLeft = QtGui.QSplitter(wgtLeft)
        splitterLeft.setOrientation(QtCore.Qt.Vertical)

        self._wgtTimer = TimerWidget(splitterLeft)

        self._wgtCamera = CameraWidget(splitterLeft, self._nao.getCamera())
        self._wgtCamera.setMinimumHeight(385)
        self._wgtCamera.cameraChanged.connect(self._nao.getCamera().setCameraSource)
        self._wgtCamera.moveHead.connect(self.on__wgtCamera_moveHead)

        self._wgtActionList = ActionListWidget(splitterLeft, self._actionQueue)
        self._wgtActionList.setMinimumHeight(120)
        self._wgtActionList.editClicked.connect(self.on__wgtActionList_editClicked)

        layoutLeft = QtGui.QHBoxLayout(wgtLeft)
        layoutLeft.setMargin(0)
        layoutLeft.addWidget(splitterLeft)

        wgtRight = QtGui.QWidget(splitter)
        wgtRight.setMinimumWidth(380)

        splitterRight = QtGui.QSplitter(wgtRight)
        splitterRight.setOrientation(QtCore.Qt.Vertical)

        self._wgtTaskPanel = QtGui.QWidget(splitterRight)
        self._wgtTaskPanel.setMinimumHeight(400)

        self._layoutTaskPanel = QtGui.QStackedLayout(self._wgtTaskPanel)
        self._layoutTaskPanel.setMargin(0)
        for i in range(len(Study.TASKS)):
            Study.TASKS[i][Study.TASK_WIDGET].setParent(self._wgtTaskPanel)
            Study.TASKS[i][Study.TASK_WIDGET].setActionQueue(self._actionQueue)
            Study.TASKS[i][Study.TASK_WIDGET].setNao(self._nao)
            self._layoutTaskPanel.addWidget(Study.TASKS[i][Study.TASK_WIDGET])
        # END for

        widgetTextStiff = QtGui.QWidget(splitterRight)
        widgetTextStiff.setMinimumHeight(160)

        self._wgtSpeech = SpeechWidget(splitterRight)
        self._wgtSpeech.setInputFocus()
        self._wgtSpeech.inputCancelled.connect(self.setFocus)
        self._wgtSpeech.textSubmitted.connect(self.on__wgtSpeech_playSpeech)
        self._wgtSpeech.volumeChanged.connect(self._nao.setVolume)

        self._wgtMovement = MovementWidget(splitterRight)
        self._wgtMovement.setActionQueue(self._actionQueue)
        self._wgtMovement.setNao(self._nao)

        layoutTextStiff = QtGui.QHBoxLayout(widgetTextStiff)
        layoutTextStiff.setMargin(0)
        layoutTextStiff.addWidget(self._wgtSpeech)
        layoutTextStiff.addWidget(self._wgtMovement)

        layoutRight = QtGui.QHBoxLayout(wgtRight)
        layoutRight.setMargin(0)
        layoutRight.addWidget(splitterRight)

        layoutMain = QtGui.QHBoxLayout(self._wgtMain)
        layoutMain.addWidget(splitter)

        ##################################################
        # MainWindow
        ##################################################
        self.installEventFilter(self)
        self.setCentralWidget(self._wgtMain)
        self.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumSize(800, 600)
        self.setWindowIcon(QtGui.QIcon("images/icon.png"))
        self.setWindowTitle('NAO Robotic Controller')
        self.resize(1024, 768)
        self.show()
class Kitchen(Room):
    """
    Kitchen window to pop up when player navigates to the Kitchen Location
    """
    def __init__(self):
        if config.progress.message == True:
            super().__init__("Kitchen","message")
        else:
            super().__init__("Kitchen")

        self.setRoomButtons()
        self.setInteractionButtons()
        self.setEasterEggButtons()

    def setRoomButtons(self):
        # Setting up buttons for other room
        self.livingButton = QPushButton("Living Room", self)
        self.livingButton.setGeometry(self.width/2-self.button_width/2,self.image_height-self.button_height,self.button_width,self.button_height)
        self.livingButton.clicked.connect(self.toLiving)

        self.ly = None
        self.libraryButton = QPushButton("Library", self)
        self.libraryButton.setGeometry(self.width-self.button_width,self.image_height/2-self.button_height/2,100,50)
        self.libraryButton.clicked.connect(self.toLibrary)

        self.sy = None
        self.studyButton = QPushButton("Study", self)
        self.studyButton.setGeometry(self.left,self.image_height/2-self.button_height/2,self.button_width,self.button_height)
        self.studyButton.clicked.connect(self.toStudy)

        # Coffee Cabinet
        self.cabinet = None
        self.cabinetButton = QPushButton("", self)
        self.cabinetButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.cabinetButton.setGeometry(45,245,25,25)
        self.cabinetButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.cabinetButton.clicked.connect(self.toCabinet) 

        # Cutting Board
        self.cutting_window = None
        self.cuttingButton = QPushButton("", self)
        self.cuttingButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.cuttingButton.setGeometry(155,385,25,25)
        self.cuttingButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.cuttingButton.clicked.connect(self.toCutting) 

    def setInteractionButtons(self):
        # Setting up buttons to interact with
        bw = 25
        bh = 25
        # Fruit
        self.fruitButton = QPushButton("", self)
        self.fruitButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.fruitButton.setGeometry(320,535,bw,bh)
        self.fruitButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.fruitButton.clicked.connect(self.toUnused) 

        # Blender
        self.blenderButton = QPushButton("", self)
        self.blenderButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.blenderButton.setGeometry(112,350,bw,bh)
        self.blenderButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.blenderButton.clicked.connect(self.toBlender) 

        # Grinder
        self.grinderButton = QPushButton("", self)
        self.grinderButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.grinderButton.setGeometry(150,355,bw,bh)
        self.grinderButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.grinderButton.clicked.connect(self.toGrinder) 

        # Hidden buttons
        self.message_window = None
        self.messageButton = QPushButton("", self)
        self.messageButton.setIcon(QIcon("../images/icons/magnifying_glass.png"))
        self.messageButton.setGeometry(935,350,bw,bh)
        self.messageButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.messageButton.clicked.connect(self.toMessage) 
        self.messageButton.hide()

        if config.progress.message == True:
            self.messageButton.show()

    def setEasterEggButtons(self):
        # Setting up easter egg buttons
        # pans
        # griddle
        self.griddleButton = QPushButton("", self)
        self.griddleButton.setGeometry(400,200,10,10)
        self.griddleButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.griddleButton.clicked.connect(self.toGriddle)

        # frying
        self.fryingButton = QPushButton("", self)
        self.fryingButton.setGeometry(205,225,10,10)
        self.fryingButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.fryingButton.clicked.connect(self.toFrying)

        # sauce
        self.sauceButton = QPushButton("", self)
        self.sauceButton.setGeometry(65,215,10,10)
        self.sauceButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.sauceButton.clicked.connect(self.toSauce)

        # pancake
        self.pancakeButton = QPushButton("", self)
        self.pancakeButton.setGeometry(120,150,10,10)
        self.pancakeButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.pancakeButton.clicked.connect(self.toPancake)

        # stock
        self.stockButton = QPushButton("", self)
        self.stockButton.setGeometry(295,75,10,10)
        self.stockButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.stockButton.clicked.connect(self.toStock)

        # wok
        self.wokButton = QPushButton("", self)
        self.wokButton.setGeometry(540,120,10,10)
        self.wokButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.wokButton.clicked.connect(self.toWok)

        # pot
        self.potButton = QPushButton("", self)
        self.potButton.setGeometry(585,75,10,10)
        self.potButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.potButton.clicked.connect(self.toPot)

        # coffee
        self.babyButton = QPushButton("", self)
        self.babyButton.setGeometry(470,140,10,10)
        self.babyButton.setStyleSheet("background-color: rgba(0, 255, 255, 0);")
        self.babyButton.clicked.connect(self.toBaby)

    def toLiving(self, checked):
        config.progress.rooms_visited += 1
        self.close()

    def toLibrary(self, checked):
        config.progress.rooms_visited += 1
        if self.ly is None:
            self.ly = Library()
            self.ly.show()
        else:
            self.ly.close()
            self.ly = None

    def toStudy(self, checked):
        config.progress.rooms_visited += 1
        if self.sy is None:
            self.sy = Study()
            self.sy.show()
        else:
            self.sy.close()
            self.sy = None

    def toCabinet(self, checked):
        if self.cabinet is None:
            self.cabinet = Cabinet()
            self.cabinet.show()
        else:
            self.cabinet.close()
            self.cabinet = None

    def toCutting(self, checked):
        if self.cutting_window is None:
            self.cutting_window = Cutting()
            self.cutting_window.show()
        else:
            self.cutting_window.close()
            self.cutting_window = None

    def toBlender(self, checked):
        self.playAudio("blender")

    def toGrinder(self, checked):
        if "beans" in config.nancy.inventory:
            self.playAudio("grinding")
            config.nancy.inventory.append("grounds")
        else:
            self.playAudio("missing_something",nancy=True)

    def toMessage(self, checked):
        if self.message_window is None and config.progress.message == True:
            self.message_window = MessageInteraction()
            self.message_window.show()
        else:
            self.message_window.close()
            self.message_window = None

    def toGriddle(self, checked):
        playAudio("griddle")
        config.progress.pan_orchestra += 1

    def toFrying(self, checked):
        playAudio("frying")
        config.progress.pan_orchestra += 1

    def toSauce(self, checked):
        playAudio("sauce")
        config.progress.pan_orchestra += 1

    def toPancake(self, checked):
        playAudio("pancake")
        config.progress.pan_orchestra += 1

    def toStock(self, checked):
        playAudio("stock")
        config.progress.pan_orchestra += 1

    def toWok(self,checked):
        playAudio("wok")
        config.progress.pan_orchestra += 1

    def toPot(self,checked):
        playAudio("pot")
        config.progress.pan_orchestra += 1

    def toBaby(self,checked):
        self.playAudtio("coffee")
        config.progress.pan_orchestra += 1
Ejemplo n.º 20
0
from Study import Study
from matplotlib import pyplot as plt

is_plotHB_raw = 0
is_plot2lvl = 1
is_plotHB_filt= 0

# Initialize data
subject = 'Y'
# filename = './160804/Y_20160804_1152.TXT'
filename = './data/Thien_20160808_1170.TXT'

#filename = 'cQuyen.TXT'
study1 = Study(subject, filename)
marker = study1.dataset.event


# Just plot something
if is_plotHB_raw:
	df = study1.dataset.df
	plt.figure(1)
	plt.subplot(211), study1.plot_Hb(df.T, 'oxyHb', marker=marker)
	plt.subplot(212), study1.plot_Hb(df.T, 'deoHb', marker=marker)

# Plot 2 levels of mental workload
Hbtype = 'deoHb'
if is_plot2lvl:
	lvl1_trials = ['Trial 1', 'Trial 4'] # exe
	lvl2_trials = ['Trial 2', 'Trial 3'] # ima
	plt.figure()
	plt.subplot(352), study1.plot_mean_2lvl('Channel 1', Hbtype, lvl1_trials, lvl2_trials)
Ejemplo n.º 21
0
def test_append_outcome():
    study = Study("hello", "Kris et al 2019")
    study.append_outcome(Outcome('education', 10, 10))
    assert len(study.outcomes) == 1
    assert isinstance(study.outcomes[0], Outcome)
    assert study.outcomes[0].treat_n == 10
Ejemplo n.º 22
0
class Step1:
    step1_finisher = True

    width = 1200
    height = 800

    x = 275
    y = 240

    face = "back"

    desk = None
    desks = []

    invincibility_flag = False

    face_timer = 500

    screen = pygame.display.set_mode((width, height))

    front = pygame.image.load("resources/images/front.png")
    back = pygame.image.load("resources/images/back.png")
    board = pygame.image.load("resources/images/board.png")

    fpsClock = pygame.time.Clock()
    FPS = 100

    def __init__(self):
        self.player = Player(self.screen, self.x, self.y)
        self.study = Study(self.screen, self.player, self.desks,
                           self.invincibility_flag)
        self.wl = WL(self.screen)

    def Step1(self):

        while self.step1_finisher:
            for event in pygame.event.get():  #종료 이벤트
                if event.type == pygame.QUIT:
                    pygame.quit()
                    exit(0)
            pygame.display.update()

            self.screen.fill((135, 135, 135))

            self.screen.blit(self.board, (50, 100))

            for i in range(3):
                for j in range(3):
                    self.desk = Desk(self.screen, 275 + self.width / 5 * i,
                                     340 + self.height / 5 * j)
                    self.desk.draw()
                    self.desks.append(self.desk)

            self.study.study()

            self.door = Door(self.screen, 1050, 600)
            self.door.draw()
            self.player.move()

            if self.face_timer == 0:
                if self.face == "front":
                    self.face_timer = 500
                    self.face = "back"

                elif self.face == "back":
                    self.face_timer = 300
                    self.face = "front"
            if self.face == "front":
                self.screen.blit(self.front, (700, 50))
            elif self.face == "back":
                self.screen.blit(self.back, (700, 50))
            self.face_timer -= 1

            if self.face == "front":
                if self.study.invincibility_flag == True:
                    pass
                else:
                    self.wl.print()

            if self.player.colliderect(self.door):
                self.step1_finisher = False

    def Starting(self):
        while True:
            screen2 = Screen2(self.screen, self.width, self.height)
            screen2.Start()
            game_step1 = Step1()
            game_step1.Step1()
            game_step2 = Step2(self.screen, self.width, self.height)
            game_step2.Step2()
            game_step3 = Step3(self.screen, self.width, self.height)
            game_step3.Step3()
            game_step4 = Step4(self.screen, self.width, self.width)
            game_step4.Step4()
            clear = Clear(self.screen, self.width, self.height)
            clear.Start()
import numpy as np

is_plotHB_raw = 0
is_plot2lvl = 1
is_plotHB_filt= 0
is_savefile = 0


# Initialize data
subject = 'Thien_'
date = '20160808_'
filename = ['./data/' + subject + date + '1170.TXT',
			'./data/' + subject + date + '1171.TXT']
labelfile = './data/' + subject + date + 'protocol.TXT'

study1 = Study(subject, filename)
marker = study1.dataset.event

# read label
study1.dataset.read_label(labelfile)


lvl1_trials = study1.get_trial_fromlabel(labelclass='E')
lvl2_trials = study1.get_trial_fromlabel(labelclass='I')
lvllegend = ['Motor Execution', 'Motor Imagery']
print 'Motor Execution: ', lvl1_trials
print 'Motor Imagery: ', lvl2_trials


# Just plot something
if is_plotHB_raw:
Ejemplo n.º 24
0
print(temp.encode())
print(os.name)

with open('C:\\bing\\test.txt', mode='wb') as w:
    w.write(temp.encode())

with open('C:\\441zm903747.txt', mode='r') as r:
    print(r.read())

print(dir(sys))

print(sys.path)

sayhi.sayhi('li')

TEST = Study('li', 'lucy')
TEST.score = 60
TEST.test = 1

btest = isinstance(TEST, Person)
TEST.set_name('lucy')   
TEST.cry()
print(TEST._Study__fullname)

TEST.cal()

TEST = [1, 3, 4]
TEST = TEST[:-1]
#TEST.reverse()
TEST.pop()
print(TEST)