# "CT-Training-BE010",] for patient in patients: ###################Fetch study############### print(patient) try: patientStudy = json.loads(tcia.get_patient_study(patientID=patient).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) for study in patientStudy: ##########Fetch series############# print("Fetching series for the studyInstanceUID: "+ study['StudyInstanceUID']) try: patientSeries = json.loads(tcia.get_series(studyInstanceUID=study['StudyInstanceUID']).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) for series in patientSeries: print("Fetching images for the seriesInstanceUID: "+series['SeriesInstanceUID']) ##################Fetch images############# try: images = (tcia.get_image(seriesInstanceUID=series['SeriesInstanceUID'])) except requests.exceptions.RequestException as e: print(e) sys.exit(1) #print(images) print("Writing image zipfile for the seriesInstanceUID: "+series['SeriesInstanceUID'])
###################Fetch study############### try: patientStudy = json.loads(tcia.get_patient_study(collection=collection, patientID=patient).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) patientStudyHash = buildHash("StudyInstanceUID", patientStudy) patientStudy = processInput(patientStudyHash, "studyInstanceUID") print("Fetching series for the studyInstanceUID: "+ patientStudy) ##########Fetch series#############3 try: patientSeries = json.loads(tcia.get_series(studyInstanceUID=patientStudy).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) patientSeriesHash = buildHash("SeriesInstanceUID", patientSeries) patientSeries = processInput(patientSeriesHash, "seriesInstanceUID") print("Fetching images for the seriesInstanceUID: "+patientSeries) ##################Fetch images############# try: images = (tcia.get_image(seriesInstanceUID=patientSeries)) except requests.exceptions.RequestException as e: print(e) sys.exit(1)
###################Fetch study############### try: patientStudy = json.loads(tcia.get_patient_study(patientID=patient).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) patientStudyHash = buildHash("StudyInstanceUID", patientStudy) patientStudy = processInput(patientStudyHash, "studyInstanceUID") print("Fetching series for the studyInstanceUID: "+ patientStudy) ##########Fetch series#############3 try: patientSeries = json.loads(tcia.get_series(studyInstanceUID=patientStudy).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) patientSeriesHash = buildHash("SeriesInstanceUID", patientSeries) patientSeries = processInput(patientSeriesHash, "seriesInstanceUID") print("Fetching images for the seriesInstanceUID: "+patientSeries) ##################Fetch images############# try: images = (tcia.get_image(seriesInstanceUID=patientSeries)) except requests.exceptions.RequestException as e: print(e) sys.exit(1)
###################Fetch study############### print(patient) try: patientStudy = json.loads( tcia.get_patient_study(patientID=patient).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) for study in patientStudy: ##########Fetch series############# print("Fetching series for the studyInstanceUID: " + study['StudyInstanceUID']) try: patientSeries = json.loads( tcia.get_series( studyInstanceUID=study['StudyInstanceUID']).text) except requests.exceptions.RequestException as e: print(e) sys.exit(1) for series in patientSeries: print("Fetching images for the seriesInstanceUID: " + series['SeriesInstanceUID']) ##################Fetch images############# try: images = (tcia.get_image( seriesInstanceUID=series['SeriesInstanceUID'])) except requests.exceptions.RequestException as e: print(e) sys.exit(1)