Beispiel #1
0
def create_subject(project_name,
                   subject_name: str = "_iblrig_test_mouse",
                   force=False):
    project_name = alyx2local_names.get(project_name, project_name)
    project_path = IBLRIG_PARAMS_FOLDER / project_name
    p = Project()
    print(f"Loading [{project_path}]")
    p.load(project_path)
    subject = p.find_subject(subject_name)
    if force or subject is None:
        subject = p.create_subject()
        subject.name = subject_name
        p.save(project_path)
        print(f"  Created subject: [{subject_name}]")
    # Create default subjects for project {project_name} if they don't exist
    if p.find_subject("_iblrig_test_mouse") is None:
        create_subject(project_name,
                       subject_name="_iblrig_test_mouse",
                       force=True)
    if p.find_subject("_iblrig_calibration") is None:
        create_subject(project_name,
                       subject_name="_iblrig_calibration",
                       force=True)

    return subject
Beispiel #2
0
 def _init_com(self) -> dict:
     logger.debug("Initializing COM ports")
     p = Project()
     p.load(str(Path(self.IBLRIG_PARAMS_FOLDER) / 'IBL'))
     out = None
     if Path(self.BPOD_COMPORTS_FILE).exists():
         logger.debug(
             f"Found COM port definition file: {self.BPOD_COMPORTS_FILE}")
         # If file exists open file
         with open(self.BPOD_COMPORTS_FILE, 'r') as f:
             out = json.load(f)
         # Use the GUI defined COM port for BPOD
         out['BPOD'] = p.boards[0].serial_port
         logger.debug(f".bpod_comports.json exists with content: {out}")
     else:
         logger.debug(f"NOT FOUND: COM ports definition file")
         # If no file exists create empty file
         comports = {
             'BPOD': None,
             'ROTARY_ENCODER': None,
             'FRAME2TTL': None
         }
         comports['BPOD'] = p.boards[0].serial_port
         out = comports
         logger.debug(f"Calling create with comports: {comports}")
         self.create_bpod_comport_file(self.BPOD_COMPORTS_FILE, comports)
     return out
Beispiel #3
0
def get_board_comport():
    iblproject_path = Path(path_helper.get_iblrig_params_folder()) / 'IBL'
    p = Project()
    p.load(str(iblproject_path))
    params_file = Path(
        path_helper.get_iblrig_params_folder()) / '.iblrig_params.json'
    if not params_file.exists():
        return p.boards[0].serial_port
    pars = load_params_file()
    if p.boards[0].serial_port != pars['COM_BPOD']:
        pars['COM_BPOD'] = p.boards[0].serial_port
        update_params_file(data=pars)
    return pars['COM_BPOD']
Beispiel #4
0
def get_board_name():
    iblproject_path = Path(path_helper.get_iblrig_params_folder()) / 'IBL'
    p = Project()
    p.load(str(iblproject_path))
    params_file = Path(
        path_helper.get_iblrig_params_folder()) / '.iblrig_params.json'
    if not params_file.exists():
        return p.boards[0].name
    pars = load_params_file()
    if p.boards[0].name != pars['NAME']:
        pars['NAME'] = p.boards[0].name
        update_params_file(data=pars)
    return pars['NAME']
    def __init__(self):
        """

        """

        GenericProject.__init__(self)

        self._name = ControlText('Project name')

        self.formset = ['_name', ' ']

        self._name.changed_event = self._name_changed_evt

        Project.__init__(self)
Beispiel #6
0
def pybpod_project_exists(project_name):
    project_name = alyx2local_names.get(project_name, project_name)
    project_path = IBLRIG_PARAMS_FOLDER / project_name
    p = Project()
    project_exists = None
    try:
        print(f"Checking existence of project [{project_name}] locally")
        p.load(project_path)
        project_exists = True
    except:  # noqa
        print(f"Project not found: [{project_path}]")
        project_exists = False

    return project_exists
Beispiel #7
0
def create_subject(iblproject_path, subject_name: str):
    p = Project()
    p.load(iblproject_path)
    if p.find_subject(subject_name) is None:
        subject = p.create_subject()
        subject.name = subject_name
        p.save(iblproject_path)
        print(f"Created subject: {subject_name}")
    else:
        subject = p.find_subject(subject_name)
        print(f"Skipping creation: Subject <{subject.name}> already exists")
Beispiel #8
0
def create_ibl_users(iblproject_path):
    p = Project()
    p.load(iblproject_path)
    if p.find_user('_iblrig_test_user') is None:
        user = p.create_user()
        user.name = '_iblrig_test_user'
        p.save(iblproject_path)
        print(f"Created: IBL default user <{user.name}>")
    else:
        user = p.find_user('_iblrig_test_user')
        print(f"Skipping creation: User <{user.name}> already exists")
Beispiel #9
0
def create_task(iblproject_path, task_name: str):
    p = Project()
    p.load(iblproject_path)
    task = p.find_task(task_name)
    # if task is None:
    task = p.create_task()
    task.name = task_name
    p.save(iblproject_path)
    print(f"Created task: {task_name}")
Beispiel #10
0
def config_task(iblproject_path, task_name: str):
    p = Project()
    p.load(iblproject_path)
    task = p.find_task(task_name)
    print(f"  Configuring task <{task.name}>")
    task._commands = []

    if task.name == '_iblrig_calibration_screen':
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_calibration_water':
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_misc_flush_water':
        task = create_task_cleanup_command(task)
    # For all of tasks stop the stim 7110, stop the recording 7111 and cleanup
    if '_iblrig_tasks' in task.name:
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_bonsai_stop_command(task, port=7111)
        task = create_task_cleanup_command(task)
        task = create_task_bpod_lights_command(task, onoff=1, when='POST')
    if task.name == '_iblrig_tasks_habituationChoiceWorld':
        task = create_task_create_command(task, patch=True)
    if task.name == '_iblrig_tasks_trainingChoiceWorld':
        task = create_task_create_command(task, patch=True)
    if task.name == '_iblrig_tasks_biasedChoiceWorld':
        task = create_task_create_command(task, patch=False)
    if task.name == '_iblrig_tasks_ephysChoiceWorld':
        task = create_task_create_command(task, patch=False)

    p.save(iblproject_path)
    print("    Task configured")
Beispiel #11
0
def create_task(iblproject_path, task_name: str):
    p = Project()
    p.load(iblproject_path)
    task = p.find_task(task_name)
    if task is None:
        task = p.create_task()
        task.name = task_name
        p.save(iblproject_path)
        print(f"Created task: {task_name}")
    else:
        print(f"Skipping creation: Task {task.name} already exists")
Beispiel #12
0
def create_subject(iblproject_path, subject_name: str):
    p = Project()
    p.load(iblproject_path)
    # if p.find_subject(subject_name) is None:
    subject = p.create_subject()
    subject.name = subject_name
    p.save(iblproject_path)
    print(f"  Created subject: {subject_name}")
Beispiel #13
0
def create_project(project_name, force=False):
    project_name = alyx2local_names.get(project_name, project_name)
    project_path = IBLRIG_PARAMS_FOLDER / project_name
    p = Project()
    if force or not pybpod_project_exists(project_name):
        p.name = project_name
        p.save(project_path)
        print(f"  Project created: [{project_name}]")
    else:
        print(
            f"  Skipping creation: project [{project_name}] found in: [{project_path}]"
        )
        p = Project()
        p.load(project_path)
    return p
Beispiel #14
0
def config_task(iblproject_path, task_name: str):  # XXX: THIS!
    p = Project()
    p.load(iblproject_path)
    task = p.find_task(task_name)
    print(f"  Configuring task <{task.name}>")
    task._commands = []

    if task.name == "_iblrig_calibration_screen":
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_calibration_water":
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_calibration_input_listner":
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_calibration_frame2TTL":
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_misc_flush_water":
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_misc_bpod_ttl_test":
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_cleanup_command(task)
    if task.name == "_iblrig_misc_frame2TTL_freq_test":
        task = create_task_cleanup_command(task)
    # For all bpod tasks turn off bpod lights, stop the stim 7110, stop the camera 7111 and cleanup
    btasks = [
        "_iblrig_tasks_habituationChoiceWorld",
        "_iblrig_tasks_trainingChoiceWorld",
        "_iblrig_tasks_biasedChoiceWorld",
        "_iblrig_tasks_ephysChoiceWorld",
    ]
    if task.name in btasks:
        task = create_task_bonsai_stop_command(task, port=7110)  # visual stimulus
        task = create_task_bonsai_stop_command(task, port=7111)  # camera recording
        task = create_task_cleanup_command(task)
        task = create_task_bpod_lights_command(task, 1, when="POST")
    if task.name == "_iblrig_tasks_habituationChoiceWorld":
        task = create_task_create_command(task, poop=True)
    if task.name == "_iblrig_tasks_trainingChoiceWorld":
        task = create_task_create_command(task, poop=True)
    if task.name == "_iblrig_tasks_biasedChoiceWorld":
        task = create_task_create_command(task, poop=False)
    if task.name == "_iblrig_tasks_ephysChoiceWorld":
        task = create_task_create_command(task, poop=False)
    if task.name == "_iblrig_tasks_ephys_certification":
        task = create_task_cleanup_command(task)
        task = create_task_bpod_lights_command(task, 0, when="PRE")
        task = create_task_bpod_lights_command(task, 1, when="POST")
    if task.name == "_iblrig_tasks_passiveChoiceWorld":
        task = create_task_cleanup_command(task)
        task = create_task_poop_command(task, when="POST")
        task = create_task_bonsai_stop_command(task, port=7110)  # stim
        task = create_task_bonsai_stop_command(task, port=7112)  # record_mic
        task = create_task_bpod_lights_command(task, 0, when="PRE")
        task = create_task_bpod_lights_command(task, 1, when="POST")
        task = create_task_move_passive_command(task, when="POST")

    p.save(iblproject_path)
    print("    Task configured")
Beispiel #15
0
def create_experiment(iblproject_path, exp_name: str):
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == exp_name]
    # if not exp:
    exp = p.create_experiment()
    exp.name = exp_name
    p.save(iblproject_path)
    print(f"Created experiment: {exp.name}")
Beispiel #16
0
def create_ibl_project(iblproject_path):
    p = Project()
    try:
        p.load(iblproject_path)
        print(f"Skipping creation: IBL project found <{iblproject_path}>")
    except:  # noqa
        p.name = 'IBL'
        p.save(iblproject_path)
        print("Created: IBL project")
def config_task(iblproject_path, task_name: str):  # XXX: THIS!
    p = Project()
    p.load(iblproject_path)
    task = p.find_task(task_name)
    print(f"  Configuring task <{task.name}>")
    task._commands = []

    if task.name == '_iblrig_calibration_screen':
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_calibration_water':
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_calibration_input_listner':
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_calibration_frame2TTL':
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_misc_flush_water':
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_misc_bpod_ttl_test':
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_cleanup_command(task)
    if task.name == '_iblrig_misc_frame2TTL_freq_test':
        task = create_task_cleanup_command(task)
    # For all bpod tasks turn off bpod lights, stop the stim 7110, stop the camera 7111 and cleanup
    btasks = [
        '_iblrig_tasks_habituationChoiceWorld',
        '_iblrig_tasks_trainingChoiceWorld',
        '_iblrig_tasks_biasedChoiceWorld',
        '_iblrig_tasks_ephysChoiceWorld',
    ]
    if task.name in btasks:
        task = create_task_bonsai_stop_command(task, port=7110)
        task = create_task_bonsai_stop_command(task, port=7111)
        task = create_task_cleanup_command(task)
        task = create_task_bpod_lights_command(task, onoff=1, when='POST')
    if task.name == '_iblrig_tasks_habituationChoiceWorld':
        task = create_task_create_command(task, poop=True)
    if task.name == '_iblrig_tasks_trainingChoiceWorld':
        task = create_task_create_command(task, poop=True)
    if task.name == '_iblrig_tasks_biasedChoiceWorld':
        task = create_task_create_command(task, poop=False)
    if task.name == '_iblrig_tasks_ephysChoiceWorld':
        task = create_task_create_command(task, poop=False)
    if task.name == '_iblrig_tasks_ephys_certification':
        task = create_task_cleanup_command(task)
        task = create_task_bpod_lights_command(task, onoff=0, when='PRE')
        task = create_task_bpod_lights_command(task, onoff=1, when='POST')
    if task.name == '_iblrig_tasks_passiveChoiceWorld':
        task = create_task_cleanup_command(task)
        task = create_task_poop_command(task, when='POST')
        task = create_task_bpod_lights_command(task, onoff=0, when='PRE')
        task = create_task_bpod_lights_command(task, onoff=1, when='POST')
        task = create_task_move_passive_command(task, when='POST')

    p.save(iblproject_path)
    print("    Task configured")
Beispiel #18
0
def create_ibl_project(iblproject_path):
    p = Project()
    print("Creating IBL project")
    try:
        p.load(iblproject_path)
        print(f"  Skipping creation: IBL project found in: {iblproject_path}")
    except:  # noqa
        p.name = "IBL"
        p.save(iblproject_path)
        print("  Created: IBL project")
Beispiel #19
0
def create_experiment_setups(iblproject_path, exp_name: str):
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == exp_name]
    if not exp:
        print(f'Experiment {exp} not found')
        raise KeyError
    else:
        exp = exp[0]

    if exp.name == '_iblrig_calibration':
        screen = create_setup(exp, 'screen', p.boards[0].name,
                              exp.name)  # noqa
        water = create_setup(exp, 'water', p.boards[0].name, exp.name)  # noqa

    if exp.name == '_iblrig_misc':
        flush_water = create_setup(  # noqa
            exp, 'flush_water', p.boards[0].name, '_iblrig_test_mouse')

    if exp.name == '_iblrig_tasks':
        biasedChoiceWorld = create_setup(  # noqa
            exp, 'biasedChoiceWorld', p.boards[0].name, None)
        habituationChoiceWorld = create_setup(  # noqa
            exp, 'habituationChoiceWorld', p.boards[0].name, None)
        trainingChoiceWorld = create_setup(  # noqa
            exp, 'trainingChoiceWorld', p.boards[0].name, None)
        ephysChoiceWorld = create_setup(  # noqa
            exp, 'ephysChoiceWorld', p.boards[0].name, None)

    p.save(iblproject_path)
Beispiel #20
0
def create_experiment_setups(iblproject_path, exp_name: str):  # XXX:THIS!
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == exp_name]
    calib_subj = [s for s in p.subjects if s.name == "_iblrig_calibration"][0]
    test_subj = [s for s in p.subjects if s.name == "_iblrig_test_mouse"][0]
    if not exp:
        raise KeyError(f"Experiment {exp} not found")
    else:
        exp = exp[0]

    if exp.name == "_iblrig_calibration":
        screen = create_setup(exp, "screen", p.boards[0].name, calib_subj)  # noqa
        water = create_setup(exp, "water", p.boards[0].name, calib_subj)  # noqa
        input_listner = create_setup(  # noqa
            exp, "input_listner", p.boards[0].name, calib_subj
        )
        frame2TTL = create_setup(exp, "frame2TTL", p.boards[0].name, calib_subj)  # noqa

    if exp.name == "_iblrig_misc":
        flush_water = create_setup(  # noqa
            exp, "flush_water", p.boards[0].name, test_subj
        )
        bpod_ttl_test = create_setup(  # noqa
            exp, "bpod_ttl_test", p.boards[0].name, test_subj
        )
        frame2TTL_freq_test = create_setup(  # noqa
            exp, "frame2TTL_freq_test", p.boards[0].name, test_subj
        )

    if exp.name == "_iblrig_tasks":
        biasedChoiceWorld = create_setup(  # noqa
            exp, "biasedChoiceWorld", p.boards[0].name, None
        )
        habituationChoiceWorld = create_setup(  # noqa
            exp, "habituationChoiceWorld", p.boards[0].name, None
        )
        trainingChoiceWorld = create_setup(  # noqa
            exp, "trainingChoiceWorld", p.boards[0].name, None
        )
        ephys_certification = create_setup(  # noqa
            exp, "ephys_certification", p.boards[0].name, None
        )
        ephysChoiceWorld = create_setup(  # noqa
            exp,
            "ephysChoiceWorld_testing",
            p.boards[0].name,
            test_subj,
            task="_iblrig_tasks_ephysChoiceWorld",
        )
        passiveChoiceWorld = create_setup(  # noqa
            exp,
            "passiveChoiceWorld_testing",
            p.boards[0].name,
            test_subj,
            task="_iblrig_tasks_passiveChoiceWorld",
        )

    p.save(iblproject_path)
Beispiel #21
0
def create_ibl_board(iblproject_path):
    p = Project()
    p.load(iblproject_path)
    if not p.boards:
        BOARD_NAME = 'SELECT_BOARD_NAME_(e.g.[_iblrig_mainenlab_behavior_0])'
        b = p.create_board()
        b.name = BOARD_NAME
        p.save(iblproject_path)
        print("Created: IBL default board (please remember to rename it)")
    else:
        print(f"Skipping creation: Board found with name <{p.boards[0].name}>")
Beispiel #22
0
def create_experiment(iblproject_path, exp_name: str):
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == exp_name]
    if not exp:
        exp = p.create_experiment()
        exp.name = exp_name
        p.save(iblproject_path)
        print(f"Created experiment: {exp.name}")
    else:
        exp = exp[0]
        print(f"Skipping creation: Experiment {exp.name} already exists")
Beispiel #23
0
def create_user(project_name, username="******", force=False):
    project_name = alyx2local_names.get(project_name, project_name)
    project_path = IBLRIG_PARAMS_FOLDER / project_name
    p = Project()
    print(f"Loading [{project_path}]")
    if not pybpod_project_exists(project_name):
        return

    p.load(project_path)
    if force or p.find_user(username) is None:
        user = p.create_user()
        user.name = username
        p.save(project_path)
        print(f"  Created user: [{user.name}] in project [{project_name}]")
    else:
        user = p.find_user(username)
        print(
            f"  Skipping creation: User [{user.name}] already exists in project [{project_name}]"
        )

    if p.find_user("_iblrig_test_user") is None:
        create_user(project_name, username="******", force=True)

    return user
def create_experiment_setups(iblproject_path, exp_name: str):  # XXX:THIS!
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == exp_name]
    calib_subj = [s for s in p.subjects if s.name == '_iblrig_calibration'][0]
    test_subj = [s for s in p.subjects if s.name == '_iblrig_test_mouse'][0]
    if not exp:
        raise KeyError(f'Experiment {exp} not found')
    else:
        exp = exp[0]

    if exp.name == '_iblrig_calibration':
        screen = create_setup(exp, 'screen', p.boards[0].name,
                              calib_subj)  # noqa
        water = create_setup(exp, 'water', p.boards[0].name,
                             calib_subj)  # noqa
        input_listner = create_setup(exp, 'input_listner', p.boards[0].name,
                                     calib_subj)  # noqa
        frame2TTL = create_setup(exp, 'frame2TTL', p.boards[0].name,
                                 calib_subj)  # noqa

    if exp.name == '_iblrig_misc':
        flush_water = create_setup(  # noqa
            exp, 'flush_water', p.boards[0].name, test_subj)
        bpod_ttl_test = create_setup(  # noqa
            exp, 'bpod_ttl_test', p.boards[0].name, test_subj)
        frame2TTL_freq_test = create_setup(  # noqa
            exp, 'frame2TTL_freq_test', p.boards[0].name, test_subj)

    if exp.name == '_iblrig_tasks':
        biasedChoiceWorld = create_setup(  # noqa
            exp, 'biasedChoiceWorld', p.boards[0].name, None)
        habituationChoiceWorld = create_setup(  # noqa
            exp, 'habituationChoiceWorld', p.boards[0].name, None)
        trainingChoiceWorld = create_setup(  # noqa
            exp, 'trainingChoiceWorld', p.boards[0].name, None)
        ephys_certification = create_setup(  # noqa
            exp, 'ephys_certification', p.boards[0].name, None)
        ephysChoiceWorld = create_setup(  # noqa
            exp,
            'ephysChoiceWorld_testing',
            p.boards[0].name,
            test_subj,
            task='_iblrig_tasks_ephysChoiceWorld')
        passiveChoiceWorld = create_setup(  # noqa
            exp,
            'passiveChoiceWorld_testing',
            p.boards[0].name,
            test_subj,
            task='_iblrig_tasks_passiveChoiceWorld')

    p.save(iblproject_path)
Beispiel #25
0
def setups_to_remove(iblproject_path):
    p = Project()
    p.load(iblproject_path)
    exp = [e for e in p.experiments if e.name == "_iblrig_calibration"]
    if not exp:
        raise KeyError(f"Experiment {exp} not found")
    else:
        exp = exp[0]
        setup = [s for s in exp.setups if s.name == "screen"]
        if not setup:
            print(f"Setup {setup} not found")
        else:
            setup = setup[0]
            print()
            exp -= setup
            p.save(iblproject_path)
 def save(self, project_path=None):
     if project_path:
         Project.save(self, project_path)
     elif self.path:
         Project.save(self, self.path)
     else:
         folder = QFileDialog.getExistingDirectory(
             self, "Select a directory to save the project: {0}".format(
                 self.name))
         if folder:
             folder = os.path.join(folder, self.name)
             try:
                 Project.save(self, str(folder))
             except FileExistsError as err:
                 logger.warning(str(err))
                 QMessageBox.warning(
                     self, 'Project exists',
                     'Project with same name already exists. Please select another path.'
                 )
Beispiel #27
0
def get_pybpod_board_comport():
    iblproject_path = Path(ph.get_iblrig_params_folder()) / "IBL"
    p = Project()
    p.load(str(iblproject_path))
    return p.boards[0].serial_port
Beispiel #28
0
def create_board_from_main_project_to(project_name, force=False):
    project_name = alyx2local_names.get(project_name, project_name)
    if project_name == "IBL":
        print("Can't create board of main project")
        return
    project_path = IBLRIG_PARAMS_FOLDER / project_name
    iblproj = Project()
    iblproj.load(IBLRIG_PARAMS_FOLDER / "IBL")
    print("Looking for boards in default project")
    if not iblproj.boards or len(iblproj.boards) > 1:
        print(
            f"0 or 2+ boards found in main project: {[x.name for x in iblproj.boards]}"
        )
        return

    bname = iblproj.boards[0].name
    print("Board found: [{}]".format(bname))
    p = Project()
    if not pybpod_project_exists(project_name):
        return

    print(f"Loading [{project_path}]")
    p.load(project_path)
    if force or not p.boards:
        board = p.create_board()
        board.name = iblproj.boards[0].name
        p.save(project_path)
        print(f"  Created board: [{board.name}] in project [{project_name}]")
    elif len(p.boards) > 1:
        print(
            f"  Skipping creation: project [{project_name}] already has [{len(p.boards)}] boards"
        )
    elif len(p.boards) == 1:
        bname = p.boards[0].name
        print(
            f"  Skipping creation: Board [{bname}] already exists in project [{project_name}]"
        )

    return
Beispiel #29
0
 def __init__(self, root_path, project_path):
     self.root_path = root_path
     self.project_path = project_path
     self.project = Project()
     self.hostname = os.environ['COMPUTERNAME']
from pybpodgui_api.models.project import Project

# create the project
proj = Project()
proj.load('my-project-folder')

exp = proj.experiments[0]
stp = exp.setups[0]

for session in stp.sessions:

    for msg in session.messages_history:

        if msg.check_type('INFO'):
            pass
            # Do somehting
        elif msg.check_type('stderr'):
            pass
            # Do something