hasselmonians / EgocentricBoundaryCells

Matlab code for egocentric boundary cell identification in freely behaving animals
GNU General Public License v3.0
7 stars 4 forks source link

Questions about using head direction #1

Open EdShen-hub opened 3 years ago

EdShen-hub commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.