Ejemplo n.º 1
0
# predict dir

root_dir = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/Result_Eigenfaces_KNN/RegPatchedImage'
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):
    subprocess.call('mkdir ' + '-p ' + result_dir_pre, shell=True)

#--------------- --------------------------------------------------------------
im_fns = Dpp.readTxtIntoList(result_dir_pre + '/' + 'FileList.txt')
predict_list = Dpp.ImageModificationAfterTransform(im_fns, result_dir_pre, constraintPredict)

# ground truth dir

root_dir = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/Result_Eigenfaces_KNN/RegPatchedImage'
if OrganPatch == True:
    result_dir_true   = root_dir + '/'+organ + '/PCA_test'
elif LocalPatach == True:
    result_dir_true   = root_dir + '/'+organ + 'LocalPatch'+ '/PCA_test'
else:
    raise ValueError('please choose the patch pattern')  

if not os.path.exists(result_dir_true):
    subprocess.call('mkdir ' + '-p ' + result_dir_true, shell=True)
Ejemplo n.º 2
0
print 'Results will be stored in:', result_dir
if not os.path.exists(result_dir):
    subprocess.call('mkdir ' + '-p ' + result_dir, shell=True)

outputPrefix = os.path.join(result_dir, 'JLF_predict/')
if not os.path.exists(outputPrefix):
    subprocess.call('mkdir ' + '-p ' + outputPrefix, shell=True)

# For reproducibility: save all parameters into the result dir
currentPyFile = os.path.realpath(__file__)
os.system('cp ' + currentPyFile + ' ' + result_dir)

#%%
X_data_dir = root_image_dir + '/' + organ + '_' + regIfLinear + '_Imagepatch'
Y_data_dir = root_label_dir + '/' + organ + '_' + regIfLinear + '_Labelpatch'
X_data_list = Dpp.readTxtIntoList(X_data_dir + '/FileList.txt')
Y_data_list = Dpp.readTxtIntoList(Y_data_dir + '/FileList.txt')
reference_im_fn = X_data_list[0]

# lamada: the tunning paramter that weights between the low-rank component and the sparse component
global lamda
lamda = 0.7
tol = 1e-07

# train data and test data
data_num = len(X_data_list)
PcNo = data_num - 1
MonteTime = 1
best_k = 30

#%%
Ejemplo n.º 3
0
#%%
root_dir = '/media/data/louis/ProgramWorkResult/VisercialMAS_ANT'
Input_Root_dir = root_dir + '/Patched_Image'
Image_Root_Dir = Input_Root_dir + '/GC_Volumes_patch_Elastix/' + organ + '_ImageMask'
Label_Root_Dir = Input_Root_dir + '/GC_label_patch_Elastix/' + organ + '_LabelMask'

Output_Root_dir = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/OrganReg_Elastix'
Image_Result_Dir = Output_Root_dir + '/Volume_OrganReg' + '/' + organ
Label_Result_Dir = Output_Root_dir + '/Label_OrganReg' + '/' + organ

# Make reference
reference_dir = root_dir + '/Full_Image/GC_Volumes_adjustment' + '/referenceImage'

selName = "10000128_1_CTce_ThAb"
DirFile = Dpp.readTxtIntoList(Image_Root_Dir + '/FileList.txt')
for dir_i in DirFile:
    if dir_i.find(selName) != -1:
        referenceImageMask = dir_i
        break
#%%
#  Registration
if IFNormalization != False:
    reference_im_fn = reference_dir + '/reference_WithNorm' + '.nrrd'
else:
    reference_im_fn = reference_dir + '/reference_WithoutNorm' + '.nrrd'

Imagereginput_dir = Image_Root_Dir
images = Dpp.readTxtIntoList(Imagereginput_dir + '/InputImageList.txt')
iamges_mask = Dpp.readTxtIntoList(Imagereginput_dir + '/FileList.txt')
ImageRegOutput_dir = Image_Result_Dir
Ejemplo n.º 4
0
    reference_im_fn = reference_dir + '/reference_WithoutNorm' + '.nrrd'
#------------------------------------------------------------------------------
Regmode = 'linear'
#Regmode = 'nonlinear'

#organ = '40358_muscle_body_of_left_rectus_abdominis'
#organ = '187_gallbladder'
#organ = '170_pancreas'
#organ = '30325_left_adrenal_gland'
#organ = '30324_right_adrenal_gland'
organ = '29193_first_lumbar_vertebra'
#'''
# %%
# adjust the original Label data.
data_folder = '/media/louis/Volume/ResearchData/visceral_used/GC_Labels/' + organ
im_fns = Dpp.readTxtIntoList(data_folder + '/FileList.txt')

searchName = "10000129_1_CTce_ThAb"
for dir_i in im_fns:
    if dir_i.find(searchName) != -1:
        im_fns.remove(dir_i)
        break

label_dir = root_label_dir + '/' + organ
sizeadjust_label_dir = label_dir + '/sizeadjustment'
if not os.path.exists(sizeadjust_label_dir):
    subprocess.call('mkdir ' + '-p ' + sizeadjust_label_dir, shell=True)

cuttingresult_dir = label_dir + '/cuttingresult'
if not os.path.exists(cuttingresult_dir):
    subprocess.call('mkdir ' + '-p ' + cuttingresult_dir, shell=True)
Ejemplo n.º 5
0
# show image information

import SimpleITK as sitk  # SimpleITK to load images
import sys
sys.path.insert(0, '../')
import DataPreProcessing.Func_data_preprocessing as Dpp

#%%
data_folder = '/media/louis/Volume/ProgramWorkResult/MICCAI_2017_6_12/Full_Image/GC_Volumes_adjustment/cuttingresult'
InputImageList = Dpp.readTxtIntoList(data_folder + '/FileList.txt')

for i in xrange(len(InputImageList)):
    image = sitk.ReadImage(InputImageList[i])
    image_array = sitk.GetArrayFromImage(image)  # get numpy array
    print 'Image No. %d' % (i)
    print 'dim z,x,y :' + str(image_array.shape)
    print 'Origin:' + str(image.GetOrigin())
    print 'sapcing:' + str(image.GetSpacing())
Ejemplo n.º 6
0
import os
import subprocess
sys.path.insert(0, '../')
import DataPreProcessing.Func_data_preprocessing as Dpp

regIfLinear = "Linear"
#regIfLinear = "nonlinear"

organ = '187_gallbladder'
#organ = '170_pancreas'
#organ = '30325_left_adrenal_gland'
#organ = '30324_right_adrenal_gland'
#organ = '29193_first_lumbar_vertebra'

root_dir = '/media/louis/Volume/ProgramWorkResult/VisercialMAS_ANT'

label_data_dir = root_dir + '/Full_Image/GC_label_adjustment' + '/'+organ +\
                 '/Regtrans_' + regIfLinear +'_ANT'
result_dir_lab = root_dir + '/Full_Image/GC_label_adjustment' + '/'+organ +\
                 '/Modification_Regtrans_' + regIfLinear + '_ANT'

print 'Results will be stored in:', result_dir_lab
if not os.path.exists(result_dir_lab):
    subprocess.call('mkdir ' + '-p ' + result_dir_lab, shell=True)

#--------------------------------------------------------------------------------
im_fns_label = Dpp.readTxtIntoList(label_data_dir + '/FileList.txt')
result_lab_list = Dpp.ImageModificationAfterTransform(im_fns_label,
                                                      result_dir_lab)
Dpp.WriteListtoFile(result_lab_list, result_dir_lab + '/FileList.txt')