#patient_evaluations = open(evaluation_path + "/patient_evaluations.log", "w") results = [] CPMs = [] CPMs2 = [] test_patients = all_patients bt.filelist_store(all_patients, evaluation_path + "/patientfilelist.log") #random.shuffle(test_patients) for p in range(len(test_patients)): result = [] patient = test_patients[p] #patient = "./LUNA16/subset9/1.3.6.1.4.1.14519.5.2.1.6279.6001.227968442353440630355230778531.mhd" #patient = "./LUNA16/subset9/1.3.6.1.4.1.14519.5.2.1.6279.6001.212608679077007918190529579976.mhd" #patient = "./LUNA16/subset9/1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408431413578140925249.mhd" #patient = "./TIANCHI_examples/LKDS-00005.mhd" uid = mt.get_mhd_uid(patient) annotations = mt.get_luna_annotations(uid, annotation_file) if len(annotations) == 0: print('%d/%d patient %s has no annotations, ignore it.' % (p + 1, len(test_patients), uid)) #patient_evaluations.write('%d/%d patient %s has no annotations, ignore it\n' %(p+1, len(test_patients), uid)) continue print('%d/%d processing patient:%s' % (p + 1, len(test_patients), uid)) full_image_info = sitk.ReadImage(patient) full_scan = sitk.GetArrayFromImage(full_image_info) origin = np.array(full_image_info.GetOrigin( ))[::-1] #the order of origin and old_spacing is initially [z,y,x] old_spacing = np.array(full_image_info.GetSpacing())[::-1] image, new_spacing = mt.resample(full_scan, old_spacing) #resample print('Resample Done. time:{}s'.format(time.time() - start_time))
CPMs = [] CPMs2 = [] test_patients = all_patients #test_count = 0 #random.shuffle(test_patients) bt.filelist_store(test_patients, evaluation_path + "/patientfilelist.log") for p in range(len(test_patients)): patient = test_patients[p] #patient = "./LUNA16/subset9/1.3.6.1.4.1.14519.5.2.1.6279.6001.212608679077007918190529579976.mhd" #patient = "./LUNA16/subset9/1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408431413578140925249.mhd" #patient = "./TIANCHI_examples/LKDS-00005.mhd" uid = mt.get_mhd_uid(patient) if 'test_uids' not in dir() or uid not in test_uids: print("%d/%d patient %s not belong to test set" %(p+1, len(test_patients), uid)) continue annotations = mt.get_luna_annotations(uid, annotation_file) exclusions = mt.get_luna_annotations(uid, exclude_file) if len(annotations) == 0: print("%d/%d patient %s has no annotations, ignore it." %(p+1, len(test_patients), uid)) #patient_evaluations.write('%d/%d patient %s has no annotations, ignore it\n' %(p+1, len(test_patients), uid)) continue #test_count += 1 #if test_count < START_NUM: #the START_NUM begin from 1 #print("%d/%d patient %s count %d/%d." %(p+1, len(test_patients), uid, test_count, START_NUM)) #continue print('%d/%d processing patient:%s' %(p+1, len(test_patients), uid)) full_image_info = sitk.ReadImage(patient) full_scan = sitk.GetArrayFromImage(full_image_info) origin = np.array(full_image_info.GetOrigin())[::-1] #the order of origin and old_spacing is initially [z,y,x]