def brains(sim): sim.dim = 2 sim.sigma = .5 sim.sfactor = 1./numpy.power(sim.sigma, 2) sim.num_points = (90,110) sim.domain_max = None sim.dx = (1.,1.) sim.num_times = 11 sim.time_min = 0. sim.time_max = 1. sim.cg_init_eps = 1e-3 sim.write_iter = file_write_iter brain_image_dir = os.environ["HOME"] + "/IMAGES/meta_images/child/" sim.kvn = 'laplacian' sim.khn = 'laplacian' sim.kvs = 3. sim.khs = .1 sim.kvo = 4 sim.kho = 4 logging.info("KV params: name=%s, sigma=%f, order=%f" \ % (sim.kvn,sim.kvs,sim.kvo)) logging.info("KH params: name=%s, sigma=%f, order=%f" \ % (sim.khn,sim.khs,sim.kho)) num_nodes = 90*110 sim.sc = diffeomorphisms.gridScalars() sim.sc.loadAnalyze(brain_image_dir + "child_2d.hdr") #sim.template_in = sim.sc.data[45,...].reshape(num_nodes) sim.target_in = sim.sc.data.reshape(num_nodes) sim.sc = diffeomorphisms.gridScalars() sim.sc.loadAnalyze(brain_image_dir + "adult_2d.hdr") #sim.target_in = sim.sc.data[45,...].reshape(num_nodes) sim.template_in = sim.sc.data.reshape(num_nodes)
def lung_downsample(sim): sim.dim = 3 sim.num_target_times = 5 sim.num_times_disc = 10 sim.num_times = sim.num_times_disc * sim.num_target_times + 1 sim.times = numpy.linspace(0, 1, sim.num_times) sim.dt = 1.0 / (sim.num_times - 1) sim.sigma = 0.1 sim.num_points_data = numpy.array([256, 184, 160]) sim.mults = numpy.array([2, 2, 2]).astype(int) sim.num_points = (sim.num_points_data / sim.mults).astype(int) sim.dx_data = (1.0, 1.0, 1.0) sim.domain_max_data = None sim.dx = None # (1.,1.,1.) sim.domain_max = numpy.array([128.0, 92.0, 80.0]) sim.gradEps = 1e-8 sim.rg = regularGrid.RegularGrid( sim.dim, num_points=sim.num_points, domain_max=sim.domain_max, dx=sim.dx, mesh_name="lddmm" ) sim.rg_data = regularGrid.RegularGrid( sim.dim, num_points=sim.num_points_data, domain_max=sim.domain_max_data, dx=sim.dx_data, mesh_name="lddmm_data" ) sim.I = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.I_interp = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.p = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sc = diffeomorphisms.gridScalars() sc.loadAnalyze(lung_image_dir + "test007.hdr") sim.I[:, 0.0 * sim.num_times_disc] = sim.apply_sync_filter(sc.data.reshape(sim.rg_data.num_nodes), sim.mults) sc.loadAnalyze(lung_image_dir + "test009.hdr") sim.I[:, 1.0 * sim.num_times_disc] = sim.apply_sync_filter(sc.data.reshape(sim.rg_data.num_nodes), sim.mults) sc.loadAnalyze(lung_image_dir + "test011.hdr") sim.I[:, 2.0 * sim.num_times_disc] = sim.apply_sync_filter(sc.data.reshape(sim.rg_data.num_nodes), sim.mults) sc.loadAnalyze(lung_image_dir + "test013.hdr") sim.I[:, 3.0 * sim.num_times_disc] = sim.apply_sync_filter(sc.data.reshape(sim.rg_data.num_nodes), sim.mults) sc.loadAnalyze(lung_image_dir + "test015.hdr") sim.I[:, 4.0 * sim.num_times_disc] = sim.apply_sync_filter(sc.data.reshape(sim.rg_data.num_nodes), sim.mults) sim.I /= 255.0 for t in range(sim.num_target_times): sim.rg.create_vtk_sg() sim.rg.add_vtk_point_data(sim.I[:, t * sim.num_times_disc], "I") sim.rg.vtk_write(t, "targets", output_dir=sim.output_dir) sim.pool_size = multiproc_pool_size sim.pool_timeout = multiproc_pool_timeout sim.write_iter = file_write_iter sim.verbose_file_output = False logging.info("lung data image parameters: ") logging.info("dimension: %d" % (sim.dim)) logging.info("num_points: %s" % (str(sim.rg.num_points))) logging.info("domain_max: %s" % (str(sim.rg.domain_max))) logging.info("dx: %s" % (str(sim.rg.dx))) logging.info("sigma: %f" % (sim.sigma)) logging.info("dt: %f" % (sim.dt))
def lung(sim): sim.dim = 3 sim.num_target_times = 4 sim.num_times_disc = 10 sim.num_times = sim.num_times_disc * sim.num_target_times + 1 sim.times = numpy.linspace(0, 1, sim.num_times) sim.dt = 1.0 / (sim.num_times - 1) sim.sigma = 1.0 sim.alpha = 7.0 # 5. sim.gamma = 1.0 sim.Lpower = 2.0 sim.num_points = numpy.array([256, 190, 160]) sim.dx = numpy.array([1.0, 1.0, 1.0]) sim.domain_max = None sim.cg_init_eps = 1e-3 sim.rg = regularGrid.RegularGrid( sim.dim, num_points=sim.num_points, domain_max=sim.domain_max, dx=sim.dx, mesh_name="lddmm" ) sim.I = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.I_interp = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.p = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.sc = diffeomorphisms.gridScalars() sim.sc.loadAnalyze(lung_image_dir + "ic007.hdr") sim.I[:, 0.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.sc.loadAnalyze(lung_image_dir + "ic009.hdr") sim.I[:, 1.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.sc.loadAnalyze(lung_image_dir + "ic011.hdr") sim.I[:, 2.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.sc.loadAnalyze(lung_image_dir + "ic013.hdr") sim.I[:, 3.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.sc.loadAnalyze(lung_image_dir + "ic015.hdr") sim.I[:, 4.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) for t in range(sim.num_target_times): sim.rg.create_vtk_sg() sim.rg.add_vtk_point_data(sim.I[:, t * sim.num_times_disc], "I") sim.rg.vtk_write(t, "targets", output_dir=sim.output_dir) sim.pool_size = multiproc_pool_size sim.pool_timeout = multiproc_pool_timeout sim.write_iter = file_write_iter sim.verbose_file_output = False logging.info("lung data image parameters: ") logging.info("dimension: %d" % (sim.dim)) logging.info("num_points: %s" % (str(sim.rg.num_points))) logging.info("domain_max: %s" % (str(sim.rg.domain_max))) logging.info("dx: %s" % (str(sim.rg.dx))) logging.info("sigma: %f" % (sim.sigma)) logging.info("dt: %f" % (sim.dt)) logging.info("kernel params- alpha: %f, gamma: %f, Lpower: %f" % (sim.alpha, sim.gamma, sim.Lpower))
def biocard(sim): sim.dim = 3 sim.num_target_times = 1 sim.num_times_disc = 10 sim.num_times = sim.num_times_disc * sim.num_target_times + 1 sim.times = numpy.linspace(0, 1, sim.num_times) sim.dt = 1.0 / (sim.num_times - 1) sim.sigma = 1.0 / 255.0 sim.alpha = 0.01 sim.gamma = 1.0 sim.Lpower = 2.0 sim.num_points = numpy.array([40, 32, 40]) sim.dx = numpy.array([0.9375, 2.0, 0.9375]) sim.domain_max = None sim.cg_init_eps = 1e-3 sim.rg = regularGrid.RegularGrid( sim.dim, num_points=sim.num_points, domain_max=sim.domain_max, dx=sim.dx, mesh_name="lddmm" ) sim.I = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.I_interp = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.p = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.sc = diffeomorphisms.gridScalars() sim.sc.loadAnalyze(biocard_image_dir + "regR2_cut.hdr") sim.I[:, 0.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes).copy() sim.sc.loadAnalyze(biocard_image_dir + "regR3_cut.hdr") sim.I[:, 1.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes).copy() # sim.sc.loadAnalyze(biocard_image_dir + "regR4_cut.hdr") # sim.I[:,2.*sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) # sim.sc.loadAnalyze(biocard_image_dir + "regR5_cut.hdr") # sim.I[:,3.*sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.pool_size = multiproc_pool_size sim.pool_timeout = multiproc_pool_timeout sim.write_iter = file_write_iter sim.verbose_file_output = False logging.info("Biocard image parameters: ") logging.info("dimension: %d" % (sim.dim)) logging.info("num_points: %s" % (str(sim.rg.num_points))) logging.info("domain_max: %s" % (str(sim.rg.domain_max))) logging.info("dx: %s" % (str(sim.rg.dx))) logging.info("sigma: %f" % (sim.sigma)) logging.info("dt: %f" % (sim.dt)) logging.info("kernel params- alpha: %f, gamma: %f, Lpower: %f" % (sim.alpha, sim.gamma, sim.Lpower))
def monkey(sim): sim.dim = 2 sim.num_target_times = 1 sim.num_times_disc = 10 sim.num_times = sim.num_times_disc * sim.num_target_times + 1 sim.times = numpy.linspace(0, 1, sim.num_times) sim.dt = 1.0 / (sim.num_times - 1) sim.sigma = 1.0 sim.alpha = 0.002 sim.gamma = 1.0 sim.Lpower = 2.0 sim.num_points = numpy.array([80, 80]) sim.domain_max = numpy.array([0.5, 0.5]) # sim.dx = numpy.array([1.,1.,1.]) sim.dx = None sim.rg = regularGrid.RegularGrid( sim.dim, num_points=sim.num_points, domain_max=sim.domain_max, dx=sim.dx, mesh_name="lddmm" ) sim.I = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.I_interp = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.p = numpy.zeros((sim.rg.num_nodes, sim.num_times)) sim.sc = diffeomorphisms.gridScalars() sim.sc.loadAnalyze("/cis/home/clr/cawork/monkey/monkey1_80_80.hdr") sim.I[:, 0.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) sim.sc.loadAnalyze("/cis/home/clr/cawork/monkey/monkey2_80_80.hdr") sim.I[:, 1.0 * sim.num_times_disc] = sim.sc.data.reshape(sim.rg.num_nodes) for t in range(sim.num_target_times): sim.rg.create_vtk_sg() sim.rg.add_vtk_point_data(sim.I[:, t * sim.num_times_disc], "I") sim.rg.vtk_write(t, "targets", output_dir=sim.output_dir) logging.info("monkey data image parameters: ") logging.info("dimension: %d" % (sim.dim)) logging.info("num_points: %s" % (str(sim.rg.num_points))) logging.info("domain_max: %s" % (str(sim.rg.domain_max))) logging.info("dx: %s" % (str(sim.rg.dx))) logging.info("sigma: %f" % (sim.sigma)) logging.info("dt: %f" % (sim.dt))