SpikeInterface / probeinterface

Python package to handle probe layout, geometry and wiring to device.
MIT License
53 stars 43 forks source link

Making a probegroup from two of the same cambridge neurotech probes #238

Closed zm711 closed 9 months ago

zm711 commented 9 months ago

Quick question about making probe groups with Cambridge neurotech probes. Cambridge neurotech allows people to buy a probe, eg an H7, or to buy same probe double so two H7s glued together. Currently I make probe, wire it and then since the other probe is an exact duplicate I just deep copy that probe. Then I set_device_indices as the same as the original probe but offset by the appropriate number of channels (& do the same for the contact numbers. Then I add the original probe and the duplicated (but offset probe) to a probegroup.

Is there a smarter way to do this?

probe = pi.get_probe(manufacturer = 'cambridgeneurotech', probe_name = 'ASSY-77-H7')
probe.wiring_to_device('ASSY-77>Adpt.A64-Om32_2x-sm-NN>RHD2164')
probe1=deepcopy(probe)
probe1.move([400,0]) # shift so they aren't on top of each other

#offset channel_indices since they are exactly modulo 64
channel_indices = probe.device_channel_indices
probe1.set_device_channel_indices(channel_indices + 64) 

#offset the contact_ids since they are modulo 64
contact_ids = probe.contact_ids
new_contact = []
for idx in range(len(contact_ids)):
    new_contact.append(str(float(contact_ids[idx])+64)) 
new_contacts= np.array(new_contact)
probe1.set_contact_ids(new_contacts)

multishank = pi.ProbeGroup()

multishank.add_probe(probe)
multishank.add_probe(probe1)

Then I just sort by probe_group in spikeinterface. But if there is an easier way to do this I would be happy to switch this or if I made a wrong step I would also be super happy to be corrected!

alejoe91 commented 9 months ago

Hi @zm711

wiring = pi.wiring.pathways["ASSY-77>Adpt.A64-Om32_2x-sm-NN>RHD2164"]
wiring_group = wiring + list(np.array(wiring) + 64)

multishank = pi.ProbeGroup()
multishank.add_probe(probe)
multishank.add_probe(probe1)

multishank.set_global_device_channel_indices(wiring_group)
zm711 commented 9 months ago

Thanks @alejoe91, I will try that as soon my raw file is done reading and close when I test :). Thanks, I figured you guys would have an easier way to do rather than hacking my way through it.

zm711 commented 9 months ago

@alejoe91, the clone() is failing?

probe1 = probe.clone()
Traceback (most recent call last):

  Cell In[8], line 1
    probe1 = probe.clone()

AttributeError: 'Probe' object has no attribute 'clone'

pi.__version__
Out[9]: '0.2.19'
zm711 commented 9 months ago

Is it suppose to be probe.copy() instead?

alejoe91 commented 9 months ago

Is it suppose to be probe.copy() instead?

Yes! Sorry about that! (I'll edit my comment so that it's clearer)

zm711 commented 9 months ago

Cool cool. I'm running the sorting now, but seems to be working and is way simpler. Thanks @alejoe91 :)