dp_augmentor update#130
Conversation
…re settings. Implemented compatibility with multichannel labels.
… original augmentor order.
arthurmccray
left a comment
There was a problem hiding this comment.
Overall looks good. Main things are whether the background_label_application flag should exist and the order of when to apply_bkg. Also please attach the updated tutorial notebook to the PR.
|
If I may, would there be a quick and dirty notebook? Love to try this class |
…ion and implemented that functionality in apply_background_to_label, which is now either list or None to reflect this. If None, will not apply, otherwise will apply background to labels according to boolean list. Updated _apply_bkg to incorporate ZiXi's correction for shifts. Changed defaults of gaussian noise to be 0 for mu, 1e-5 for std, and updated docstring to reflect that this scaling is based on total electron dose. Changed application order to be elastic->background. Added aperature related attributes to docstring, and fixed typo in docstring. Added warning if single channel passed to multichannel functions.
|
Heads-up: you'll need to pull dev into the PR to enable the updated automated checks. |
|
@NJMarchese also just a note/reminder to also update the tutorial |
a2d6fc0 to
b9652e1
Compare
…ft to coordinates in Fourier space if apply_shift is true. Also removed aperture code as beyond current scope of PR.
|
Please update the tutorial so that the code can be tested/validated, and please also respond to the remaining comments. Also consider writing a few pytests (or more realistically, having an LLM do so) |
arthurmccray
left a comment
There was a problem hiding this comment.
see above comments, realized i didn't officially "submit review" yet
NJMarchese
left a comment
There was a problem hiding this comment.
Figured out that comments won't be visible until review submitted
There was a problem hiding this comment.
Cool almost there! Just a couple things I found when trying to run the notebook (which failed at first due to an import error). Also please include the outputs of the notebook on the github, it's very useful so that people can see online what it does!
--edit-- actually the notebook isn't running? Errors in the 1a cell:
- and maybe don't use
pandas, justnumpyto read the csv since that's a dependency already?
ValueError Traceback (most recent call last)
Cell In[4], line 3
1 aug_90 = DPAugmentor(add_flipshift=True, free_rotation=False, rng=0)
2 dp_90 = aug_90.augment(dp)
----> 3 aug_90.print_params()
5 aug_free = DPAugmentor(add_flipshift=True, free_rotation=True,
6 rotation_range=[-180, 180], rng=1)
7 dp_free = aug_free.augment(dp)
File ~/code/quantem/src/quantem/core/utils/augment_dp.py:340, in DPAugmentor.print_params(self, print_all)
314 print(">" * 32)
316 params = [
317 (
318 "Inelastic background",
(...)
337 ("Gaussian blur", self.add_blur, f"Sigma: {self.blur_sigma:.2f}"),
338 ]
--> 340 for name, enabled, details in params:
341 print(f"{name}: {enabled}")
342 if (enabled or print_all) and details:
ValueError: too many values to unpack (expected 3)
|
|
||
| from quantem.core import config | ||
| from quantem.core.utils import array_funcs as af | ||
| from quantem.core.utils.utils import RNGMixin |
There was a problem hiding this comment.
this fails--RNGMixin is in quantem.core.utils.rng, not sure how it was able to run on your end.
| if TYPE_CHECKING: | ||
| import torch | ||
| import torch.nn.functional as F | ||
|
|
||
| if config.get("has_torch"): | ||
| import torch | ||
| import torch.nn.functional as F |
There was a problem hiding this comment.
torch is a required dependency now, you can just import torch normally
Added an option to apply the background to the labels as well (this was implemented for purpose of adding to the background label image, so amorphous halos + background). The background_label_application is a boolean list (or None) that indicates which label channels to apply the background to if apply_background_to_label is true.
Added gaussian noise, with parameters relative to electron dose.
Implemented ability to work with multichannel labels.
Added preliminary sections for apertures.