Skip to content

Conversation

@resatomo
Copy link
Collaborator

Average ECoG data across neighboring channels based on distance.

@resatomo resatomo requested a review from leoscholl January 27, 2024 01:15

return NCC, shifts

def get_neighboring_channel_index(elec_pos, distance=0.75):
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think about having this function take "ch_idx" as an argument, and only return neighboring_idx[ch_idx], instead of the whole matrix?
i think it might be more useful that way?
probably it will be slower, so in get_mean_neighboring_channels() you might not use this function

Args:
data (nch): neural data
elec_pos (nch, 2): x, y position of each channel
distance (float): define neighboring channels based on this distance. 0.75 is for 4 neighboring channels and 1.3 is for 9 channels.
Copy link
Collaborator

Choose a reason for hiding this comment

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

0.75 and 1.3 only applies to ECoG244 array


return neighboring_idx

def get_mean_neighboring_channels(data, elec_pos, distance=0.75):
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't want to derail this function -- it's fine and you can push it -- but just a note for the future: we should really make a spatial smoothing function that takes an arbitrary 2d kernel and smooths the data that way, rather than only doing average and only limited to a radius

data_test = np.arange(1,10)
m_data_test = aopy.analysis.get_mean_neighboring_channels(data_test, elec_pos_test, distance=1)
self.assertTrue(m_data_test[0] == np.sum(data_test[0]+data_test[1]+data_test[3])/3)
self.assertTrue(m_data_test[4] == np.sum(data_test[1]+data_test[3]+data_test[4]+data_test[5]+data_test[7])/5)
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be great to add a couple more lines to get a spatial map of the test data before and after smoothing and make a plot of before/after. then you could include the plot and the example code in the function docstring as well.

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.

3 participants