From 95f16dd0c4683b2656c942cfc3c54e7869302528 Mon Sep 17 00:00:00 2001 From: malago86 Date: Tue, 15 Jun 2021 11:54:45 -0400 Subject: [PATCH] Fix ROI location --- Victre/Pipeline.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/Victre/Pipeline.py b/Victre/Pipeline.py index e5de4f4..444c0f0 100644 --- a/Victre/Pipeline.py +++ b/Victre/Pipeline.py @@ -468,8 +468,7 @@ def _output_to_list(x): return x.decode('ascii').split('\n')[:-1] else: ssh_command = "ssh -Y {:s} \"{:s}\"".format( self.ips["gpu"], command) - # print(os.system("cd {:s} && ls -la ./Victre/projection/MC-GPU_v1.5b.x > log.txt".format(os.getcwd()))) - # os.system(ssh_command, sh) + cprint("Initializing MCGPU for {:s}...".format( filename), 'cyan') if self.verbosity else None @@ -677,8 +676,6 @@ def reconstruct(self): else: ssh_command = "ssh -Y {:s} \"{:s}\"".format( self.ips["cpu"], command) - # print(ssh_command) - # res = os.popen(ssh_command).read() self.recon_size = dict( x=np.ceil(self.arguments_recon["voxels_x"] * self.arguments_recon["voxel_size"] / @@ -829,7 +826,7 @@ def get_coordinates_dm(self, vx_location): location[1] += det_origin[1] # we figured out by looking at the voxels and pixels that Y - location[1] = self.arguments_recon["detector_elements"] - location[1] + location[1] = self.arguments_mcgpu["image_pixels"][0] - location[1] return location[0], location[1] @@ -985,10 +982,6 @@ def save_DICOM_one(data, count): ds.fix_meta_info() - # print("Writing test file", - # "./results/{:d}/DICOM/{:03d}.dcm".format(self.seed, count)) - # ds.save_as("./results/{:d}/DICOM/{:03d}.dcm".format(self.seed, count)) - pydicom.filewriter.dcmwrite( "{:s}/{:d}/DICOM_{:s}/{:03d}.dcm".format( self.results_folder, self.seed, modality, count), ds, @@ -1115,7 +1108,6 @@ def generate_spiculated(self, seed=None, size=None): os.getcwd(), self.arguments_spiculated["seed"]) - # print(command) cprint("Generating mass (seed={:d}, size={:.2f})...".format( self.arguments_spiculated["seed"], self.arguments_spiculated["alpha"]), 'cyan') if self.verbosity else None os.system(command) @@ -1643,6 +1635,18 @@ def compress_phantom(self, thickness=None): self.arguments_recon["voxels_y"] = self.arguments_mcgpu["number_voxels"][0] self.arguments_recon["voxels_z"] = self.arguments_mcgpu["number_voxels"][2] + self.recon_size = dict( + x=np.ceil(self.arguments_recon["voxels_x"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_pixel_size"]).astype(int), + y=np.ceil(self.arguments_recon["voxels_y"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_pixel_size"]).astype(int), + z=np.ceil(self.arguments_recon["voxels_z"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_thickness"]).astype(int) + ) + + self.arguments_mcgpu["source_position"][1] = self.arguments_mcgpu["number_voxels"][1] * \ + self.arguments_mcgpu["voxel_size"][1] / 2 + self.candidate_locations = np.loadtxt( "{:s}/{:d}/pc_{:d}.loc".format(self.results_folder, self.seed, self.seed), delimiter=',').tolist() @@ -1697,6 +1701,18 @@ def crop(self, size=None): self.arguments_recon["voxels_y"] = self.arguments_mcgpu["number_voxels"][0] self.arguments_recon["voxels_z"] = self.arguments_mcgpu["number_voxels"][2] + self.recon_size = dict( + x=np.ceil(self.arguments_recon["voxels_x"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_pixel_size"]).astype(int), + y=np.ceil(self.arguments_recon["voxels_y"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_pixel_size"]).astype(int), + z=np.ceil(self.arguments_recon["voxels_z"] * self.arguments_recon["voxel_size"] / + self.arguments_recon["recon_thickness"]).astype(int) + ) + + self.arguments_mcgpu["source_position"][1] = self.arguments_mcgpu["number_voxels"][1] * \ + self.arguments_mcgpu["voxel_size"][1] / 2 + with gzip.open("{:s}/{:d}/pc_{:d}_crop.raw.gz".format(self.results_folder, self.seed, self.seed), 'wb') as f: f.write(np.ascontiguousarray(phantom))