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

Questions about using head direction #1

Open
EdShen-hub opened this issue Sep 23, 2021 · 2 comments
Open

Questions about using head direction #1

EdShen-hub opened this issue Sep 23, 2021 · 2 comments

Comments

@EdShen-hub
Copy link

Hello,

Thank you for providing the code to generate the amazing plots!

I want to plot egocentric rate maps with a fix object as the reference and use the animal's head direction defined from 0-360 degrees, with 0 being East, 90 -> North, 180 -> West, and 270 -> South. I noticed that in your Nature Communications paper you used movement direction from -180 -> -90 -> 0 -> 90 (South - West - North - East). Does the way I define my direction also work for the head directions? And how can I modify the code to allow a single point as the referenced boundary?

Thank you very much for your help!
Ed

@wchapman
Copy link
Collaborator

Hi Ed! Your head direction definition will be fine, the sin/cos functions will accommodate for -180:180 vs 0:360.

If your object of interest is large/distributed in space, you can use the EgocentricRatemap function provided, and select corners of the object instead of corners of the environment (we've used this internally in the lab).

If you're interested in just the tuning to a single point, you're probably better off calculating the egocentric rate map from scratch (which actually avoids many of the complications in calculating distance to each point on the boundary). Eg:

dx = AnimalX - ObjectX
dy = AnimalY - ObjectY
dd = sqrt(dx.^2 + dy.^2)
relativeAngle = wrapTo180(atan2(dy,dx) - AnimalHD)

occupancy = histcounts2(dd, relativeAngle, 0:50, -180:10:180)
spkCount = histcounts2(dd(spk==1), relativeAngle(spk==1), 0:50, -180:10:180)
rateMap = spkCount ./ Occupancy

You can then plot these maps using the same mesh grid trick we used (eg: lines 38-46 of plotEBC.m)

@EdShen-hub
Copy link
Author

Thank you for the answers! The code for point reference also works. It is just that now the rate map doesn't show the reference point that the spikes are tuning to. I guess this is normal, though. After all, it is hard for one point to show up in a map.

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