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

Add smoothing of contour plots using Gaussian filtering #268

Merged
merged 7 commits into from
Mar 16, 2021

Conversation

Cornelius-G
Copy link
Collaborator

Allows smoothing of contour plots using Gaussian filtering (via ImageFiltering.jl).

Without smoothing:
p = plot(samples, (:a, :c), st=:smallest_intervals_contour, bins=100, smoothing=0)
no_smoothing

With smoothing:
p = plot(samples, (:a, :c), st=:smallest_intervals_contour, bins=100, smoothing=1.5)
with_smoothing

Also possible to smooth the dimensions separately:
p = plot(samples, (:a, :c), st=:smallest_intervals_contour, bins=100, smoothing=(0, 1.5))
with_smoothing_y

(Also replaced all remaining "local modes" by "marginal modes")

@codecov-io
Copy link

codecov-io commented Mar 13, 2021

Codecov Report

Merging #268 (9db5d58) into master (a24f3d6) will increase coverage by 2.68%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #268      +/-   ##
==========================================
+ Coverage   55.60%   58.28%   +2.68%     
==========================================
  Files         109      109              
  Lines        5257     5550     +293     
==========================================
+ Hits         2923     3235     +312     
+ Misses       2334     2315      -19     
Impacted Files Coverage Δ
src/BAT.jl 85.71% <ø> (+2.38%) ⬆️
src/algotypes/mode_estimator.jl 37.50% <ø> (+8.92%) ⬆️
src/plotting/recipes_MarginalDist_2D.jl 0.00% <0.00%> (ø)
src/plotting/recipes_samples_1D.jl 0.00% <0.00%> (ø)
src/plotting/recipes_samples_2D.jl 0.00% <0.00%> (ø)
src/densities/abstract_density.jl 97.29% <0.00%> (-1.24%) ⬇️
src/utils/coord_utils.jl 100.00% <0.00%> (ø)
src/statistics/autocor.jl 100.00% <0.00%> (ø)
src/distributions/funnel.jl 100.00% <0.00%> (ø)
src/densities/const_density.jl 100.00% <0.00%> (ø)
... and 69 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a24f3d6...9db5d58. Read the comment docs.

@oschulz
Copy link
Member

oschulz commented Mar 13, 2021

This is very nice - only, ImageFiltering would be quite a heavy additional dependency for BAT, it pulls in several other imaging-related packages that we don't need at all. Can we find a similar functionality/algorithms in a more statistics-oriented Julia package?

@oschulz
Copy link
Member

oschulz commented Mar 13, 2021

We already depend on KernelDensity.jl, could we maybe do this via BivariateKDE?

@Cornelius-G
Copy link
Collaborator Author

We already depend on KernelDensity.jl, could we maybe do this via BivariateKDE?

This was actually also my first idea. However, the things I tried with KDEs (and also with grid interpolations) did not really improve the contours.
I'll see if I can find some more light-weight filtering algorithms.

@Cornelius-G
Copy link
Collaborator Author

Cornelius-G commented Mar 15, 2021

So, I removed the dependency on ImageFiltering.jl and added a file convolution_utils.jl that contains very basic code for a convolution (including padding) and Gaussian kernels.
The implementation is really simplistic and quickly put together from the code here and here, but seems to work.
Unfortunately, I currently don't have the time to make this much nicer, but would like to quickly add this feature. Maybe someone else would like to do a bit of code reduction and profiling.

However, there are efforts for separating the filtering stuff from the image-related code in ImageFiltering.jl being currently discussed. So, we might want to keep an eye on that and switch back to a more sophisticated implementation later.

@Cornelius-G
Copy link
Collaborator Author

@oschulz GitHub Actions had some issues yesterday evening, so the CI failed or is still queued. I don't see the button to restart CI. Can you run this again somehow?

@oschulz
Copy link
Member

oschulz commented Mar 16, 2021

Yes, I was wondering ... restarting it now.

@oschulz
Copy link
Member

oschulz commented Mar 16, 2021

Nice!

@oschulz oschulz merged commit 0e383fc into bat:master Mar 16, 2021
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.

3 participants