def run(self, window = None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.contourareaerror = ContourErrorWithAreaAnalysis(None) self.contourweigherror = WeightedContourErrorAnalysis(None) self.areaerror = AreaIndexAnalysis(None) self.centerlineerror = CenterlineErrorAnalysis(None) self.savepath = 'D:/ResultData/' self.dirs = ['icp-cen-clip-nolabel/', 'icp-cen-noclip-label/', 'icp-surface-clip-label/', 'icp-surface-noclip-nolabel/'] self.type = ['_icp_cen.mat', '_icp_cen.mat', '_icp_con.mat', '_icp_con.mat'] self.book = xlwt.Workbook() self.sheet = self.book.add_sheet('icp_cen') self.sheet.write(1, 0, 'MRE') self.sheet.write(2, 0, 'AMRE') self.sheet.write(3, 0, 'WMRE') self.sheet.write(4, 0, 'AWMRE') for k in range(4): for i in range(self.cnt): dataset = self.load(k, i) self.process(dataset, k, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet = self.book.add_sheet('mask') self.sheet.write(1, 0, 'With mask') self.sheet.write(5, 0, 'Without mask') for j in range(2): for i in range(4): self.sheet.write(j * 4 + i + 1, 1, title[i]) for i in range(self.cnt): dataset = self.load(i) self.sheet.write(0, i + 2, self.ini.file.name_result[i]) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.contourerror = ContourErrorAnalysis(None) self.areaerror = AreaIndexAnalysis(None) self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet = self.book.add_sheet('icp_cen') #self.sheet.write(1, 0, 'MR Area') #self.sheet.write(5, 0, 'US Area') self.sheet.write(1, 0, 'Delta') ''' for j in range(2): for i in range(4): self.sheet.write(j * 4 + i + 1, 1, title[i]) ''' for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window = None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test_modal.ini') self.cnt = len(self.ini.file.name_fix) self.icp = WeightIcpRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.dis = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 10, 100, 10000000] self.error = npy.zeros([len(self.dis)], dtype = npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error /= self.cnt self.book = xlwt.Workbook() self.sheet = self.book.add_sheet('Initial Slice') for i in range(len(self.dis)): self.sheet.write(0, i, float(self.dis[i])) self.sheet.write(1, i, float(self.error[i])) self.book.save('./Result/weight_icp_merge.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') #self.ini = DictIni(self.path + '/Script/Macro/test_modal.ini') self.cnt = len(self.ini.file.name_fix) self.icp = NonrigidIcpRegistration(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet1 = self.book.add_sheet('icp_con') self.sheet1.write(1, 0, 'SRE') self.sheet1.write(5, 0, 'SMAXE') self.sheet1.write(9, 0, 'Dice Index') self.sheet1.write(13, 0, 'time') for j in range(3): for i in range(4): self.sheet1.write(j * 4 + i + 1, 1, title[i]) self.sheet2 = self.book.add_sheet('icp_cen') self.sheet2.write(1, 0, 'SRE') self.sheet2.write(5, 0, 'SMAXE') self.sheet2.write(9, 0, 'Dice Index') self.sheet2.write(13, 0, 'time') for j in range(3): for i in range(4): self.sheet2.write(j * 4 + i + 1, 1, title[i]) self.sheet3 = self.book.add_sheet('icp_con_label') self.sheet3.write(1, 0, 'SRE') self.sheet3.write(5, 0, 'SMAXE') self.sheet3.write(9, 0, 'Dice Index') self.sheet3.write(13, 0, 'time') for j in range(3): for i in range(4): self.sheet3.write(j * 4 + i + 1, 1, title[i]) self.sheet4 = self.book.add_sheet('icp_cen_label') self.sheet4.write(1, 0, 'SRE') self.sheet4.write(5, 0, 'SMAXE') self.sheet4.write(9, 0, 'Dice Index') self.sheet4.write(13, 0, 'time') for j in range(3): for i in range(4): self.sheet4.write(j * 4 + i + 1, 1, title[i]) for i in range(0, self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.savepath = self.path + self.ini.file.savedir self.contourerror = ContourErrorAnalysis(None) self.contourareaerror = ContourErrorWithAreaAnalysis(None) self.result = [{}, {}, {}] self.resultCnt = [{}, {}, {}] self.correct = npy.array([0.0, 0.0, 0.0]) self.count = npy.array([0, 0, 0]) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset print self.correct / self.count, npy.sum(self.correct) / npy.sum( self.count) ''' for cnt in range(3): for x in self.result[cnt].keys(): self.result[cnt][x] /= self.resultCnt[cnt][x] self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA'] self.sheet = self.book.add_sheet('Distance_error') for i in range(3): self.sheet.write(i + 1, 0, title[i]) zmin = [0, 0, 0] zmax = [0, 0, 0] for cnt in range(3): zmin[cnt] = min(self.result[cnt].keys()) zmax[cnt] = max(self.result[cnt].keys()) z1 = int(min(zmin)) z2 = int(max(zmax)) for z in range(z1, z2 + 1): self.sheet.write(0, z - z1 + 1, z * 0.34722220897674) for cnt in range(3): for x in self.result[cnt].keys(): self.sheet.write(cnt + 1, int(x) - z1 + 1, self.result[cnt][x]) for cnt in range(3): for x in self.result[cnt].keys(): self.sheet.write(cnt + 4, int(x) - z1 + 1, self.resultCnt[cnt][x]) self.book.save(self.path + self.ini.file.savedir + 'Distance_error_segmentation.xls') ''' if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test_merge_suc.ini') self.cnt = len(self.ini.file.name_fix) self.repeat = 3 self.icp = IcpPointsetRegistration(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.error = npy.zeros([4, 16, 4], dtype=npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error /= self.cnt self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet = self.book.add_sheet('Noise Slice') self.sheet.write(1, 0, 'Cen-Label') self.sheet.write(5, 0, 'Con-Label') self.sheet.write(9, 0, 'Cen') self.sheet.write(13, 0, 'Con') for i in range(4): self.sheet.write(i + 1, 1, title[i]) self.sheet.write(i + 5, 1, title[i]) self.sheet.write(i + 9, 1, title[i]) self.sheet.write(i + 13, 1, title[i]) for i in range(0, 16): self.sheet.write(0, i + 2, float(i) / 5) for i in range(4): for j in range(0, 16): self.sheet.write(i + 1, j + 2, float(self.error[0, j, i])) self.sheet.write(i + 5, j + 2, float(self.error[1, j, i])) self.sheet.write(i + 9, j + 2, float(self.error[2, j, i])) self.sheet.write(i + 13, j + 2, float(self.error[3, j, i])) self.book.save('./Result/Robust_Noise_merge_suc.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) #self.para = [0.01, 0.02, 0.03, 0.04, 0.05, 0.1, 0.2, 0.4, 0.8, 1.0] self.para = [0.6] self.len = len(self.para) self.error = npy.zeros([self.len, 4], dtype=npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error[:, 0] /= self.cnt self.error[:, 1] = npy.sqrt( (self.error[:, 1] - self.error[:, 0]**2 * self.cnt) / (self.cnt - 1)) self.book = xlwt.Workbook() self.sheet = self.book.add_sheet('Downsample Slice') self.sheet.write(1, 0, 'mean') self.sheet.write(2, 0, 'std') for i in range(self.len): self.sheet.write(0, i + 1, self.para[i]) for i in range(2): for j in range(self.len): self.sheet.write(i + 1, j + 1, float(self.error[j, i])) self.book.save('./Result/Robust_Para_snap_surface_0.6.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def load(self): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.path = self.path.replace('\\', '/') self.ini = DictIni(self.path + '/Script/Macro/load.ini') load = LoadDicomFile(None) dataset = [None, None] self.cnt = self.ini.file.name_result dir = self.path + self.ini.file.datadir + 'crop' + str(self.cnt) + '/' mdir = dir + "3D Merge/" namelist = os.listdir(mdir) dataset = load.load( [str(mdir.replace('/', '\\') + x) for x in namelist])[0] dataset.setName('Patient%d_Merge_Full' % self.cnt) print '3D Merge Data %d loaded!' % self.cnt return dataset
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.areaerror = AreaIndexAnalysis(None) self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet1 = self.book.add_sheet('segmentation') self.sheet1.write(1, 0, 'MRE') for i in range(4): self.sheet1.write(i + 1, 1, title[i]) self.sheet1.write(5, 0, 'Time') self.sheet2 = self.book.add_sheet('registration') self.sheet2.write(1, 0, 'MRE') self.sheet2.write(5, 0, 'MAXE') self.sheet2.write(9, 0, 'Dice Index') self.sheet2.write(13, 0, 'Time') for j in range(3): for i in range(4): self.sheet2.write(j * 4 + i + 1, 1, title[i]) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) #self.ini = DictIni(self.path + '/Script/Macro/test1.ini') # Remove 56L for small FOV self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.error = npy.zeros([10, 4], dtype=npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error /= self.cnt self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet = self.book.add_sheet('Downsample Slice') for i in range(4): self.sheet.write(i + 1, 0, title[i]) for i in range(10): self.sheet.write(0, i + 1, i + 1) for i in range(4): for j in range(10): self.sheet.write(i + 1, j + 1, float(self.error[j, i])) self.book.save('./Result/Robust_Para.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window = None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) #self.spacing = [-1.0, 40.0, 32.0, 16.0, 8.0, 4.0] #self.w1 = [-1.0, 0.0, 1.0, 10.0, 100.0, 1000.0, 10000.0] #self.type = ['SSD', 'MI', 'CR'] #n = len(self.w1) * len(self.spacing) #self.regPara = [(-1, -1, 'SSD'), (4.0, -1, 'SSD'), (-1, 1000, 'MI'), (32.0, 1000, 'MI'), (-1, -1, 'MI'), (32.0, -1, 'MI')] self.regPara = [(-1, -1, 'SSD'), (-1, 1000, 'MI'), (-1, -1, 'MI')] #self.regPara = [(-1, -1, 'SSD'), (15.0, -1, 'SSD'), (-1, -1, 'MI'), (15.0, -1, 'MI')] self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() self.sheet1 = self.book.add_sheet('MSD') for i in range(len(self.regPara)): self.sheet1.write(i + 1, 1, "type = %s beta = %fmm, w1 = %f" % (self.regPara[i][2], self.regPara[i][0], self.regPara[i][1])) self.sheet2 = self.book.add_sheet('DSC') for i in range(len(self.regPara)): self.sheet2.write(i + 1, 1, "type = %s beta = %fmm, w1 = %f" % (self.regPara[i][2], self.regPara[i][0], self.regPara[i][1])) self.sheet3 = self.book.add_sheet('Time') for i in range(len(self.regPara)): self.sheet3.write(i + 1, 1, "type = %s beta = %fmm, w1 = %f" % (self.regPara[i][2], self.regPara[i][0], self.regPara[i][1])) for i in range(17, self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test.ini') self.cnt = len(self.ini.file.name_fix) self.contourerror = ContourErrorAnalysis(None) self.contourareaerror = ContourErrorWithAreaAnalysis(None) self.contourweigherror = WeightedContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.areaerror = AreaIndexAnalysis(None) self.centerlineerror = CenterlineErrorAnalysis(None) self.savepath = self.path + self.ini.file.savedir self.book = xlwt.Workbook() title = ['CCA', 'ECA', 'ICA', 'Overall'] self.sheet = self.book.add_sheet('icp_cen') self.sheet.write(1, 0, 'MRE') self.sheet.write(5, 0, 'MAXE') #self.sheet.write(9, 0, 'AWMRE') #self.sheet.write(9, 0, 'Dice Index') #self.sheet.write(13, 0, 'MCRE') #self.sheet.write(17, 0, 'MAXCRE') #for j in range(5): for j in range(2): for i in range(4): self.sheet.write(j * 4 + i + 1, 1, title[i]) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window = None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test_modal.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.error = npy.zeros([31, 2], dtype = npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error[:, 0] /= self.cnt self.error[:, 1] = npy.sqrt((self.error[:, 1] - self.error[:, 0] ** 2 * self.cnt) / (self.cnt - 1)) self.book = xlwt.Workbook() self.sheet = self.book.add_sheet('Initial Slice') self.sheet.write(1, 0, 'mean') self.sheet.write(2, 0, 'std') for i in range(-15, 16): self.sheet.write(0, i + 16, i) for i in range(2): for j in range(31): self.sheet.write(i + 1, j + 1, float(self.error[j, i])) self.book.save('./Result/Initial_merge.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window = None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test_modal.ini') self.cnt = len(self.ini.file.name_fix) self.icp = IcpPointsetRegistration(None) self.contourerror = ContourErrorAnalysis(None) self.surfaceerror = SurfaceErrorAnalysis(None) self.dis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] self.error = npy.zeros([len(self.dis), len(self.dis)], dtype = npy.float32) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.error /= self.cnt self.book = xlwt.Workbook() self.sheet = self.book.add_sheet('Initial Slice') for i in self.dis: self.sheet.write(0, i, i) self.sheet.write(i, 0, i) for i in self.dis: for j in self.dis: self.sheet.write(i, j, float(self.error[i - 1, j - 1])) self.book.save('./Result/center_dis_merge.xls') if self.gui: self.gui.showErrorMessage('Success', 'Test sucessfully!') else: print 'Test sucessfully!'
def run(self, window=None): self.path = sys.argv[0] if os.path.isfile(self.path): self.path = os.path.dirname(self.path) self.ini = DictIni(self.path + '/Script/Macro/test_contrast.ini') self.cnt = len(self.ini.file.name_fix) self.uspoints = 0 self.usslices = 0 self.mrpoints = 0 self.mrslices = 0 self.mr = [0, 0, 0, 0] self.book = xlwt.Workbook() title = ['Bottom', 'Bifurcation', 'Top', 'X', 'Y', 'Z'] self.sheet_us = self.book.add_sheet('Merge') for i in range(1, 7): self.sheet_us.write(0, i, title[i - 1]) self.sheet_mr = self.book.add_sheet('SNAP') for i in range(1, 7): self.sheet_mr.write(0, i, title[i - 1]) for i in range(self.cnt): dataset = self.load(i) self.process(dataset, i) del dataset self.mr[3] = self.mr[0] + self.mr[1] + self.mr[2] if self.gui: self.gui.showErrorMessage( 'Success', 'US Slice: %d, US Point: %d\nMR Slice: %d, MR Point: %d\nTotal Slice: %d, Total Point: %d\n' % (self.usslices, self.uspoints, self.mrslices, self.mrpoints, self.usslices + self.mrslices, self.uspoints + self.mrpoints)) print self.mr else: print 'Test sucessfully!'