dax/dax_tools_utils.py
def randomly_get_sessions(xnat, project, nb_sess=5):
    """
    Retrieve nb_sess sessions label randomly from the test project on XNAT

    :param project: XNAT project
    :return: list of sessions label
    """
    sessions = list()
    list_sess = XnatUtils.list_sessions(xnat, project)
    if len(list_sess) < int(nb_sess):
        sessions = [sess['label'] for sess in list_sess]
    else:
        for _ in range(int(nb_sess)):
            session_added = False
            while not session_added:
                random_index = random.randint(0, len(list_sess) - 1)
                if list_sess[random_index]['label'] not in sessions:
                    sessions.append(list_sess[random_index]['label'])
                    session_added = True

    return sessions

    Retrieve nb_sess sessions label randomly from the test project on XNAT

    :param project: XNAT project
    :return: list of sessions label
    
Retrieve nb_sess sessions label randomly from the test project on XNAT
Retrieve nb_sess sessions label randomly from the test project on XNAT
def randomly_get_sessions(xnat, project, nb_sess=5):
    sessions = list()
    list_sess = XnatUtils.list_sessions(xnat, project)
    if len(list_sess) < int(nb_sess):
        sessions = [sess['label'] for sess in list_sess]
    else:
        for _ in range(int(nb_sess)):
            session_added = False
            while not session_added:
                random_index = random.randint(0, len(list_sess) - 1)
                if list_sess[random_index]['label'] not in sessions:
                    sessions.append(list_sess[random_index]['label'])
                    session_added = True
    return sessions
def randomly_get_sessions ( xnat , project , nb_sess = 5 ) : sessions = list ( ) list_sess = XnatUtils . list_sessions ( xnat , project ) if len ( list_sess ) < int ( nb_sess ) : sessions = [ sess [ 'label' ] for sess in list_sess ] else : for _ in range ( int ( nb_sess ) ) : session_added = False while not session_added : random_index = random . randint ( 0 , len ( list_sess ) - 1 ) if list_sess [ random_index ] [ 'label' ] not in sessions : sessions . append ( list_sess [ random_index ] [ 'label' ] ) session_added = True return sessions
Retrieve nb_sess sessions label randomly from the test project on XNAT
Retrieve nb_sess sessions label randomly from the test project on XNAT
"""
    Retrieve nb_sess sessions label randomly from the test project on XNAT

    :param project: XNAT project
    :return: list of sessions label
    """
list of sessions label
list of sessions label
xnat
project
None
nb_sess