How to use the xnat.connect function in xnat

To help you get started, we’ve selected a few xnat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MStarmans91 / WORC / WORC / exampledata / datadownloader.py View on Github external
def download_project(project_name, xnat_url, datafolder, nsubjects=10,
                     verbose=True):

    # Connect to XNAT and retreive project
    session = xnat.connect(xnat_url)
    project = session.projects[project_name]

    # Create the data folder if it does not exist yet
    datafolder = os.path.join(datafolder, project_name)
    if not os.path.exists(datafolder):
        os.makedirs(datafolder)

    subjects_len = len(project.subjects)
    if nsubjects == 'all':
        nsubjects = subjects_len
    else:
        nsubjects = min(nsubjects, subjects_len)

    subjects_counter = 1
    downloaded_subjects_counter = 0
    for s in range(0, subjects_len):
github MStarmans91 / WORC / WORC / processing / label_processing.py View on Github external
label_status (numpy array): The status of the different labels
         for each patient
    """
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    config = load_config_XNAT(label_info)
    url = config['XNAT']['url']
    projectID = config['XNAT']['projectID']

    # Example
    # url = "http://bigr-rad-xnat.erasmusmc.nl"
    # projectID = 'LGG-Radiogenom'
    # url = label_info['url']
    # projectID = label_info['projectID']

    session = xnat.connect(url, verify=False)

    subkeys = session.projects[projectID].subjects.keys()
    subkeys.sort()
    session.disconnect()

    baseurl = url + '/data/archive/projects/' + projectID + '/subjects/'
    patient_ID = list()
    label_names = None
    label_status = list()
    for i_patient in subkeys:
        # Extra check as there are bound to be some fake patients
        if projectID in i_patient:
                patient_ID.append(i_patient)

                data = requests.get(baseurl + i_patient +
                                    '/resources/GENETICS/files/genetics.json')

xnat

An XNAT client that exposes the XNAT REST interface as python objects. Part of the interface is automatically generated based on the servers data model as defined by the xnat schema.

Apache-2.0
Latest version published 1 month ago

Package Health Score

58 / 100
Full package analysis

Popular xnat functions

Similar packages