Hello @zivy,
thank you very much for your reply.
i made changes to the code and my function looked like this, for future readers:
import numpy as np
import SimpleITK as sitk
import time
def oblique_slice(self, theta_x_degrees:float, theta_y_degrees:float, theta_z_degrees:float, slice_size:list[int], slice_index:list[int]) -> np.array:
"""
extrai um slice obliquo do volume e retorna em formato de array numpy
"""
theta_x_radians = np.deg2rad(theta_x_degrees)
theta_y_radians = np.deg2rad(theta_y_degrees)
theta_z_radians = np.deg2rad(theta_z_degrees)
rotation_matrix = sitk.Euler3DTransform()
rotation_matrix.SetRotation(theta_x_radians, theta_y_radians, theta_z_radians)
time1 = time.time()
rotated_volume = sitk.Resample(self.volume, rotation_matrix)
time2 = time.time()
print(f"resample timer = {time2 - time1}")
slice_extraction = sitk.Extract(rotated_volume, slice_size, slice_index)
return sitk.GetArrayFromImage(slice_extraction)
With this parrameters i will be able to implement mpr function.
I am trying to optimize this code because Resample are taking too much time, approximately 0.04/0.045 seconds, which gives me 20 frames per second.
In my MainSettings i set:
sitk.ProcessObject.SetGlobalDefaultNumberOfThreads(multiprocessing.cpu_count())
And now i’m trying to use gpu with pytorch or tensorflow, after reading this:
which by coincidence you answered too, lol!
I will bring news in case I get something.