Skip to content
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

Next-Gen Dataset: Exclude background patches during training #293

Open
jdeschamps opened this issue Dec 6, 2024 · 0 comments
Open

Next-Gen Dataset: Exclude background patches during training #293

jdeschamps opened this issue Dec 6, 2024 · 0 comments
Labels
feature New feature or request
Milestone

Comments

@jdeschamps
Copy link
Member

jdeschamps commented Dec 6, 2024

Problem

In microscopy, images often contain large background areas. During training, this will cause the network to spend substantial amount of time learning "nothing". Being able to exclude background regions would be a useful feature that many users would probably enjoy.

Potential solutions

Solution 1: CSBDeep-style

There is no reason not to copy what has been developed before in CSBDeep:

# parameters:
# threshold
# percentile
from scipy.ndimage import maximum_filter
def _filter(datas, patch_size, dtype=np.float32):
    image = datas[0]
    if dtype is not None:
        image = image.astype(dtype)
    # make max filter patch_size smaller to avoid only few non-bg pixel close to image border
    patch_size = [(p//2 if p>1 else p) for p in patch_size]
    filtered = maximum_filter(image, patch_size, mode='constant')
    return filtered > threshold * np.percentile(image,percentile)
return _filter

Source

Solution 2: use mean and std

Exclude patches whose mean is N standard deviation away from the dataset mean.

Relevant other issues

#292

@jdeschamps jdeschamps added the feature New feature or request label Dec 6, 2024
@jdeschamps jdeschamps changed the title Exclude background patches durint training Exclude background patches during training Dec 6, 2024
@jdeschamps jdeschamps added this to the v0.1.0 milestone Dec 17, 2024
@jdeschamps jdeschamps moved this to Backlog in v0.1.0 Jan 27, 2025
@jdeschamps jdeschamps changed the title Exclude background patches during training Next-Gen Dataset: Exclude background patches during training Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

1 participant