-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major fix for get_s for BlocksOnCylindrical along with with minor changes #2
Conversation
There's still some gremlins here. In addition, there's too many white-space changes. I'd prefer that you undo them. This PR should be as small as possible. At the moment, I have to append We'll solve the formatting after merging the PRs. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still some white-space diffs left unfortunately.
Main thing is that the SSRB code doesn't look correct
error(boost::format("ScatterSimulation: limitation in #planes and voxel-size for the %1% image.\n" | ||
"This would cause a shift of %2%mm w.r.t. the activity image.\n" | ||
"(see https://github.com/UCL/STIR/issues/495.") | ||
% name % (z_to_middle - z_to_middle_standard)); | ||
% name % (z_to_middle - z_to_middle_standard)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space
else if (!is_null_ptr(proj_data_info_cyl_noarc_cor_sptr)) | ||
{ | ||
const float total_axial_length = proj_data_info_cyl_noarc_cor_sptr->get_scanner_sptr()->get_num_rings() * | ||
proj_data_info_cyl_noarc_cor_sptr->get_scanner_sptr()->get_ring_spacing(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space
// Find how much is the delta ring | ||
// If the previous projdatainfo had max segment == 1 then should be from SSRB | ||
// in ScatterEstimation. Otherwise use the max possible. | ||
int delta_ring = proj_data_info_cyl_noarc_cor_sptr->get_num_segments() == 1 ? 0 : | ||
new_scanner_sptr->get_num_rings()-1; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
white space
Completely reverted SSRB code. A proper implementation for SSRB will be given in separate PR. |
if (proj_data_info_ptr->get_scanner_ptr()->get_scanner_geometry() == "BlocksOnCylindrical") | ||
{ | ||
fovrad_in_mm = | ||
min((min(max_index.x(), -min_index.x()) - 5.f) * voxel_size.x(), | ||
(min(max_index.y(), -min_index.y()) - 5.f) * voxel_size.y()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document why you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reducing the fovrad_in_mm
prevent memory leak. Due to radius problem in "BlocksOnCylindrical" it might perform ray tracing where voxels doesn't exist. This might be the source of memory leak. I don't know too much about C++ technicality behind this but I know that if I perform reconstruction without -5.f
or use +5.f
then memory leak will occur. This I have tested.
will need to add some code to |
// BlocksOnCylindrical geometry is already align no shifted needed. | ||
this->shift_detector_coordinates_to_origin = | ||
CartesianCoordinate3D<float>(0,0,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In @danieldeidda's change, we shifted the "blocks" geometry to coincide with the cylindrical one. (i.e. 0 in first ring), so we will need to replace this code with the same as the lines above
if (costheta < 0.0001) { | ||
costheta = 0.0001; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what we think for get_tantheta()
independent of R
CartesianCoordinate3D<float> _p1;
CartesianCoordinate3D<float> _p2;
find_cartesian_coordinates_of_detection(_p1, _p2, bin);
CartesianCoordinate3D<float> p2_minus_p1 = _p2 - _p1;
return p2_minus_p1.z() / (sqrt(square(p2_minus_p1.x())+square(p2_minus_p1.y());
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
Thanks! Sadly, we cannot merge as there is a conflict in In particular, Can you merge |
@@ -668,6 +669,7 @@ calculate_proj_matrix_elems_for_one_bin( | |||
|
|||
phi = proj_data_info_noarccor.get_phi(bin); | |||
s_in_mm = proj_data_info_noarccor.get_s(bin); | |||
tantheta = proj_data_info_noarccor.get_tantheta(bin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it repeated here? You've already set it above. (in fact, s_in_mm
is also set above)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was set before I downcast the projection data so it would be accessible outside if statement and repeated inside the if statement to get correct value from each geometry of projection data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_tantheta
is virtual
, so downcasting or not makes no difference: it will call the same function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know this. What would happen if there is multiple get_tantheta()
for each geometry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pointer points to one particular object. Calling one of its virtual functions will call the one from its type, even if the pointer is from a base type. "run-time polymorphism" :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found 2 more things. sorry.
I also noticed you marked several of my requests to reinstate white-space/comment to the original lines as "resolved", but they are still there. Not sure why you did that. However, this is a minor thing, so feel free to ignore.
|
||
float costheta = 1/sqrt(1+square(tantheta)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact, these lines can now be reinstated, and all the tantheta
lines above removed, which will lead to a smaller change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sorry, I thought I made the changes to fix the white space problem so I marked as resolve. Not too sure if it's me or you who should be marking them as resolved, if it's not resolved just mark them as unresolved again.
As for the git conflict, do I do git merge master
? My plan is probably add Daniels changes then delete the "X" orientation code after.
what you should normally do is (assuming that you called the remote pointing to Parisa's fork
This will pull in Daniel's new test but also the conflicting edits, which is why you need to resolve them. (i.e. no need to remove the "X" configuration again) |
Looks like I cannot "unresolve". Have a look at the diff in |
see start_x*/ | ||
|
||
//calculate start_point to build the map. | ||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well. no. You've now committed the file that contains the conflict, i.e. it has both versions (your code here, and the original pkhateri/master
code below). You need to manually edit the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok figured out what happened. VS code trying to be helpful shows the conflict as an overlay and some options to resolve the conflict. Unfortunately, unless I select an option it will keep both changes which is what it did :) .
great. thanks. Can you sort out the |
@danieldeidda @emikhay this is nearly ready. Any objections from anyone to squash-merge (as opposed to merge) when done? The disadvantage is that it gets you into trouble if you've merged this PR somewhere else already. The advantage however is that it removes a lot of the back and forth commits, so I'd prefer that. If no problem, @VietAnhDao it'd help if you draft a commit message for the squash-merge, i.e. a few bullets with the actual changes that survived. |
- s coodrinate is derived from vectors. - tantheta is derived from vectors. - scatter simulation accept BlocksOnCylindrical.
done :) . I hope I've removed all the white space. |
almost, but fine 😄 |
- s coodrinate is derived from vectors. - tantheta is derived from vectors. - scatter simulation accept BlocksOnCylindrical. - remove X orientation.
I have now :) |
Summary of the changes:
|
Now I find that I cannot merge this... @pkhateri could you squash-merge with the above commit message? |
@pkhateri or give me write permission to your |
- get_s and get_tantheta are derived from end-points. - scatter simulation accept BlocksOnCylindrical. - remove X orientation. squashed commit of #2 Co-authored-by: Kris Thielemans <KrisThielemans@users.noreply.github.com>
I've squash-merged this on the Thanks @VietAnhDao ! |
Nice ! bit messy but worked out in the end :) do you want me to close this? I do have the "Close with comment" option. |
yes please |
Pull request accepted. |
No description provided.