Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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):
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')