Skip to content

Commit

Permalink
Fix ROI location
Browse files Browse the repository at this point in the history
  • Loading branch information
malago86 committed Jun 15, 2021
1 parent 5fb05be commit 95f16dd
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Victre/Pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"] /
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 95f16dd

Please sign in to comment.