Closed dericdesta closed 5 months ago
Alright, I think I figured it out (old code lines commented out):
displace the detector in x-direction
float lateral_detector_displacement = 16.0; // lateral detector displacement [cm] (along x-axis)
float3 detector_center; // Center of the detector straight ahead of the focal spot.
detector_center.x = source_data[0].position.x + source_data[0].direction.x * detector_data[0].sdd - lateral_detector_displacement;
detector_center.y = source_data[0].position.y + source_data[0].direction.y * detector_data[0].sdd;
detector_center.z = source_data[0].position.z + source_data[0].direction.z * detector_data[0].sdd;
adjust the phi aperture to cover the displaced detector
if ( (theta_aperture < -1.0e-7) || (phi_aperture < -1.0e-7) ) // If we enter a negative angle, the fan beam will cover exactly the detector surface.
{
theta_aperture= 2.0 * atan(0.5*detector_data[0].height_Z/(detector_data[0].sdd)) * RAD2DEG; // Optimum angles
//OLD: phi_aperture = 2.0 * atan(0.5*detector_data[0].width_X/(detector_data[0].sdd)) * RAD2DEG;
double phi_1, phi_2;
//calculate phi1 and phi2 using lateral detector displacement
phi_1 = atan((detector_data[0].width_X/2.0 - lateral_detector_displacement)/detector_data[0].sdd) * RAD2DEG;
phi_2 = atan((detector_data[0].width_X/2.0 + lateral_detector_displacement)/detector_data[0].sdd) * RAD2DEG;
phi_aperture = (phi_2 + phi_1);
source_data[0].cos_theta_low = (float)( cos((90.0 - 0.5*theta_aperture)*DEG2RAD) );
source_data[0].D_cos_theta = (float)( -2.0*source_data[0].cos_theta_low ); // Theta aperture is symetric above and below 90 deg
//OLD: source_data[0].phi_low = (float)( (90.0 - 0.5*phi_aperture)*DEG2RAD );
source_data[0].phi_low = (float)( (90.0 - phi_1)*DEG2RAD );
source_data[0].D_phi = (float)( phi_aperture*DEG2RAD );
source_data[0].max_height_at_y1cm = (float) ( tan(0.5*theta_aperture*DEG2RAD) );
}
I'm quite sure that more code needs to be modified, but let's see...
I will also add lateral detector displacement to the input file format (with default = 0). Ping me, if I should open a PR.
Best, Frederic
Hi Frederic,
I think your solution is correct. Thanks for sharing the problem and the code solving it. I was going to suggest a simpler solution (keep a larger detector than needed --not a problem to waste a little memory-- and reject unwanted sampled angles in the kernel source function) but your solution is more efficient. Please verify that the with the modified code the source sampling is correct and that you are modeling the exact geometry you want. Check the usual geometric suspects: do you need to add or subtract "lateral_detector_displacement"?, is the photon distribution in a flat field consistent after changing the angles?, etc.
Best regards,
Andreu
Hi there, thank you for this great framework! I want to simulate a half-fan CBCT (like, e.g., a Varian TrueBeam CBCT is doing it for larger FOV protocols, see here for a schematic). So I want to shift the flat panel detector laterally by some amount. Currently I'm doing it by extending the detector laterally to both sides and cutting away "non-existent" detector space on the projections after simulation. However, this is obviously quite inefficient. So is there a simple way to implement this into MCGPU? I'm happy to do a PR if someone could give me some pointers where code needs to be modified.
Cheers, Frederic!