flatironinstitute / mountainsort5

MountainSort spike sorting algorithm, version 5
Apache License 2.0
37 stars 8 forks source link

channel locations for spike sorting #3

Closed skyetomez closed 1 year ago

skyetomez commented 1 year ago

I'm wanting to use ms5 for spike sorting but I'm running into the following error with data collected using openephys.

Exception                                 Traceback (most recent call last)
Cell In[8], line 8
      4 # need to sort the recording to continue!
      5 # 1. Build singularity continaer for matlab
      6 # 2. Run Sorter
      7 folder = "sorter_output"
----> 8 sorting = ms5.sorting_scheme1(
      9     recording["clean_data"],
     10     sorting_parameters = ms5.Scheme1SortingParameters(detect_channel_radius=0,
     11                                                      snippet_mask_radius = 0))

File ~/.conda/envs/spike_sort/lib/python3.10/site-packages/mountainsort5/schemes/sorting_scheme1.py:41, in sorting_scheme1(recording, sorting_parameters)
     38 N = recording.get_num_frames()
     39 sampling_frequency = recording.sampling_frequency
---> 41 channel_locations = recording.get_channel_locations()
     43 print(f'Number of channels: {M}')
     44 print(f'Number of timepoints: {N}')

File ~/.conda/envs/spike_sort/lib/python3.10/site-packages/spikeinterface/core/baserecordingsnippets.py:305, in BaseRecordingSnippets.get_channel_locations(self, channel_ids, axes)
    303 locations = self.get_property('location')
    304 if locations is None:
--> 305     raise Exception('There are no channel locations')
    306 locations = np.asarray(locations)[channel_indices]
    307 return select_axes(locations, axes)

Exception: There are no channel locations

I was looking at early documentation and I thought setting radius to 0 would let me move past this, but it doesn't. Is there anything I can do to get this information or by-pass this requirement?

magland commented 1 year ago

Hi @skyetomez, I think the BaseRecording should have a set_channel_locations() function, or something similar, that you could use to set them all to (0, 0). Could you look into that? If you don't find anything, I'll take a look.

skyetomez commented 1 year ago

Thank you @magland I can do that. I wasn't sure what these location data would look like. Is it just a list of tuples?

skyetomez commented 1 year ago

Before I close this, do you know how one would go about recovering the channel locations from a probe? We custom make our probes in our lab so these physical locations are rather difficult to determine.

magland commented 1 year ago

Could you provide some more details on what you are trying to do? Jeremy

On Tuesday, May 2, 2023, skyetomez @.***> wrote:

Before I close this, do you know how one would go about recovering the channel locations from a probe?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/flatironinstitute/mountainsort5/issues/3*issuecomment-1531649275__;Iw!!DSb-azq1wVFtOg!T3yIb-4JhC14zMzG0pwCAuZ2Cat-n1NUN3DRaN03PE7ZRtV8Aw6OpU4ZQhKwHVp3WCuD8tPkzme_cdLyA-Dzlbueke0NfKnc1ICOsLP_$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AA4CIQGT4PVSS77PTUDX6DLXEEPSNANCNFSM6AAAAAAXSVDNOI__;!!DSb-azq1wVFtOg!T3yIb-4JhC14zMzG0pwCAuZ2Cat-n1NUN3DRaN03PE7ZRtV8Aw6OpU4ZQhKwHVp3WCuD8tPkzme_cdLyA-Dzlbueke0NfKnc1AGzN_VL$ . You are receiving this because you were mentioned.Message ID: @.***>

-- Sent from my phone

skyetomez commented 1 year ago

Sure thing @magland . My goal is to use Scheme3 sorting with this openephys tetrode data. The problem is that we recorded using probes that we made in lab and I've been told that the channel locations are not something we'd easily recover.

magland commented 1 year ago

If they are tetrodes then just set the channel locations to 0,0 and just be sure to sort each tetrode separately.

I'd be interested to learn how the sorting turns out!

On Tuesday, May 2, 2023, skyetomez @.***> wrote:

Sure thing @magland https://urldefense.com/v3/__https://github.com/magland__;!!DSb-azq1wVFtOg!UBygc6NzQR2OpcwMfevS56YKBGN_Ty2A3eC95eCM1_G2g4gwuna3KQI5T6ZBdE_nbuWzuGYuZ5_R0PpWKsM1JnaosxzxeuIimGfqUJ40$ . My goal is to use Scheme3 sorting with this openephys tetrode data. The problem is that we recorded using probes that we made in lab and I've been told that the channel locations are not something we'd easily recover.

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/flatironinstitute/mountainsort5/issues/3*issuecomment-1531885819__;Iw!!DSb-azq1wVFtOg!UBygc6NzQR2OpcwMfevS56YKBGN_Ty2A3eC95eCM1_G2g4gwuna3KQI5T6ZBdE_nbuWzuGYuZ5_R0PpWKsM1JnaosxzxeuIimFdUBcgm$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AA4CIQGDXHFPQ354ENTIJADXEFBQTANCNFSM6AAAAAAXSVDNOI__;!!DSb-azq1wVFtOg!UBygc6NzQR2OpcwMfevS56YKBGN_Ty2A3eC95eCM1_G2g4gwuna3KQI5T6ZBdE_nbuWzuGYuZ5_R0PpWKsM1JnaosxzxeuIimLCUHkMz$ . You are receiving this because you were mentioned.Message ID: @.***>

-- Sent from my phone

skyetomez commented 1 year ago

Hi @magland . I've been thinking about this phrase. "sure to sort each tetrode separately." How would this be done? I'm thinking I'd have to group the channels by tetrode and then sort based on these groups. Is this what you mean?

magland commented 1 year ago

Yes, you need to group the electrodes by tetrode, and then extract out the sub-recording for each tetrode... I believe it's the recording.channel_slice(...) function from spikeinterface... and then run the sorting on each of those sub-recordings. You'll have a different sorting object for each tetrode.