Skip to content

Integration with NWB #12

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

Open
samuelgarcia opened this issue Dec 2, 2020 · 7 comments
Open

Integration with NWB #12

samuelgarcia opened this issue Dec 2, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@samuelgarcia
Copy link
Member

@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
Copy link
Member Author

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

@bendichter
Copy link
Contributor

bendichter commented Dec 2, 2020

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
Copy link
Member Author

Is it with Luke Campagnola ?

@samuelgarcia
Copy link
Member Author

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
Copy link

CodyCBakerPhD commented Jul 27, 2022

@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
Copy link
Member

@alejoe91 alejoe91 added the enhancement New feature or request label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants