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

psthRasterAndCounts gives psth that is undercounted in at the edge-bins #12

Open
ilandau opened this issue May 12, 2020 · 4 comments
Open

Comments

@ilandau
Copy link

ilandau commented May 12, 2020

Hey there, I'm a new user. I noticed that the psth created by psthRasterAndCounts was undercounted in the first and last bin. Both psth and bins are returned as vectors that are the length of the number of edges, i.e. one more than the number of bins. This could be related to the old matlab hist function which used to accept bin-centers as inputs, whereas the new histogram function only accepts a vector of edges as inputs.

In any case, I made minor changes in the file locally to make it return psth and bins corresponding to the bin-centers and with length corresponding to the actual number of bins. I'd be happy to share that change. But maybe people out there are still using old versions of Matlab and that's why they're not running into issues?

@nsteinme
Copy link
Collaborator

Good catch, yes looks like the first bin will be half as wide as the others (this is only going to be true for the last bin if the window size is evenly divisible by the bin size - I don't think it applies to the last bin in general). I think the correct fix is to change line 31 to start from window(1)+psthBinSize/2 rather than starting from window(1). Do you agree?

@ilandau
Copy link
Author

ilandau commented May 13, 2020

So what I did was to replace line 31 with the following:

edges = window(1):psthBinSize:window(2); [psth, edges] = histcounts(stRelToEvent, edges); bins = edges(1:end-1) + psthBinSize/2;

Matlab seems to highly recommend switching out the old calls to hist.

@nsteinme
Copy link
Collaborator

nsteinme commented May 13, 2020 via email

@ilandau
Copy link
Author

ilandau commented May 13, 2020

Sure.

I'm a bit of a newbie to github collaboration. It looks like I need to be assigned as a "collaborator" in order to start a new branch and then make the pull request. Is that right?

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

No branches or pull requests

2 participants