Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

convolve spikes and times, not rate #20

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

halvarsu
Copy link
Collaborator

With inspiration from this article, I switched the order of convolution and division when creating rate maps.

The old method had problems in the cases where one bin only had one time point and one spike. This happened surprisingly often resulting in unnaturally high spike rate in that bin and neighboring bins after convolution. The new method gives an average reasonably close to the exact (number of spikes/total time) for normal smoothing factor. Here an example from a rate map where the old method overshoots:

image

This commit currently does not change the default behaviour of spatial_rate_map. I personally think this is a better method (easier to separate grid fields afterwards), should it be the default?

@codecov
Copy link

codecov bot commented Jan 26, 2018

Codecov Report

❗ No coverage uploaded for pull request base (dev@8320e8c). Click here to learn what that means.
The diff coverage is 82.69%.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev      #20   +/-   ##
======================================
  Coverage       ?   42.75%           
======================================
  Files          ?       39           
  Lines          ?     4283           
  Branches       ?        0           
======================================
  Hits           ?     1831           
  Misses         ?     2452           
  Partials       ?        0
Impacted Files Coverage Δ
exana/tracking/__init__.py 100% <100%> (ø)
exana/tracking/fields.py 71.46% <74.07%> (ø)
exana/tests/test_fields.py 94.28% <91.66%> (ø)

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 8320e8c...1f2bbdf. Read the comment docs.

@lepmik
Copy link
Member

lepmik commented Jan 29, 2018

Great work! I think we should have this new method as a default. However, first we must make sure this would not affect users if anyone relies on the old method @tristanstoeber @anecc

@lepmik lepmik mentioned this pull request Jan 29, 2018
@tristanstoeber
Copy link
Contributor

tristanstoeber commented Jan 29, 2018 via email

@anecc
Copy link

anecc commented Jan 30, 2018 via email

@halvarsu halvarsu force-pushed the new_rate_map branch 2 times, most recently from bcd61ba to 2073e93 Compare February 2, 2018 11:47
@halvarsu
Copy link
Collaborator Author

halvarsu commented Jun 4, 2018

Is it time for a merge?

rate[np.isnan(rate)] = 0. # for convolution
from astropy.convolution import Gaussian2DKernel, convolve_fft
from astropy.convolution import Gaussian1DKernel, convolve_fft
Copy link
Member

Choose a reason for hiding this comment

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

Did you find the reason why this was changed from 2D to 1D @halvarsu ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it makes sense, as it is the 1D-spatial rate map function :)

Copy link
Member

Choose a reason for hiding this comment

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

True :) I thought it was used in the 2D case as well, but I probably just remember wrong

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants