ChangLabUcsf / ndx-electrical-stim

An NWB extension for storing electrical stimulation waveforms and metadata for neural stimulation.
Other
2 stars 1 forks source link

Defining stimulation metadata type #2

Closed jessierliu closed 4 years ago

jessierliu commented 4 years ago

@bendichter @kristinksellers @akhambhati and I had discussed for stimulation that when you set the stimulation, you set it with some number of parameters (which might change between stimulation systems, people, etc). And for some systems you get the waveform as well. So they were saying that it would be good to have the metadata, so that if you didn’t have the waveform, you could still say that “this is what the parameters were supposed to be.”

Is there a standard for how to store these types of metadata? My instinct is to allow a dictionary to be set since there might be several time periods of different stimulation parameters throughout a single block. There would just be a field in StimSeries that is metadata and it accepts a dictionary containing whatever the user wants (so this is not super rigorous in specifying what should be set, maybe there is a way to specify some mandatory parameters). Maybe it looks something like below:

metadata = {
    "stim1": {
        "amplitude": 20,
        "paramter2": 2
    },
    "stim2": {
        "parameter1": "TDT-box"
    }
}
bendichter commented 4 years ago

We don't really have a way of storing arbitrary meta-data dictionaries. Some users have stored hierarchical meta-data in free text fields as json, just as you are doing here. I would advise either standardizing this and creating an extension, or using json.

jessierliu commented 4 years ago

Gotcha, I personally think a JSON makes the most sense?

@akhambhati @kristinksellers Any objections? What might the parameters look like? This can give us a better idea of whether it's suited to a JSON style.

kristinksellers commented 4 years ago

I think JSON should be fine. The parameters that come to mind include: frequency, amplitude, pulsewidth, inter-pulse interval, duration.

In some special cases: ramp duration, open-loop / closed-loop (yes/no)

jessierliu commented 4 years ago

@bendichter Is there a reason why you specify JSON style as opposed to any kind of dictionary (which could contain a NumPy array if a user defines a field that isn't predefined)? i.e. is it required to incorporate a check that the dictionary is JSON serializable?

bendichter commented 4 years ago

How would you implement a general dictionary in hdf5?

jessierliu commented 4 years ago

Ah, yes I did not think about that, duh. Okay, so I'll JSON serialize the input dictionary to store it.

So the user must then json.loads(nwbfile.stimulus['stim'].metadata) or something to that effect to recover the "dictionary".

bendichter commented 4 years ago

yeah