try: weight = cc.LoadMHA(imagedir + 'block{0}_as_MRI_weight_{1}.mha'.format(i, sz)) except IOError: print 'Warning, weight block does not exist' weight = ca.Image3D(blk.grid(), blk.memType()) ca.Copy(weight, blk, 0) # take red cc.SetRegionGTE(weight, weight, .1, 1) for i in xrange(3): ca.Copy(weight3, weight, i) weights += weight3 print ca.MinMax(weights) for i in xrange(3): ca.Copy(weight, weights, i) cc.SetRegionLT(weight, weight, 1, 1) ca.Copy(weights, weight, i) print ca.MinMax(weights) ca.Div_I(blocks, weights) else: # best imagedir = '/home/sci/crottman/korenberg/results/' blocks = cc.LoadMHA( imagedir + 'BFI_2D_Reg/block1_as_MRI_' + col + '_256.mha', ca.MEM_HOST) blk = cc.LoadMHA(imagedir + 'BFI_2D_Reg/block2_as_MRI_' + col + '_256.mha', ca.MEM_HOST) blocks += blk blk = cc.LoadMHA(imagedir + 'landmark/block3_as_MRI_' + col + '.mha', ca.MEM_HOST) blocks += blk
import PyCA.Core as ca import numpy as np import sys import PyCACalebExtras.Common as cc import PyCACalebExtras.Display as cd import matplotlib.pyplot as plt plt.close('all') block = 3 # 1, 2, 3, 4 dir_in = '/home/sci/crottman/korenberg/results/landmark/' dir_out = '/home/sci/crottman/korenberg/results/ve_reg/' Imri = cc.LoadMHA('/home/sci/crottman/korenberg/results/MRI/brain_seg.mha') cc.SetRegionLT(Imri, Imri, 1.0, 20000) VEmri = ca.Image3D(Imri.grid(), Imri.memType()) cc.VarianceEqualize(VEmri, Imri, sigma=2.0) # # load landmark registered blocks # Ibfi = cc.LoadMHA(dir_in + 'block' + str(block) + '_as_MRI_bw.mha') # ca.Neg_I(Ibfi) # VEbfi = ca.Image3D(Imri.grid(), Imri.memType()) # cc.VarianceEqualize(VEbfi, Ibfi, sigma=2.0) # cd.DispImage(VEbfi, ca.MinMax(VEmri)) # load landmark registered pre-VEd block VEbfi = cc.LoadMHA(dir_in + 'block' + str(block) + '_as_MRI_ve.mha') ca.Neg_I(VEbfi) # cc.WritePNG(VEbfi, 'VEbfi_block' + str(block) + 'new.png', rng = [-2.8, 2.8]) # cd.DispImage(Ibfi)