Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Denoising via adaptive binning.

License

NotificationsYou must be signed in to change notification settings

maurosilber/binlets

Repository files navigation

PackagePyVersionLicenseCodeStyleCIpre-commit.ci statusPaper

Usage

binlets requires an array of data,and a test function to compare two data points.

Single-channel with Poisson statistics

For instance,for single-channel signal with Poisson statistics:

defchi2_test(x:NDArray,y:NDArray)->NDArray[bool]:"""Compares two values with Poisson noise using a χ² test."""diff=x-yvar_diff=x+y# Poisson variancereturndiff**2<=var_diffdenoised=binlets(data,test=chi2_test,levels=None,# max averaging area is 2**levels. By default, floor(log2(min(data.shape)))linear=True,# the transformation is linear (x - y))

We recomend wrapping this in a function,and providing an extra parameter to adjust the significance level:

defpoisson_binlets(data:NDArray,*,n_sigma:float,levels:int|None=None):defchi2_test(x:NDArray,y:NDArray)->NDArray[bool]:"""Compares two values with Poisson noise using a χ² test."""diff=x-yvar_diff=x+y# Poisson variancereturndiff**2<=n_sigma**2*var_diffdenoised=binlets(data,test=chi2_test,linear=True,    )returndenoised

Ratio of multichannel-data

For multichannel data,binlets expects channels to be in the first dimension of the data array.That is,data.shape should be(N_CHANNELS, *spatial_dimensions).

defratio(channels):"""Statistic of interest."""returnchannels[1]/channels[0]deftest(x,y):# The test of your choice. For instance, a χ² test.diff=ratio(x)-ratio(y)var_diff=ratio_var(x)+ratio_var(y)returndiff**2<=var_diffdenoised=binlets(data,test=test, ...)# the same as beforedenoised_ratio=ratio(denoised)

Installation

Binlets can be installed from PyPI:

pip install binlets

or conda-forge:

conda installl -c conda-forge binlets

Development

To set up a development environment in a new conda environment, run the following commands:

git clone https://github.com/maurosilber/binletscd binletsconda env create -f environment.ymlconda activate binletspre-commit install

About

Denoising via adaptive binning.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp