organ = '187_gallbladder' organ = '170_pancreas' organ = '30325_left_adrenal_gland' organ = '30324_right_adrenal_gland' organ = '29193_first_lumbar_vertebra' CWD = os.getcwd() central_point = np.load(CWD + '/PatchedImage_v2/' + organ + '_' + regIfLinear + '_central_point.npy') ImageInfo = np.load(CWD + '/PreProcessing_v5/ImageInfo.npy') ImageInfo = ImageInfo.item() root = '/media/louis/Volume/ProgramWorkResult/VisercialMAS_ANT' rawPredictDir = root + "/Result_Eigenfaces_KNN/PatchedImage/" + organ + '_' + regIfLinear + "/PCA_predict" rawPredictlist = readTxtIntoList(rawPredictDir + "/FileListZoom.txt") PredictDir = root + "/PredictRecovery/" + organ + '_' + regIfLinear + "_PredictRecovery" if not os.path.exists(PredictDir): subprocess.call('mkdir ' + '-p ' + PredictDir, shell=True) predict_List = predictRecover(rawPredictlist, central_point, ImageInfo, PredictDir) WriteListtoFile(predict_List, PredictDir + "/FileList.txt") #%% # upsample #root_dir = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/Full_Image' #rawImageDir = root_dir + '/GC_Volumes_adjustment/Regtrans_linear' #groundTruthDir = root_dir + '/GC_label_adjustment'+'/'+organ + '_'+ regIfLinear + '/Modification_Regtrans_linear'
RunRegistration = False IFdownSample = True IFNormalization = False InterP = 0 # Bilinear interpolation would be order=1, nearest is order=0, and cubic is the default (order=3). Regmode = 'nonlinear' # output path root_dir = '/media/data/louis/ProgramWorkResult/VisercialMAS_ANT' root_image_dir = root_dir + '/Full_Image' + '/GC_Volumes_adjustment' # image root dir root_label_dir = root_dir + '/Full_Image' + '/GC_label_adjustment' # image root dir # Input path data_folder = '/media/data/louis/ResearchData/visceral_used/GC_Volumes' im_fns_raw = readTxtIntoList(data_folder + '/FileList.txt') # adjust the GC original data. Image_select = range(32) + range(33, 40) ''' there is no "10000129_1_CTce_ThAb.nii.gz" ''' im_fns = [] for i in Image_select: im_fns.append(im_fns_raw[i]) #%% sizeadjust_list = [] sizeadjust_image_dir = root_image_dir + '/sizeadjustment' if not os.path.exists(sizeadjust_image_dir): subprocess.call('mkdir ' + '-p ' + sizeadjust_image_dir, shell=True)
sitk.WriteImage(img, fn) return outputlist #%% OrganPatch = False LocalPatach = True organ = '187_gallbladder' constraint1 = 0.3 constraintgroundtruth = 0.02 #%% #raw image root = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12' image_dir = root + '/Patched_Image/GC_Volumes_patch' + '/' + organ + '_Imagepatch' im_fns = readTxtIntoList(image_dir + '/' + 'FileList.txt') normalizedImage_list = ImageNormlization(im_fns, image_dir) WriteListtoFile(normalizedImage_list, image_dir + '/normalizedFileList.txt') #%% # predict dir root_dir = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/Result_Eigenfaces_KNN/PatchedImage' if OrganPatch == True: result_dir_pre = root_dir + '/' + organ + '/PCA_predict' elif LocalPatach == True: result_dir_pre = root_dir + '/' + organ + 'LocalPatch' + '/PCA_predict' else: raise ValueError('please choose the patch pattern') print 'Results will be stored in:', result_dir_pre if not os.path.exists(result_dir_pre):