-
Notifications
You must be signed in to change notification settings - Fork 10
Feature/ft projector (draft) #124
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
base: master
Are you sure you want to change the base?
Conversation
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.
Thank you very much!
Re DeepSource:
The DeepSource errors can be accessed by clicking on "Details" next to the GitHub workflow called "DeepSource", or equivalently at this link.
- I believe the issues found by DeepSource can be addressed. Let us know if you see a blockage?
Re Test:
The Test errors can be accessed by clicking on "Details" next to the GitHub workflow called "Test", or equivalently at this link.
I have copy-pasted the error below, it seems that the projector has been initialized without a space attribute.
- I believe this can be fixed too? Let us know if not.
tests/test_linear_simulator.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
simSPI/linear_simulator/linear_simulator.py:30: in __init__
self.projector = Projector(config)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Projector()
config = {'chunks': 4, 'pixel_size': 0.8, 'cs': 2.7, 'amplitude_contrast': 0.1, 'ctf_size': 32, 'noise': False, 'noise_sigma': ...ise_distribution': 'gaussian', 'input_volume_path': '', 'side_len': 32, 'kv': 300, 'value_nyquist': 0.1, 'b_factor': 0}
def __init__(self, config):
"""Initialize volume grid."""
super(Projector, self).__init__()
self.config = config
> self.space = config.space
E AttributeError: 'AttrDict' object has no attribute 'space'
|
Linking to issue #102 |
|
Hmmm, I just fixed the linear simulator test in my local branch but can't seem to push the change. Any ideas why? |
|
Ok, got the changes pushed, the linear_simulator test should be fixed now. |
Codecov Report
@@ Coverage Diff @@
## master #124 +/- ##
==========================================
- Coverage 98.39% 97.94% -0.44%
==========================================
Files 15 15
Lines 744 776 +32
==========================================
+ Hits 732 760 +28
- Misses 12 16 +4
Continue to review full report at Codecov.
|
ninamiolane
left a comment
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.
LGTM, thank you! I made minor comments.
|
|
||
| self.register_buffer("vol_coords", coords.reshape(-1, 3)) | ||
| elif self.space == "fourier": | ||
| # Assume DC coefficient is at self.vol[n//2+1,n//2+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.
This comment could be moved in a docstring, so that it is more visible by users --- when we will publish the documentation website with Sphinx.
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.
This relates a bit to my comment in issue #102, we should try to standardize somewhere the conventions for Fourier space representations. Then it doesn't really need to be anywhere... I'm also not sure that this is currently accurate.
| Parameters | ||
| ---------- | ||
| rot_params : tensor of rotation matrices |
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 description of rot_params does not strictly follow the docstring convention:
- if it is a tensor, what is its shape
- it should be on two lines, where the first line explains the type of datastructure and the second explains what the parameter represents.
This will become important to generate a clean documentation website.
Additionally, this description says that rot_params is a tensor; yet _forward_fourier docstring mentions a dict: which one is true?
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.
Maybe this docstring could point to _forward_fourier docstring about the details? I find it well explained there that rot_params is a dictionary that contains a tensor of specific shape.
|
|
||
| # rescale the coordinates to be compatible with the edge alignment of | ||
| # torch.nn.functional.grid_sample | ||
| if self.config.side_len % 2 == 0: # even case |
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 comments even case and odd case might not be necessary as it is evident from the code.
| (batch_sz, self.config.side_len, self.config.side_len), | ||
| dtype=torch.complex64, | ||
| ) | ||
| # interpolation is decomposed to real and imaginary parts due to torch |
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.
Should this be put in a docstring?
| def test_projector_fourier(): | ||
| """Test accuracy of projector function. | ||
| Note: corrent test only checks that the scaling is compatible. |
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.
Typo: current
| torch.fft.fftshift(saved_data["projector_output"], dim=(2, 3)) | ||
| ) | ||
|
|
||
| print(out.dtype) |
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 think we should avoid prints in the tests because our logs might become overcrowded when we add more tests: could these become asserts?
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 agree, maybe these could be replaced with logging, so they could be displayed if really needed?
fredericpoitevin
left a comment
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.
Thanks so much! This is a great addition 🙏
| def _forward_fourier(self, rot_params): | ||
| """Output the tomographic projection of the volume in Fourier space. | ||
| Take a slide through the Fourier space volume whose normal is |
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.
Typo: slice
| Parameters | ||
| ---------- | ||
| rot_params : tensor of rotation matrices |
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.
Maybe this docstring could point to _forward_fourier docstring about the details? I find it well explained there that rot_params is a dictionary that contains a tensor of specific shape.
| torch.fft.fftshift(saved_data["projector_output"], dim=(2, 3)) | ||
| ) | ||
|
|
||
| print(out.dtype) |
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 agree, maybe these could be replaced with logging, so they could be displayed if really needed?
There are a few caveats in this merge.
Checklist
Verify that your PR checks all the following items.
test_*.py filescorresponding the files modified by this PR,If some items are not checked, mark your PR as draft (Look for "Still in progress? Convert to Draft" on your PR) . Only mark the PR as "Ready for review" if all the items above are checked.
If you do not know how to address some items, reach out to a maintainer by requesting reviewers.
If some items cannot be addressed, explain the reason in the Description of your PR, and mark the PR ready for review
Description
Issue
Additional context