spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

How to use plot_unit_waveforms API?

Open Yuhao-Zhang-SV opened this issue 3 years ago • 11 comments

Hi developers,

Sorry I have a simple question... After I read the API doc, there are two parameters, namely, channel_ids and units_ids in the plot_unit_waveforms function. So basically can I just arbitrarily choose some units and channels as lists as inputs? I tried on this, but got ValueError: operands could not be broadcast together with shapes (272,120,49) (1,1,2) error. It seems that only when I choose all channels (not specify channel_ids parameter). So is there a way that I can plot any number of units and channels as I want? Thanks in advance~

Yuhao-Zhang-SV avatar Apr 20 '22 08:04 Yuhao-Zhang-SV

Hi @Yuhao-Zhang-SV

It would be helpful if you shared the snippet of code that you used! :)

alejoe91 avatar Apr 20 '22 08:04 alejoe91

OK, I think this is how I called plot_unit_waveforms API:

        self.we = si.extract_waveforms(self.loaded_recording_cmr, self.sorting_MS4, self.waveformCachePath, ms_before = 2, ms_after = 2, max_spikes_per_unit = 10000, overwrite=True)
        sw.plot_unit_waveforms(self.we, _channel_ids=[0, 2],_ unit_ids=[19, 37, 27, 29])

If I deleted channel_ids here, it could be executed successfully. (We have 49 channels, so I don't think there's an index error...) Thanks in advance~

Yuhao-Zhang-SV avatar Apr 21 '22 04:04 Yuhao-Zhang-SV

Hi @Yuhao-Zhang-SV

Why are you using _channel_ids and _unit_ids? It should be channel_ids and unit_ids (without the _)!

alejoe91 avatar Apr 21 '22 07:04 alejoe91

Also, can you paste the entire traceback?

alejoe91 avatar Apr 21 '22 07:04 alejoe91

Oh, sorry about that... I intended to use the "Italian" format, but it did not display properly (the initial code has no _ before parameters...). And the entire traceback is shown below. Thanks~ image

Yuhao-Zhang-SV avatar Apr 21 '22 09:04 Yuhao-Zhang-SV

Ok thanks for the clarification! Can you try instead of providing channel_ids to use radius_um=100? Just to see if it works! This selects the channels in a um radius around the maximum channel

alejoe91 avatar Apr 21 '22 09:04 alejoe91

OK, I think it works! The script can execute without errors. So why is this useful? I notice something has changed to my waveform figure... image

Yuhao-Zhang-SV avatar Apr 21 '22 10:04 Yuhao-Zhang-SV

this plots the best channels for each unit. Also the channel_ids approach should work..I'll double check!

alejoe91 avatar Apr 21 '22 10:04 alejoe91

Hi, since each unit has 9 waveforms, I just tried to include 9 channels to try to plot again but still failed... So what might be the problem here? Thanks in advance~ 1650609548(1)

Yuhao-Zhang-SV avatar Apr 22 '22 06:04 Yuhao-Zhang-SV

Also, plot_unit_templates API has the same issue here...

Yuhao-Zhang-SV avatar Apr 22 '22 07:04 Yuhao-Zhang-SV

thanks for the report! I'll be off next week but we'll try to look into it at the beginning of May!

alejoe91 avatar Apr 22 '22 13:04 alejoe91

HI @Yuhao-Zhang-SV

We refactored the plotting functions completely. Can you check if the error is still there after upgrading? Closing for now, feel free to reopen!

alejoe91 avatar Oct 13 '22 11:10 alejoe91