-
Notifications
You must be signed in to change notification settings - Fork 21
dp_augmentor update #130
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: dev
Are you sure you want to change the base?
dp_augmentor update #130
Conversation
…re settings. Implemented compatibility with multichannel labels.
… original augmentor order.
| self._setup_device(device) | ||
| self.log_file = log_file | ||
|
|
||
| self.set_params( |
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 don't think a set_params method is necessary, the assignments can happen in __init__
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 set_params was a method from the original version of the augmentor. Personally I'd rather have that change be in a separate PR.
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.
might as well do it in this PR? should be a simple change
src/quantem/core/utils/augment_dp.py
Outdated
| def _apply_bkg_to_multichannel_label(self, label: ArrayLike, probe: ArrayLike | None = None) -> ArrayLike: | ||
| """Apply background to specified channels of multichannel label""" | ||
| if len(label.shape) != 3: | ||
| # Single channel label - shouldn't normally happen |
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 raise an error then
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.
Added warning.
| self.generate_params() | ||
| self._init_log_file() | ||
|
|
||
| def _setup_device(self, device: str) -> None: |
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.
not sure if it's worth updating this now, but we do have quantem.config for device management and array_funcs for handling torch or numpy more easily. https://github.com/electronmicroscopy/quantem/blob/dev/src/quantem/core/utils/array_funcs.py
| if len(transformed_label.shape) == 3: | ||
| transformed_label = self._apply_bkg_to_multichannel_label(transformed_label, probe) | ||
|
|
||
| if self.add_ellipticity or self.add_shift or self.add_scale: |
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.
shouldn't adding ellipticity/shift/scaling be done before adding background? Otherwise there will be a hard edge to the noise after the shift/scale. You will need to also update the add_bkg function to account for the shifted center (see Zixi's updated augmentor file I sent you a while back for an implementation of that).
arthurmccray
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.
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. |
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.