def grep_or_create_visit_label_db_info(bids_id, cand_id, visit_label, db, createvisit, verbose, loris_bids_dir, center_id): """ Greps (or creates if candidate does not exist and createcand is true) the BIDS candidate in the LORIS candidate's table and return a list of candidates with their related fields from the database. :parma bids_id : BIDS ID of the candidate :type bids_id : str :param cand_id : CandID to use to create the session :type cand_id : int :param visit_label : Visit label to use to create the session :type visit_label : str :param db : database handler object :type db : object :param createvisit : if true, creates the candidate in LORIS :type createvisit : bool :param verbose : if true, prints out information while executing :type verbose : bool :param loris_bids_dir: LORIS BIDS import root directory to copy data :type loris_bids_dir: str :return: session information grepped from LORIS for cand_id and visit_label :rtype: dict """ session = Session(verbose, cand_id=cand_id, visit_label=visit_label, center_id=center_id) loris_vl_info = session.get_session_info_from_loris(db) if not loris_vl_info and createvisit: loris_vl_info = session.create_session(db) # create the visit directory for in the candidate folder of the LORIS # BIDS import directory lib.utilities.create_dir( loris_bids_dir + "sub-" + bids_id + "/ses-" + visit_label, verbose) return loris_vl_info