SpikeInterface / probeinterface

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

Integration with NWB #12

Open samuelgarcia opened 3 years ago

samuelgarcia commented 3 years ago

@lfrank @bendichter

You both mention NWB backend for handling probe geometry description. I have NOT studied then yet. I will.

Are theses two codes linked somehow ?

https://github.com/NovelaNeuro/ndx-franklab-novela this seams to be a description of in house data management for recordings that also include probes description (with multi shank)

https://github.com/catalystneuro/ndx-spatial-coordinates/blob/main/src/spec/create_extension_spec.py being unfamilir wuth nwb I get the purposed on this, could you explain more ?

Would be a way to define some kind of offcial to describe probes in NWB. Maybe my question is naive because I am not aware of what have already been done.

samuelgarcia commented 3 years ago

About the ndx-franklab-novela I will use lots of fields propose by this project.

bendichter commented 3 years ago

ndx-spatial-coordinates is a work-in-progress. It's a project with the Allen Institute that encompasses several related topics: probe configuration, anatomical atlas, and spatial transformations. We have started thinking about how to define objects in 2 and 3 d, so I thought it might be relevant for you. It's still a work-in-progress though, is likely to change, and currently has no documentation.

samuelgarcia commented 3 years ago

Is it with Luke Campagnola ?

samuelgarcia commented 3 years ago

Hi @bendichter. I have release today version 0.1.0 The actual package contain a "read_nwb(...)" function which is empty at the moment. When nwb format will have something about the spatial probe description it would be cool to implement this function as a proof of concept to test prointerface API.

CodyCBakerPhD commented 2 years ago

@D1o0g9s will be helping with this task

Some pseudo-code design for reading NWB without the use of the extension @D1o0g9s is putting together, as well as a modular step-by-step bite-size tasklist

1

read stuff in probeinterface.io

def read_from_nwb(nwbfile_path : str) -> Probe:  # or w/e name you want
with NWBHDF5IO(file, "r") as io:
     nwbfile = io.read()

    # figure out num_dims and num_contaacts,

    shape = nwbfile.electrodes.get("shape")
    # shape_params only necessary if shape is not None

    probe_object = Probe(ndim = num_dims, si_units="um")

    poisitions_2d = np.empty(shape=(num_contacts, num_dims))
    for j, column_name in enumerate(["rel_x", "rel_y", "rel_z"]):
           poisitions_2d[, j] = nwbfile.electrodes[column_name]

    probe_object.set_contacts(positioned_2d, shapes=shape, shape_params=shape_params)

    return probe_object

2

In neuroconv.tools.probeinterface

def add_probe_info(nwbfile : NWBFile):
    # map all probeinterface.Probe fields to electrode columns + use the ndx-probe extension for nicely describing probe geometry in the new Device object

def write_probe(probe: Probe, nwbfile_path : str, metadata : dict, overwrite : bool = False):
    with NWBHDF5IO(path=nwbfile_path, mode="w" if overwrite else "r+") as io:
        nwbfile = make_nwbfile_from_metadata(metadata) if overwrite else io.read() # this is typical basic neuroconv metadata strcture, mainly for session_start_time
        add_probe_info(nwbfile=nwbfile)
        io.write(nwbfile)

3

read more complete information (if available) in probeinterface.io

def read_from_nwb():  # or w/e name you want
with NWBHDF5IO(file, "r") as io:
     nwbfile = io.read()

     # all the previous stuff from #1

    # then read in all that stuff was that newly written through the use of # 2
    # goal being to be capable of a full roundtrip without any loss in information when using neuroconv.tools.probeinterface.write_probe to write a nwbfile, then using probe=read_from_nwb(nwbfile_path) to read it back
alejoe91 commented 1 year ago

https://github.com/SpikeInterface/ndx-probeinterface

lfrank commented 1 year ago

Great to see that this has come together… On Aug 23, 2023, at 1:40 AM, Alessio Buccino @.***> wrote:

This Message Is From an External Sender This message came from outside your organization.

https://github.com/SpikeInterface/ndx-probeinterfacehttps://urldefense.com/v3/__https://github.com/SpikeInterface/ndx-probeinterface__;!!LQC6Cpwp!vlc3DAXwtXJ8CJ2gEhvoTBjMzkFljZr8sN6ZMfdwJLn8CQHBN4_WnFU-XQjaFKqE6yzk7uk2efqxFFfkH-1z_vYzTt8$

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/SpikeInterface/probeinterface/issues/12*issuecomment-1689534559__;Iw!!LQC6Cpwp!vlc3DAXwtXJ8CJ2gEhvoTBjMzkFljZr8sN6ZMfdwJLn8CQHBN4_WnFU-XQjaFKqE6yzk7uk2efqxFFfkH-1zWsnvwTA$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABV4PSPXL3WEXEIUDMLBOUTXWW6W7ANCNFSM4UKNGC4A__;!!LQC6Cpwp!vlc3DAXwtXJ8CJ2gEhvoTBjMzkFljZr8sN6ZMfdwJLn8CQHBN4_WnFU-XQjaFKqE6yzk7uk2efqxFFfkH-1z1TdCyss$. You are receiving this because you were mentioned.