Skip to content

dp_augmentor update#130

Open
NJMarchese wants to merge 6 commits intodevfrom
dp_augmentor
Open

dp_augmentor update#130
NJMarchese wants to merge 6 commits intodevfrom
dp_augmentor

Conversation

@NJMarchese
Copy link
Collaborator

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.

Nicholas Marchese added 2 commits December 5, 2025 11:19
…re settings. Implemented compatibility with multichannel labels.
if len(label.shape) != 3:
# Single channel label - shouldn't normally happen
return label
if len(self.background_label_application) == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove background_label_application and just allow apply_background_to_label to accept a list

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:
Copy link
Collaborator

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).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that as currently implemented, the apply_bkg method is incorrect if there have been shifts applied. It will be centering the inelastic background on the center of the image, rather than on the shifted center, and this needs to be fixed before merging.

Copy link
Collaborator

@arthurmccray arthurmccray left a 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.

@bobleesj
Copy link
Collaborator

bobleesj commented Dec 7, 2025

If I may, would there be a quick and dirty notebook? Love to try this class

Nicholas Marchese added 2 commits December 16, 2025 08:25
…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.
@gvarnavi
Copy link
Collaborator

Heads-up: you'll need to pull dev into the PR to enable the updated automated checks.

@arthurmccray
Copy link
Collaborator

@NJMarchese also just a note/reminder to also update the tutorial


if self.add_bkg:
result = self._apply_bkg(result, probe)
if transformed_label is not None and self.apply_background_to_label is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm just forgetting, but what is the case where we would want to apply_background_to_label? I can't think of one, and as the logic is broken here, I'm guessing it isn't actually used and should be removed.

Device for computations ("cpu", "cuda", "cuda:0", etc.).

add_aperture : bool, default=False
Enable circular aperture mask to simulate objective aperture effects.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for simulating a HAADF detector having been inserted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants