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

LFP subsampling #2

Merged
merged 10 commits into from
Jul 9, 2024
Merged

LFP subsampling #2

merged 10 commits into from
Jul 9, 2024

Conversation

arjunsridhar12345
Copy link
Collaborator

LFP Subsampling ported from allensdk. Peforms spatial and temporal subsampling:

  • Spatial subsampling: Takes input arg of distance between channels to keep, strides by this distance
  • Temporal subsampling: Input arg: ratio of input to output samples in time
  • Common median reference: For probes in agar, takes input arg of surface channel index for a probe and does cmr
  • High pass filter of LFP

code/run_capsule.py Outdated Show resolved Hide resolved
Comment on lines 356 to 358
channel_ids_to_keep = channel_ids[0:len(channel_ids):SPATIAL_CHANNEL_SUBSAMPLING_FACTOR]
channel_ids_to_remove = [channel_id for channel_id in channel_ids if channel_id not in channel_ids_to_keep]
recording_lfp_spatial_subsampled = recording_lfp.remove_channels(channel_ids_to_remove)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also use recording_lfp_spatial_subsampled = recording_lfp.channel_slice(channel_ids_to_keep)

code/run_capsule.py Outdated Show resolved Hide resolved
code/run_capsule.py Outdated Show resolved Hide resolved
code/run_capsule.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@alejoe91 alejoe91 left a comment

Choose a reason for hiding this comment

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

Thanks @arjunsridhar12345

I added a few comments and suggestions

@alejoe91
Copy link
Collaborator

@arjunsridhar12345 do you mind if I push directly to your PR?

@arjunsridhar12345
Copy link
Collaborator Author

@arjunsridhar12345 do you mind if I push directly to your PR?

Yeah sure

code/run_capsule.py Outdated Show resolved Hide resolved
Comment on lines 410 to 415
recording_lfp = spre.common_reference(
recording_lfp,
reference="single",
groups=groups,
ref_channel_ids=reference_channel_ids,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@arjunsridhar12345 not sure this is correct. If I understand correctly, you want to subtract the median of the channnels in agar (from surface_channel_index to the last channel) to the remaining channels, correct?

The current solution will subtract to each channel group (so each channel in your case), the corresponding reference_channel_id, so all channels out of the brain will be zeroed out, with no effect on the other channels. Is this the wanted behavior?

Copy link
Collaborator Author

@arjunsridhar12345 arjunsridhar12345 Jun 28, 2024

Choose a reason for hiding this comment

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

yes, want to subtract the median of channels from surface index to last to the remaining channels. Then, should the reference be "global" with only ref_channel_ids set? Or what parameters should be passed to get the desired effect?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm I don't think we have that option yet, but we could cook in a workaround if needed.

See this issue: SpikeInterface/spikeinterface#2985

Copy link
Collaborator Author

@arjunsridhar12345 arjunsridhar12345 Jun 28, 2024

Choose a reason for hiding this comment

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

ah ok cool. that seems close, basically just need to subtract the remaining traces from the median of those channels. is there any sort of set traces type functionality or another way you know of?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really...I'll think about a smart way to do it! We will probbaly need some custom recording functions

Copy link
Collaborator

Choose a reason for hiding this comment

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

@arjunsridhar12345 fixed in this PR: SpikeInterface/spikeinterface#3139 (and SpikeInterface/spikeinterface#3140)

Until we release, I added a custom installation in the postinstall

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok great, thanks!

environment/postInstall Outdated Show resolved Hide resolved
@alejoe91 alejoe91 merged commit f0e820e into main Jul 9, 2024
@alejoe91 alejoe91 deleted the lfp_subsampling branch October 2, 2024 18:02
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.

2 participants