예제 #1
0
 def _check_com_config(self):
     comports = {
         'BPOD': self.COM['BPOD'],
         'ROTARY_ENCODER': None,
         'FRAME2TTL': None
     }
     logger.debug(f"COMPORTS: {str(self.COM)}")
     if not self.COM['ROTARY_ENCODER']:
         comports['ROTARY_ENCODER'] = strinput(
             "RIG CONFIG",
             "Please insert ROTARY ENCODER COM port (e.g. COM9): ",
             default='COM')
         logger.debug("Updating comport file with ROTARY_ENCODER port " +
                      f"{comports['ROTARY_ENCODER']}")
         self.create_bpod_comport_file(self.BPOD_COMPORTS_FILE, comports)
         self.COM = comports
     if not self.COM['FRAME2TTL']:
         comports['FRAME2TTL'] = strinput(
             "RIG CONFIG",
             "Please insert FRAME2TTL COM port (e.g. COM9): ",
             default='COM')
         logger.debug("Updating comport file with FRAME2TTL port " +
                      f"{comports['FRAME2TTL']}")
         self.create_bpod_comport_file(self.BPOD_COMPORTS_FILE, comports)
         self.COM = comports
예제 #2
0
def ask_project(subject_name, one=None):
    if subject_name == "_iblrig_test_mouse":
        log.info(
            f"Test mouse detected Project for {subject_name}: _iblrig_test_project"
        )
        return "_iblrig_test_project"
    one = one or ONE()
    projects = one.alyx.rest("subjects", "read",
                             subject_name)["session_projects"]
    if not projects:
        log.info(f"No Projects found for Subject {subject_name}: []")
        return None
    elif len(projects) == 1:
        log.info(
            f"One project found for subject {subject_name}: [{projects[0]}]")
        return projects[0]
    else:
        log.info(
            f"Multiple projects found for subject {subject_name}:{projects}")
        last_sessions = one.search(subject=subject_name, limit=10)
        last_project = one.alyx.rest("sessions", "read",
                                     last_sessions[0])["project"]
        title = "Select Project"
        prompt = str(projects)
        default = last_project
        out_proj = graph.strinput(title,
                                  prompt,
                                  default=default,
                                  nullable=True)
        if out_proj not in projects:
            return ask_project(subject_name, one=one)
        return out_proj
예제 #3
0
def check_params_comports(data: dict) -> dict:
    patch = {}
    for k in data:
        if 'COM' in k and not data[k]:
            newcom = strinput(
                "RIG CONFIG",
                f"Please insert {k.strip('COM_')} COM port (e.g. COM9): ",
                default='COM')
            patch.update({k: newcom})

    if patch:
        data.update(patch)
        update_params_file(data=patch)
        log.debug("Updating params file with: {patch}")

    return data
def ask_is_mock(settings_file_path: str = None) -> bool:
    out = None
    resp = graph.strinput(
        "Session type", "IS this a MOCK recording? (yes/NO)", default='NO', nullable=True)
    if resp is None:
        return ask_is_mock(settings_file_path)
    if resp.lower() in ['no', 'n', '']:
        out = False
    elif resp.lower() in ['yes', 'y']:
        out = True
    else:
        return ask_is_mock(settings_file_path)
    if settings_file_path is not None and out is not None:
        patch = {'IS_MOCK': out}
        patch_settings_file(settings_file_path, patch)
    return out
예제 #5
0
def ask_subject_project(subject: str, settings_file_path: str = None) -> float:
    import datetime
    import json

    from one.api import ONE

    one = ONE()
    all_subjects = list(one.alyx.rest("subjects", "list"))
    all_subjects.append({"dump_date": datetime.datetime.utcnow().isoformat()})

    fpath = None  # Find Subjects folder
    # Save json in Subjects folder

    with open(fpath, "w+") as f:
        f.write(json.dumps(all_subjects, indent=1))
        f.write("\n")
    # Load subjects from disk
    with open(fpath, "r") as f:
        all_subjects = json.loads(f.readlines())

    # Given Subject load 'session_projects'
    all_projects = {x["nickname"]: x["session_projects"] for x in all_subjects}
    projects = all_projects[subject]

    if not projects:
        return projects
    elif len(projects) == 1:
        return projects[0]
    else:
        resp = graph.strinput(
            "Select project",
            str(projects),
            default=projects[0],
            nullable=False,
        )
        return resp

    out = graph.numinput("Subject project",
                         f"{subject} project (gr):",
                         nullable=False)
    log.info(f"Subject weight {out}")
    if settings_file_path is not None:
        patch = {"SUBJECT_WEIGHT": out}
        patch_settings_file(settings_file_path, patch)
    return out
예제 #6
0
def ask_is_mock(settings_file_path: str = None) -> bool:
    out = None
    resp = graph.strinput(
        "Session type",
        "IS this a MOCK recording? (yes/NO)",
        default="NO",
        nullable=True,
    )
    if resp is None:
        return ask_is_mock(settings_file_path)
    if resp.lower() in ["no", "n", ""]:
        out = False
    elif resp.lower() in ["yes", "y"]:
        out = True
    else:
        return ask_is_mock(settings_file_path)
    if settings_file_path is not None and out is not None:
        patch = {"IS_MOCK": out}
        patch_settings_file(settings_file_path, patch)
    return out