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

added working 'get_foraging_bouts' function #410

Open
wants to merge 60 commits into
base: datajoint_pipeline
Choose a base branch
from

Conversation

jkbhagatio
Copy link
Member

No description provided.

glopesdev and others added 28 commits September 6, 2024 12:53
Allow forwarding of load function kwargs to reader
)
foraging_mask = max_windowed_wheel_vals > (patch_spun_df["cum_wheel_dist"] + min_wheel_movement)
# Discretize into foraging bouts
bout_start_indxs = np.where(np.diff(foraging_mask.astype(int), prepend=0) == 1)[0]
Copy link
Member Author

Choose a reason for hiding this comment

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

these should be shifted up by win_len

Copy link
Member Author

Choose a reason for hiding this comment

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

bout_start_indxs = np.where(np.diff(foraging_mask.astype(int), prepend=0) == 1)[0] + win_len

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe win_len - 1

Copy link
Contributor

@lochhh lochhh Sep 20, 2024

Choose a reason for hiding this comment

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

if the wheel starts moving after a long period of inactivity but for fewer than min_wheel_movement BUT a pellet is delivered as below, should this (first) pellet be counted in the foraging bout, i.e. should n=3 or n=2? If we shift bout_start_idxs by win_len-1, n=2.
newplot

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the foraging bout should be started when the wheel actually starts moving.

Let me look at this particular case in more detail later.

The bouts that the previous rolling max approach detects will differ from just shifting the cum_wheel_dist, and I think this may be one of them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Iirc, using rolling max and direct shift produce the same results in terms of the number of pellets. But feel free to verify this.

foraging_mask = max_windowed_wheel_vals > (patch_spun_df["cum_wheel_dist"] + min_wheel_movement)
# Discretize into foraging bouts
bout_start_indxs = np.where(np.diff(foraging_mask.astype(int), prepend=0) == 1)[0]
bout_end_indxs = np.where(np.diff(foraging_mask.astype(int), prepend=0) == -1)[0]
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to account for final pellet delivery in bout: time for bonsai to deliver pellet / beambreak to occur after threshold crossing

Copy link
Contributor

Choose a reason for hiding this comment

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

bout_start_indxs shift is done in a96231c and left a TODO note for changing the constant for bout_end_indxs

@jkbhagatio jkbhagatio marked this pull request as ready for review September 20, 2024 19:49
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.

5 participants