def create_trip_exec_simple(self, no_output=False): """ Generates the .exec script and stores it into self.trip_exec. """ logger.info("Generating the trip_exec script...") oar_list = self.oar_list targets = self.targets fields = self.plan.get_fields() projectile = fields[0].get_projectile() output = [] output.extend(self.create_exec_header()) output.extend(self.create_exec_load_data_files(projectile)) output.extend(self.create_exec_field(fields)) output.extend(self.create_exec_oar(oar_list)) dosecube = None if len(targets) > 1: dosecube = DosCube(self.images) for i, voi in enumerate(targets): temp = DosCube(self.images) dose_level = int(voi.get_dose() / self.target_dose * 1000) if dose_level == 0: dose_level = -1 temp.load_from_structure(voi.get_voi().get_voi_data(), dose_level) if i == 0: dosecube = temp * 1 else: dosecube.merge_zero(temp) dosecube.cube[dosecube.cube == -1] = int(0) if not self.plan.get_target_dose_cube() is None: dosecube = self.plan.get_target_dose_cube() if dosecube is not None: if not no_output: dosecube.write(os.path.join(self.path, "target_dose.dos")) output.extend(self.create_exec_plan(incube="target_dose")) else: output.extend(self.create_exec_plan()) if self.plan.get_optimize(): output.extend(self.create_exec_opt()) name = self.plan_name output.extend(self.create_exec_output(name, fields)) out = "\n".join(output) + "\nexit\n" self.trip_exec = out
def test_write(self): c = DosCube() c.read(self.cube000) fd, outfile = tempfile.mkstemp() os.close(fd) # Windows needs it os.remove(outfile) # we need only temp filename, not the file c.write(outfile) hed_file = outfile + DosCube.header_file_extension dos_file = outfile + DosCube.data_file_extension self.assertTrue(os.path.exists(hed_file)) self.assertTrue(os.path.exists(dos_file)) logger.info("Checking if output file " + hed_file + " is not empty") self.assertGreater(os.path.getsize(hed_file), 1) logger.info("Checking if output file " + dos_file + " is not empty") self.assertGreater(os.path.getsize(dos_file), 1) os.remove(hed_file) os.remove(dos_file)
def test_write(self): c = DosCube() c.read(self.cube000) fd, outfile = tempfile.mkstemp() os.close(fd) # Windows needs it os.remove(outfile) # we need only temp filename, not the file c.write(outfile) hed_file = outfile + ".hed" dos_file = outfile + ".dos" self.assertTrue(os.path.exists(hed_file)) self.assertTrue(os.path.exists(dos_file)) logger.info("Checking if output file " + hed_file + " is not empty") self.assertGreater(os.path.getsize(hed_file), 1) logger.info("Checking if output file " + dos_file + " is not empty") self.assertGreater(os.path.getsize(dos_file), 1) os.remove(hed_file) os.remove(dos_file)