Ejemplo n.º 1
0
    def init_rooms(self, frame):
        study = Study(frame)
        study.grid(row=0, column=0)

        hall = Hall(frame)
        hall.grid(row=0, column=9)

        lounge = Lounge(frame)
        lounge.grid(row=0, column=17)

        library = Library(frame)
        library.grid(row=6, column=0)

        stairs = Stairs(frame)
        stairs.grid(row=8, column=9)

        dining_room = DiningRoom(frame)
        dining_room.grid(row=9, column=16)

        billiard_room = BilliardRoom(frame)
        billiard_room.grid(row=12, column=0)

        conservatory = Conservatory(frame)
        conservatory.grid(row=19, column=0)

        ball_room = BallRoom(frame)
        ball_room.grid(row=17, column=8)

        kitchen = Kitchen(frame)
        kitchen.grid(row=18, column=18)
Ejemplo n.º 2
0
def b2p_p3_long(reduce_memory = False, behavioural = True):
    studyname = 'b2p_study'
    ages = 'young'
    paradigm = 'Todd P300'
    sr = 512
    nelec = 74
    groups = ['concussed']
    
    ###### Define all concussed
    concussed_ids = [
        '1088_2',
        '1100_2',
        '1101_2',
        '1111_2',
        '1119_2',
        '1125_2',
        '1127_2nd',
        '1128_2',
        '1130_2',
        '1131_2',
        '1132_2',
        '1133_2',
        '1138_2',
        '1140_2',
        '1150_2',
        '1152_f',
        '1153_2_f',
        '1157_2_f',
        '1166_2',
    ]
    
    subjects = {
        groups[0]: [
            '%s'%(i) for i in concussed_ids
        ]}
    
    conditions = {
        'Standard': '_DC Detrend_P3_std',
        'Frequency Deviant': '_DC Detrend_P3_1',
        'Duration Deviant': '_DC Detrend_P3_2',
        'Intensity Deviant': '_DC Detrend_P3_3',
    }
    
    cont_conditions = {
        'Standard': 10,
        'Frequency Deviant': 20,
        'Duration Deviant': 30,
        'Intensity Deviant': 40,
    }
    
    
    if not behavioural:
        return Study(studyname, paradigm, ages, sr, groups, subjects, conditions, reduce_memory, load_induced = False, nelec = nelec)
    else:
        df = pd.read_csv('./Data/%s/behaviour_demographics.csv'%(studyname), delimiter=',')
        df = df.loc[df['id'].isin(subjects[groups[0]]) | df['id'].isin(subjects[groups[1]])]

        return (Study(studyname, paradigm, ages, sr, groups, subjects, conditions, reduce_memory, load_induced = False, nelec = nelec), df)
Ejemplo n.º 3
0
    def test_add_experiment(self):
        study = Study(name="teststudy",
                      resourcePool={
                          "r1": [1, 2],
                          "r2": [0, 0, 7]
                      })

        p1 = {"a": 2, "b": 5}
        a1 = {"g": 0}
        e11 = TestExperiment1(p1, a1)
        e12 = TestExperiment1(p1, {})

        study.add_experiment(e11)
        self.assertTrue(e11 == list(study.experiments.values())[0])

        print("This should generate a warning of double add.")
        study.add_experiment(e12)
        self.assertTrue(e11 == list(study.experiments.values())[0])
        self.assertTrue(e12 == list(study.experiments.values())[0])
        self.assertTrue(len(study.experiments.values()) == 1)

        p2 = {"a": 1, "c": 2, "b": 5}
        e21 = TestExperiment1(p2, a1)
        study.add_experiment(e21)
        self.assertTrue(len(study.experiments.values()) == 2)
Ejemplo n.º 4
0
def model_run(base_path, project, study_name, override_output='', use_threading='False'):

    # set up script logging
    py_name = os.path.basename(__file__)
    util.setup_local_logging(base_path, py_name, label=study_name)
    start_time = dt.datetime.now()
    global study

    try:
        # --------------------------------------
        # Initialise and load data for the study
        # --------------------------------------
        logging.info("study_name = %s", study_name)
        logging.info("Thread variable is %s", use_threading)
        study_ng = Study(
            base_path=base_path,
            project=project,
            study_name=study_name,
            dst_region=dst_region,
            override_output=override_output,
            use_threading=use_threading)

        if use_threading == 'True':  # NB use_threading is a string so need to compare with string
            # -------------
            # Use Threading
            # -------------
            logging.info("THREADING")
            global lock
            num_worker_threads = num_threads
            lock = threading.Lock()
            with concurrent.futures.ThreadPoolExecutor(max_workers=num_worker_threads) as x:
                results = list(x.map(run_scenario, study.scenario_list))

        else:
            # WITHOUT Threads (simpler to debug):
            # ----------------------------------
            logging.info("NOT THREADING")
            print("study: ", study)
            print("study.scenario_list: ", study_ng.get_scenario_list())
            for scenario in study_ng.get_scenario_list():
                study_ng.run_scenario(scenario)

        study_ng.log_study_data()

        end_time = dt.datetime.now()
        duration = end_time - start_time
        print("***COMPLETED STUDY ***", study_name)
        logging.info("***COMPLETED STUDY %s ***", study_name)
        logging.info(" ********* Completed %i scenarios in %f **************", len(study_ng.scenario_list),
                     duration.seconds)
        logging.info(" ********* Time per Scenario is  %f **************", duration.seconds / len(study_ng.scenario_list))

    except:
        pass
        logging.exception('\n\n\n Exception !!!!!!')
        type, value, tb = sys.exc_info()
        traceback.print_exc()
        pdb.post_mortem(tb)
Ejemplo n.º 5
0
def get_studies_from_json():
    with open('ut-studies/studies.json', 'r') as f:
        studies_dict = json.load(f)
    studies = []
    for study in studies_dict:
        studies.append(Study(study['abbreviation'], study['tabb'], study['name'], study['type']))
    return studies
Ejemplo n.º 6
0
 def get_studies(self,
                 bind_to_patient=None,
                 offset=0,
                 limit=50,
                 orderby=None,
                 filter_attributes=None):
     study_list = []
     if type(filter_attributes) is not dict:
         filter_attributes = {}
     filter_attributes['limit'] = limit
     filter_attributes['offset'] = offset
     filter_attributes['orderby'] = orderby
     for json_study in self._make_request(path='studies',
                                          params=filter_attributes):
         # get patient object
         if bind_to_patient and type(bind_to_patient) is Patient:
             patient = bind_to_patient
         else:
             filter_patient = {
                 'PatientID':
                 get_from_nested_dict(json_study, ['00100020', 'Value', 0]),
                 'PatientName':
                 get_from_nested_dict(
                     json_study, ['00100010', 'Value', 0, 'Alphabetic']),
             }
             result = self.get_patients(limit=1,
                                        filter_attributes=filter_patient)
             patient = result[0] if len(result) > 0 else None
         # create study object
         study_list.append(
             Study(pacs=self, patient=patient, input_dict=json_study))
     return study_list
Ejemplo n.º 7
0
def postproc_action(args):
    study_path = os.path.abspath('.')
    study_name = os.path.basename(study_path)
    with action_error_handler(args.debug):
        study = Study(study_name, study_path)
        study.load()
        try:
            # Insert study path to load postproc functions
            sys.path.insert(0, study_path)
            import postproc
        except Exception as err:
            raise
            raise Exception("File 'postproc.py' not found in study directory.")
        create_results_table(postproc.POSTPROC_TABLE_FIELDS, study)

    _printer.indent_level = 0
    _printer.print_msg("Done.", "info")
Ejemplo n.º 8
0
    def test_acquire_and_release_resources(self):
        study = Study(name="teststudy",
                      resourcePool={
                          "r1": [1],
                          "r2": [0, 0, 7]
                      })
        p1 = {"a": 2, "b": 5}
        p2 = {"a": 1, "c": 2, "b": 5}
        e1 = TestExperiment1(p1, {})
        e2 = TestExperiment1(p2, {})
        study.add_experiment(e1)
        study.add_experiment(e2)

        self.assertTrue(len(study.resourcePool["r1"]) == 1)
        self.assertTrue(len(study.resourcePool["r2"]) == 3)

        res = study.wait_and_acquire_resources()
        e1._fill_resources(res)
        self.assertTrue(len(study.resourcePool) == 2)
        self.assertTrue(len(study.resourcePool["r1"]) == 0)
        self.assertTrue(len(study.resourcePool["r2"]) == 2)
        study.release_resources(e1)
        self.assertTrue(len(study.resourcePool) == 2)
        self.assertTrue(len(study.resourcePool["r1"]) == 1)
        self.assertTrue(len(study.resourcePool["r2"]) == 3)
Ejemplo n.º 9
0
def print_tree_action(args):
    study_path = os.path.abspath('.')
    study_name = os.path.basename(study_path)
    with action_error_handler(args.debug):
        study = Study(study_name, study_path)
        _printer.print_msg("Printing param tree...", "info")
        _printer.indent_level = 1
        study.param_file.print_tree()

    _printer.indent_level = 0
    _printer.print_msg("Done.", "info")
Ejemplo n.º 10
0
    def test_run_all(self):
        study = Study(name="teststudy",
                      resourcePool={
                          "r1": [1, 2],
                          "r2": [0, 0, 7]
                      })
        p1 = {"a": 2, "b": 5}
        p2 = {"a": 1, "c": 2, "b": 5}
        e1 = TestExperiment_w_name(p1, {})
        e2 = TestExperiment_w_name(p2, {})
        e1.name = "Test01"
        e2.name = "Test02"
        study.add_experiment(e1)
        study.add_experiment(e2)

        self.assertTrue(len(study.resourcePool) == 2)
        self.assertTrue(len(study.resourcePool["r1"]) == 2)
        self.assertTrue(len(study.resourcePool["r2"]) == 3)
        #print(study.resourcePool)
        study.run_all()
        time.sleep(1)
        #print(study.resourcePool)
        self.assertTrue(len(study.resourcePool) == 2)
        self.assertTrue(len(study.resourcePool["r1"]) == 2)
        self.assertTrue(len(study.resourcePool["r2"]) == 3)
Ejemplo n.º 11
0
def generate_action(args):
    study_path = os.path.abspath('.')
    study_name = os.path.basename(study_path)
    with action_error_handler(args.debug):
        study = Study(study_name, study_path)
        sb = StudyGenerator(study,
                            short_name=args.shortname,
                            build_once=args.build_once,
                            keep_onerror=args.keep_on_error,
                            abort_undefined=args.abort_undefined)
        r = None
        if args.local_remote is not None:
            r = get_remote(study_path, args.local_remote)
        sb.generate_cases(r)
    _printer.print_msg("Done.", "info")
Ejemplo n.º 12
0
 def add_dataset(self, dataset):
     try:
         if self.dicom_dataset.PatientID == dataset.PatientID:
             for x in self.studies:
                 try:
                     x.add_dataset(dataset)
                     logger.debug("Part of this study")
                     break
                 except Exception as e:
                     logger.debug("Not part of this study")
             else:
                 self.studies.append(Study(dicom_dataset=dataset))
         else:
             raise KeyError("Not the same PatientIDs")
     except Exception as e:
         logger.debug("trouble comparing adding study to patient", exc_info=e)
         raise KeyError("Not the same PatientIDs")
Ejemplo n.º 13
0
    def save_exp(self):
        study = Study(name="teststudy",
                      resourcePool={
                          "r1": [1, 2],
                          "r2": [0, 0, 7]
                      })
        p1 = {"a": 2, "b": 5}
        e1 = TestExperiment1(p1, {})
        study.add_experiment(e1)
        study.save_exp(e1)

        fn = self.exp_result_dir + get_id_for_dict(exp.parameters)
        path = pathlib.Path(fn)
        self.assertEquals((str(path), path.is_file()), (str(path), True))
def createStudy(studyData):
    #check that the studyData is valid
    if not ("name" in studyData and type(studyData["name"]) == str
            and len(studyData["name"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'name' (type=str and length>0)")
    #construct the study
    s = Study()
    s.name = studyData["name"]
    if "description" in studyData:
        s.description = studyData["description"]
    if "equipmentList" in studyData:
        s.equipmentList = equipment_db_access.loadEquipmentList(
            studyData["equipmentList"])
    #create the study
    StudyTable.put_item(Item=s.toDynamo())
    return s
 def getStudy(self):
     try:
         path = self.lineEditStudy.text()
         dirs = os.listdir(path)
         for mydir in dirs:
             _, ext = os.path.splitext(mydir)
             if ext == '.txt':
                 f = open(path + f'/{mydir}', "r")
                 lines = f.readlines()
                 name = lines[0].rstrip('\n')
                 rootDir = lines[1].rstrip('\n')
                 sensorDir = lines[2].rstrip('\n')
                 return Study(name, rootDir, sensorDir)
     except TypeError as e:
         msg = QtWidgets.QMessageBox()
         msg.setWindowTitle("Error")
         msg.setText(f"Error detected : {e}")
         msg.setIcon(QtWidgets.QMessageBox.Warning)
         msg.exec()
     except AttributeError as e:
         msg = QtWidgets.QMessageBox()
         msg.setWindowTitle("Error")
         msg.setText(f"Error detected : {e}, path invalid")
         msg.setIcon(QtWidgets.QMessageBox.Warning)
         msg.exec()
     except PermissionError as e:
         msg = QtWidgets.QMessageBox()
         msg.setWindowTitle("Error")
         msg.setText(f"Error detected : {e}, path invalid on your computer")
         msg.setIcon(QtWidgets.QMessageBox.Warning)
         msg.exec()
     except FileNotFoundError as e:
         msg = QtWidgets.QMessageBox()
         msg.setWindowTitle("Error")
         msg.setText(f"Error detected : {e}, folder invalid")
         msg.setIcon(QtWidgets.QMessageBox.Warning)
         msg.exec()
Ejemplo n.º 16
0
def delete_action(args):
    study_path = os.path.abspath('.')
    study_name = os.path.basename(study_path)
    with action_error_handler(args.debug):
        study = Study(study_name, study_path, load_param_file=False)
        study.load()
        _printer.print_msg("Selected %d cases to delete..." % study.nof_cases,
                           "info")
        if args.yes:
            opt = 'y'
        else:
            _printer.print_msg("Are you sure to delete?[Y,y]: ",
                               "input",
                               end="")
            opt = raw_input("")
        if opt in ['y', 'Y']:
            _printer.print_msg("Deleting study files...", "info")
            study.delete()
        else:
            _printer.print_msg("Delete aborted.", "info")
    _printer.print_msg("Done.", "info")
def loadStudy(studyData):
    """Returns a Study object for the given data"""
    #check that the studyData is valid
    if not ("studyId" in studyData and type(studyData["studyId"]) == str
            and len(studyData["studyId"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'studyId' (type=str and length>0)")
    if not ("name" in studyData and type(studyData["name"]) == str
            and len(studyData["name"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'name' (type=str and length>0)")
    if not ("status" in studyData and type(studyData["status"]) == str
            and len(studyData["status"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'status' (type=str and length>0)")
    if not ("dateCreated" in studyData and type(studyData["dateCreated"])
            == str and len(studyData["dateCreated"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'dateCreated' (type=str and length>0)")
    if not ("dateModified" in studyData and type(studyData["dateModified"])
            == str and len(studyData["dateModified"]) > 0):
        raise errors.BadRequestError(
            "Study must have attribute 'dateModified' (type=str and length>0)")
    if not ("archived" in studyData and type(studyData["archived"]) == bool):
        raise errors.BadRequestError(
            "Study must have attribute 'archived' (type=bool)")
    #construct the study
    s = Study()
    s.studyId = studyData["studyId"]
    s.name = studyData["name"]
    if "description" in studyData:
        s.description = studyData["description"]
    s.status = studyData["status"]
    s.dateCreated = studyData["dateCreated"]
    s.dateModified = studyData["dateModified"]
    s.archived = studyData["archived"]
    if "deploymentList" in studyData:
        s.deploymentList = deployment_db_access.loadDeploymentList(
            studyData["deploymentList"])
    if "equipmentList" in studyData:
        s.equipmentList = equipment_db_access.loadEquipmentList(
            studyData["equipmentList"])
    if "resourceList" in studyData:
        s.resourceList = studyData["resourceList"]
    return s
Ejemplo n.º 18
0
def state_action(args,
                 action,
                 allowed_states,
                 action_func,
                 output_handler,
                 action_progress_bar=None):
    study_path = os.path.abspath('.')
    study_name = os.path.basename(study_path)
    study = Study(study_name, study_path)
    study.load()
    if args.selector is None:
        case_selector = "*"
    else:
        case_selector = args.selector
    with action_error_handler(args.debug):
        cases_idx = decode_case_selector(case_selector, study.nof_cases)
        study.set_selection(cases_idx)
        remote_cases, no_remote_cases = get_cases_byremote(cases_idx,
                                                           study,
                                                           allowed_states,
                                                           remote=args.remote)
    nof_remotes = len(remote_cases.keys())
    nof_selected_cases = len(cases_idx)
    nof_no_remote_cases = len(no_remote_cases)
    nof_remote_cases = nof_selected_cases - nof_no_remote_cases

    # Print info about the state of selected cases
    _printer.print_msg(
        "Selected {} cases for action '{}':".format(nof_selected_cases,
                                                    action), "info")
    _printer.indent_level = 1
    if nof_no_remote_cases:
        _printer.print_msg(
            "- {} cases with no associated remote...".format(
                nof_no_remote_cases), "info")
    if nof_remote_cases > 0:
        _printer.print_msg(
            "- {} cases in ({} remotes)':".format(
                len(cases_idx) - len(no_remote_cases), nof_remotes), "info")
        for counter, (remote_name,
                      remote_info) in enumerate(remote_cases.items()):
            _printer.indent_level = 2
            _printer.print_msg(
                "[{}] '{}': {} cases selected".format(
                    counter + 1, remote_name, remote_info["nof_selected"]),
                "info")
            for status, case_info in remote_info["cases"].items():
                if case_info["nof"] > 0:
                    _printer.indent_level = 3
                    _printer.print_msg("{}: {}".format(status,
                                                       case_info["nof"]))
            nof_excluded_cases = remote_info["nof_selected"] - remote_info[
                "nof_valid"]
            if nof_excluded_cases > 0:
                _printer.print_msg(
                    "Found {} cases with a state not in {}. They will be ignored."
                    .format(nof_excluded_cases, allowed_states))

    # The cases which has no remote are the ones to upload
    if action == "upload":
        with action_error_handler(args.debug):
            _printer.indent_level = 0
            r = get_remote(study_path, args.remote)
            remote_cases = {}
            remote_cases[r.name] = {
                "nof_valid": len(no_remote_cases),
                "valid_cases": no_remote_cases
            }

    # Iterate over remotes
    for remote_name, remote_info in remote_cases.items():
        # If not valid cases to perform action go to next remote
        if remote_info["nof_valid"] == 0:
            continue
        # Continue to the next remote if there are not cases to download
        study.set_selection(remote_info["valid_cases"])
        _printer.print_msg("", "blank")
        remote_header = "[{}: '{}']".format(action.capitalize(), remote_name)
        _printer.indent_level = 0
        _printer.print_msg(remote_header, "info")
        _printer.indent_level = 1

        # Ask for confirmation
        if args.yes:
            opt = 'y'
        else:
            _printer.print_msg("Perform action '{}' on '{}'?[Y,y]: ".format(
                action, remote_name),
                               "input",
                               end="")
            opt = raw_input("")
        if not opt in ['y', 'Y']:
            _printer.print_msg("Skipping...")
            _printer.print_msg("", "blank")
            continue
        with action_error_handler(args.debug):
            r = get_remote(study_path, remote_name)
            connect(r, debug=args.debug, progress_bar=action_progress_bar)
            sm = remote.StudyManager(study)
            # The update affect all cases not only the selection
            sm.update_status(r)
            # Upload is not affected by update_status()
            if action == "upload":
                valid_cases = remote_cases[remote_name]["valid_cases"]
            else:
                remote_cases_updated, no_remote_cases = get_cases_byremote(
                    cases_idx, study, allowed_states, remote=remote_name)
                valid_cases = remote_cases_updated[remote_name]["valid_cases"]
            output = ""
            if valid_cases:
                _printer.print_msg(
                    "Performing action '{}' on {} cases...".format(
                        action, len(valid_cases)), "info")
                study.set_selection(valid_cases)
                output = action_func(sm, r)
                output_handler(output)
            else:
                _printer.print_msg("No jobs running found. Skipping...")
        r.close()
    _printer.print_msg("", "blank")
    _printer.indent_level = 0
    if sum([r["nof_valid"] for r in remote_cases.values()]) == 0:
        _printer.print_msg("Nothing to do for action: '{}'".format(action),
                           "info")
    _printer.print_msg("Done.", "info")
Ejemplo n.º 19
0
    def get_study(self):
        study = Study()
        study.id = self.get_text_by_title('NCT Number')
        study.title = self.get_text_by_title('Brief Title')
        study.official_title = self.get_text_by_title('Official Title')
        study.brief_summary = self.get_text_by_title('Brief Summary')
        study.detailed_description = self.get_text_by_title(
            'Detailed Description')
        study.type = self.get_text_by_title('Study Type')
        study.phase = self.get_text_by_title('Study Phase')
        study.design = self.get_text_by_title('Study Design')
        study.condition = self.get_text_by_title('Condition')
        study.intervention = self.get_text_by_title('Intervention')
        study.arms = self.get_text_by_title('Study Arms')

        study.start_date = self.get_text_by_title('Start Date')
        study.completion_date = self.get_text_by_title('Completion Date')

        study.estimated_enrollment = self.get_text_by_title(
            'Estimated Enrollment')
        study.eligibility_criteria = self.get_text_by_title(
            'Eligibility Criteria')
        study.sex_gender = self.get_text_by_title('Sex/Gender')
        study.ages = self.get_text_by_title('Ages')
        study.study_population = self.get_text_by_title('Study Population')
        study.study_groups = self.get_text_by_title('Study Groups/Cohorts')
        study.enrollment_countries = self.get_text_by_title(
            'Listed Location Countries')

        study.responsible_party = self.get_text_by_title('Responsible Party')
        study.sponsor = self.get_text_by_title('Study Sponsor')
        study.collaborators = self.get_text_by_title('Collaborators')
        study.investigators = self.get_text_by_title('Investigators')
        return study
def check_all_unfeasible_options(solver_path, study_path, years_error,
                                 years_warning):
    output_path = study_path / 'output'

    st = Study(str(study_path))
    st.check_files_existence()

    # Option error-verbose : mps and error
    st.set_variable(variable="include-unfeasible-problem-behavior",
                    value="error-verbose",
                    file_nick_name="general")
    result_code = launch_solver(solver_path, study_path)
    assert result_code != 0
    check_log_values(output_path, years_error, "fatal")
    check_mps_availability(output_path, years_error)

    # Option error-dry : no mps and error
    st.set_variable(variable="include-unfeasible-problem-behavior",
                    value="error-dry",
                    file_nick_name="general")
    result_code = launch_solver(solver_path, study_path)
    assert result_code != 0
    check_log_values(output_path, years_error, "fatal")
    check_no_mps_available(output_path)

    # Option warning-verbose : mps and warning
    st.set_variable(variable="include-unfeasible-problem-behavior",
                    value="warning-verbose",
                    file_nick_name="general")
    result_code = launch_solver(solver_path, study_path)
    assert result_code == 0
    check_log_values(output_path, years_warning, "warns")
    check_mps_availability(output_path, years_warning)

    # Option warning-dry : no mps and warning
    st.set_variable(variable="include-unfeasible-problem-behavior",
                    value="warning-dry",
                    file_nick_name="general")
    result_code = launch_solver(solver_path, study_path)
    assert result_code == 0
    check_log_values(output_path, years_warning, "warns")
    check_no_mps_available(output_path)
        if (len(blocks) == 6 and slowdown and compensation is not None
                and compensation_descriptor and version and prolific_pid):
            return Participant(
                version=version,
                user_agent=user_agent,
                compensation=compensation,
                compensation_descriptor=compensation_descriptor,
                slowdown=slowdown,
                blocks=blocks,
                keyset=keyset,
                prolific_pid=prolific_pid,
                model_name=model_name,
                sex=metadata["sex"],
                age=(int(metadata["age"]) if metadata["age"] else None),
            )
    raise ParticipantException(prolific_pid, "missing-data")


_participants = []
_exceptions = []
_metadata = load_participant_metadata()
for file in get_data_file_paths():
    try:
        participant = get_participant_for_file(file, _metadata)
        _participants.append(participant)
    except ParticipantException as ex:
        _exceptions.append(ex)

echo_study = Study(_participants, _exceptions)
echo_study.print_summary()
Ejemplo n.º 22
0
input("")
print('"Well, this week\'s assignment will be: {0}"'.format(active_project.name))
input("")
print("Let's see whether our students are able to understand it right away.")
input("")
for i in codecool_bp.students:
    i.understanding_project(active_project.understand_assignment(i))
input("")
codecool_bp.drink_coffee(50)
input("")
print("If you have any questions regarding the project, ask away! - says {0}.".format(active_mentor.nick_name))
input("")
for _ in range(3):
    stud = random.choice(codecool_bp.students)
    event = Study(2, "This was indeed a good question. Skill level: ",
                  -3, "{0} asks THE question bugging ".format(stud.full_name) +
                  ("him" if stud.gender == "Male" else "her") + " for so long! Energy level: ")
    stud.process(event.process_event())
    print(active_project.questions.pop(random.randrange(len(active_project.questions))))
    stud.process(event.process_study())
    print("\n")
input("")
codecool_bp.drink_coffee(50)
input("")
print("Do not worry, those who still do not understand will have a chance to discuss with the mentors after school.")
input("")
print('''It's noon already! Time surely flies when you are having fun! Let's have lunch, shall we?
It seems that some of the class is not hungry. They can pass time by playing some table football!''')
input("")
for pers in random.sample(codecool_bp.students + codecool_bp.mentors, 5):
    if pers.hungry:
Ejemplo n.º 23
0
def b2p_p3(reduce_memory = False, behavioural = True):
    studyname = 'b2p_study'
    ages = 'young'
    paradigm = 'Todd P300'
    sr = 512
    nelec = 74
    groups = ['controls', 'concussed']
    
    ###### Define all controls
    controls_ids = list(range(1,28))
    
    ###### Define all concussed
    concussed_ids = [
        1079,
        1088,
        1100,
        1101,
        1102,
        1110,
        1111,
        1118,
        1119,
        1125,
        1127,
        1128,
        1129,
        1130,
        1131,
        1132,
        1133,
        1138,
        1140,
        1142,
        1150,
        1151,
        1152,
        1153,
        1157,
        1166,
    ]
    
    subjects = {groups[0]: [
            'mTBI_P%02d'%(i) for i in controls_ids
            ], 
        groups[1]: [
            '%d'%(i) for i in concussed_ids
        ]}
    
    conditions = {
        'Standard': '_P3_std',
        'Frequency Deviant': '_P3_1',
        'Duration Deviant': '_P3_2',
        'Intensity Deviant': '_P3_3',
    }
    
    cont_conditions = {
        'Standard': 10,
        'Frequency Deviant': 20,
        'Duration Deviant': 30,
        'Intensity Deviant': 40,
    }
    
    
    if not behavioural:
        return Study(studyname, paradigm, ages, sr, groups, subjects, conditions, reduce_memory, load_induced = False, nelec = nelec)#, picks = ['Cz', 'Pz', 'Fz'])
    else:
        df = pd.read_csv('./Data/%s/behaviour_demographics.csv'%(studyname), delimiter=',')
        df = df.loc[df['id'].isin(subjects[groups[0]]) | df['id'].isin(subjects[groups[1]])]

        return (Study(studyname, paradigm, ages, sr, groups, subjects, conditions, reduce_memory, load_induced = False, nelec = nelec), df)
Ejemplo n.º 24
0
 def study_widget(self):
     study = Study(_areas, _info_list)
     study.setContentsMargins(0, 0, 0, 0)
     return study
Ejemplo n.º 25
0
 def get_studies(self):
     response = self.connection.sword.get_resource(self.collection.href)
     entries = utils.get_elements(response.content, tag='entry')
     return [Study.from_entry(entry, dataverse=self) for entry in entries]
Ejemplo n.º 26
0
 def getStudy(self):
     name = self.lineEditName.text()
     rootDir = self.lineEditRootDir.text()
     sensorDir = self.lineEditSensorsDir.text()
     return Study(name, rootDir, sensorDir)
Ejemplo n.º 27
0
 def get_studies(self):
     response = self.connection.sword.get_resource(self.collection.href)
     entries = utils.get_elements(response.content, tag='entry')
     return [Study.from_entry(entry, dataverse=self) for entry in entries]
Ejemplo n.º 28
0
 def __init__(self, dicom_dataset=None):
     self.studies = list()
     self.dicom_dataset = dicom_dataset
     self.studies.append(Study(dicom_dataset=dicom_dataset))
Ejemplo n.º 29
0
            special_cases_codes.append(case.croho)
    print("Now searching for studies in downloaded CROHO registry...")
    for row in wsheet.iter_rows():
        if (row[2].value.find('Universiteit Twente') > -1 or str(row[6].value) in scraped_croho_codes)\
                and str(row[12].value).find('00-00-000') > -1\
                and row[6].value not in crohocodes:
            crohocodes.append(row[6].value)
            activeutstudies.append(row)
        else:
            for special in special_cases:
                if str(row[6].value) == special.croho and special.croho not in crohocodes:
                    crohocodes.append(special.croho)
                    special_cases_tuples.append((row, special))
    print("Searching complete.\n")
    res = []
    for row in activeutstudies:
        res.append(Study("", "", get_without_type_prefix(row[7].value), "Bachelor" if row[7].value[0:2] == "B " else "Master"))
    for tup in special_cases_tuples:
        res.append(Study("", "", tup[1].name, "Bachelor" if tup[0][7].value[0:2] == "B " else "Master"))
    abbr_gen = Abbreviation()
    abbr_gen.add_abbreviation(res)
    identical = compare(res)
    print("Process complete. The current list has been found to be " + "up to date." if identical else "outdated.")


def get_without_type_prefix(input: str):
    return input[2:len(input)]


read_croho_xlsx()