Skip to content

Commit

Permalink
Add a simple noise config
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonw committed Feb 18, 2025
1 parent bd84157 commit dbb2285
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions dacapo/experiments/trainers/gp_augments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .gamma_config import GammaAugmentConfig
from .intensity_config import IntensityAugmentConfig
from .intensity_scale_shift_config import IntensityScaleShiftAugmentConfig
from .noise_config import NoiseAugmentConfig
34 changes: 34 additions & 0 deletions dacapo/experiments/trainers/gp_augments/noise_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from .augment_config import AugmentConfig

import gunpowder as gp

import attr

from typing import Tuple


@attr.s
class NoiseAugmentConfig(AugmentConfig):
"""
This class manages the configuration of gamma augmentation for a given dataset.
Attributes:
gamma_range: A tuple of float values represents the min and max range of gamma noise
to apply on the raw data.
Methods:
node(): Constructs a node in the augmentation pipeline.
"""

kwargs: dict[str, any] = attr.ib(
metadata={
"help_text": "key word arguments for skimage `random_noise`. For more details see "
"https://scikit-image.org/docs/stable/api/skimage.util.html#skimage.util.random_noise"
},
factory=lambda: dict(),
)

def node(self, raw_key: gp.ArrayKey, _gt_key=None, _mask_key=None):
"""
Constructs a node in the augmentation pipeline.
"""
return gp.NoiseAugment(raw_key, **self.kwargs)

0 comments on commit dbb2285

Please sign in to comment.