TimeseriesGenerator

class managers.operatorsTranscribe.metadata_timeseriesgenerator.TimeseriesGenerator

Available Methods:

Method name Method type
forcellrecording() class method
forrecording() class method
cellrecordings_response_regionbodies() static method
cellrecordings_response_components() static method
recordings_cell_stimulus() static method
static cellrecordings_response_regionbodies(model, recordings, stimtype, parameters)

Creates a generic time-series (response) metadata for cells. This method is called by forcellrecordings_nostimulus() and forcellrecordings_stimulus().

Arguments:

Arguments Value type
first instantiated model
second string for cellregion; “soma”, “axon”, etc …
third array; eg: recordings[“time”] = rec_t
fourth array; eg: recordings[“response”][cellregion] = rec_response
fifth
  • string “not stimulated” or
  • array; eg: recordings[“stimulus”] = rec_stim
sixth
  • None or string; eg: stimparameters[“type”]
  • stimparameters[“type”] = [“current”, “IClamp”]
  • stimparameters[“type”] = [“voltage”, “SEClamp”]
seventh
  • dictionary for runtime parameters
  • keys: "dt", "celsius", "tstop", "v_init"

Returned value: Is is a dictionary of the form

{ "name":         string,
  "data":         array,
  "unit":         string,
  "resolution":   float,
  "conversion":   float,
  "timestamps":   array,
  "comments":      string,
  "description":  string }

NOTE:

  • recordings["stimulus"] = ``"Model is not stimulated" != specific_rec_stim
  • but recordings["stimulus"] = array = specific_rec_stim
classmethod forcellrecording(chosenmodel=None, recordings=None, runtimeparameters=None, stimparameters=None)

Creates the NWB formatted time-series metadata for cells. This is normally not called by the TranscribeManager, instead it is called by forrecording().

Keyword Arguments:

Key Value type
chosenmodel instantiated model
recordings
  • dictionary with keys: "time", "response" and

    "stimulus"

  • Eg: {“time”: array, “response”: {cellregion_a: array,

    cellregion_b: array},

    “stimulus”: str(“Model is not stimulated”) or array}

runtimeparameters
  • dictionary with keys "dt", "celsius", "tstop" and
    "v_init"
    • Eg: {“dt”: 0.01, “celsius”: 30, “tstop”: 100, “v_init”: 65}
stimparameters
  • dictionary with keys "type", "stimlist" and
    "tstop"
  • value for "type" is a two element list of strings of
the form <stimulus category> <specific type of that category>
  • the first element is ALWAYS <stimulus category>
  • Eg: current inject on a cell ["current", "IClamp"]
  • value for "stimlist" is list with elements as dictionary
of the form [ {}, {}, … ]
  • Eg1: [ {“amp”: 0.5, “dur”: 100.0, “delay”: 10.0},

    {“amp”: 1.0, “dur”: 50.0, “delay”: 10.0+100.0} ]

  • Eg2: [ {“amp_initial”: 0.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 5.0},

    {“amp_initial”: 0.5, “amp_final”: 1.0, “dur”: 5.0,

    “delay”: 10.0},

    {“amp_initial”: 1.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 15.0},

    {“amp_initial”: 0.5, “amp_final”: 0.0, “dur”: 5.0,

    “delay”: 20.0}]

  • value for "tstop" is a number, time for generating the

last epoch. Therefore, "tstop": parameters["tstop"].

Returned value: Dictionary whose elements themselves are dictionaries. If there was not stimulus the length of the root dictionary is qual tot he number of cell regions, say, a soma and a dendrite. Their key values are themselves dictionaries, see cellrecordings_response(). On the other hand if there was a stimulus the length of the root dictionary is equal to 1 + the number of cell regions, say, a soma and an axon. Their key values are also dictionaries, see cellrecordings_response().

Use case:

>> tg = TimeseriesGenerator()

Get the model

>> from models.cells.modelDummyTest import DummyCell

>> model = DummyCell()

>> runtimeparam = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}

Generate model response

>> rec_t = [ t*runtimeparam["dt"] for t in range( int( runtimeparam["tstop"]/runtimeparam["dt"] ) ) ]

>> rec_i = numpy.random.rand(1,len(rec_t))[0] # stimulus

>> rec_v = numpy.random.rand(2,len(rec_t))    # response

This model has, model.regions = {'soma':0.0, 'axon':0.0}

For simulation without stimulation

>> recordings = {"time": rec_t, "response": {"soma": rec_v[0], "axon": rec_v[1]}, "stimulus": "Model is not stimulated"}

>> respmd = tg.forcellrecording(chosenmodel = model, recordings = recordings, parameters = runtimeparam)

For simulation with stimulation

>> stimparameters = {"type": ["current", "IClamp"], "stimlist": [ {"amp": 0.5, "dur": 100.0, "delay": 10.0}, {"amp": 1.0, "dur": 50.0, "delay": 10.0+100.0} ], "tstop": parameters["tstop"]}

>> recordings = {"time": rec_t, "response": {"soma": rec_v[0], "axon": rec_v[1]}, "stimulus": rec_i}

>> respmd = tg.forcellrecording(chosenmodel = model, recordings = recordings, parameters = runtimeparam, stimparameters = stimparameters)

NOTE:

  • if there is NO stimulation and chosenmodel.regions={"soma": 0.0, "axon": 0.0}` then ``len(respmd) = 2 since there are two cell regions
  • also, this means respmd_soma = respmd["soma"] and respmd_axon = respmd["axon"]
  • however, with stimulation there is an additional “stimulus” key stimulmd = respmmd["stimulus"]
classmethod forrecording(chosenmodel=None, recordings=None, runtimeparameters=None, stimparameters=None)

Creates the NWB formatted time-series metadata.

Keyword Arguments:

Key Value type
chosenmodel instantiated model
recordings
  • dictionary with keys: "time", "response" and

    "stimulus"

  • Eg: {“time”: array, “response”: {cellregion_a: array,

    cellregion_b: array},

    “stimulus”: str(“Model is not stimulated”) or array}

runtimeparameters
  • dictionary with keys "dt", "celsius", "tstop" and
    "v_init"
  • Eg: {“dt”: 0.01, “celsius”: 30, “tstop”: 100, “v_init”: 65}
(optional)

stimparameters

  • dictionary with keys "type", "stimlist" and
    "tstop"
  • value for "type" is a two element list of strings of
the form <stimulus category> <specific type of that category>
  • the first element is ALWAYS <stimulus category>
  • Eg: current inject on a cell ["current", "IClamp"]
  • value for "stimlist" is list with elements as dictionary
of the form [ {}, {}, … ]
  • Eg1: [ {“amp”: 0.5, “dur”: 100.0, “delay”: 10.0},

    {“amp”: 1.0, “dur”: 50.0, “delay”: 10.0+100.0} ]

  • Eg2: [ {“amp_initial”: 0.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 5.0},

    {“amp_initial”: 0.5, “amp_final”: 1.0, “dur”: 5.0,

    “delay”: 10.0},

    {“amp_initial”: 1.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 15.0},

    {“amp_initial”: 0.5, “amp_final”: 0.0, “dur”: 5.0,

    “delay”: 20.0}]

  • value for "tstop" is a number, time for generating the

last epoch. Therefore, "tstop": parameters["tstop"].

Returned value: Dictionary whose elements themselves are dictionaries. If there was not stimulus the length of the root dictionary is qual tot he number of cell regions, say, a soma and a dendrite. On the other hand if there was a stimulus the length of the root dictionary is equal to 1 + the number of cell regions, say, a soma and an axon. The key values are themselves dictionaries, see forcellrecording().

Use case: For modelscale="cells"

>> tg = TimeseriesGenerator()

Get dummy model

>> from models.cells.modelDummyTest import DummyCell

>> model = DummyCell()

>> runtimeparam = {"dt": 0.01, "celsius": 30, "tstop": 100, "v_init": 65}

Generate model response

>> rec_t = [ t*runtimeparam["dt"] for t in range( int( runtimeparam["tstop"]/runtimeparam["dt"] ) ) ]

>> rec_i = numpy.random.rand(1,len(rec_t))[0] # stimulus

>> rec_v = numpy.random.rand(2,len(rec_t))    # response

This model has model.regions = {'soma':0.0, 'axon':0.0}

For simulation without stimulation

>> recordings = {"time": rec_t, "response": {"soma": rec_v[0], "axon": rec_v[1]}, "stimulus": "Model is not stimulated"}

>> respmd = tg.forcellrecording(chosenmodel = model, recordings = recordings, parameters = runtimeparam)

Simulation with stimulation

>> stimparameters = {"type": ["current", "IClamp"], "stimlist": [ {"amp": 0.5, "dur": 100.0, "delay": 10.0}, {"amp": 1.0, "dur": 50.0, "delay": 10.0+100.0} ], "tstop": runtimeparam["tstop"]} >> recordings = {"time": rec_t, "response": {"soma": rec_v[0], "axon": rec_v[1]}, "stimulus": rec_i}

>> respmd = tg.forcellrecording(chosenmodel = model, recordings = recordings, parameters = runtimeparam, stimparameters = stimparameters)

NOTE:

  • if there is NO stimulation and chosenmodel.regions={"soma": 0.0, "axon": 0.0} then len(respmd) = 2 since there are two cell regions
  • also, this means respmd_soma = respmd["soma"] and respmd_axon = respmd["axon"]
  • however, with stimulation there is an additional “stimulus” key stimulmd = respmmd["stimulus"]
static recordings_cell_stimulus(model, recordings, parameters, stimparameters)

Creates a time-series (response) metadata for stimulated cells. This method is called by :py:meth`.recordings_cellstimulus`.

Arguments:

Argument Value type
first instantiated model
second array; eg: recordings[“time”] = rec_t
third array; eg: recordings[“stimulus”] = rec_stim
fourth
  • dictionary for runtime parameters
  • keys "dt", "celsius", "tstop", "v_init"
fifth
  • dictionary for stimulation parameters
  • keys "type", "stimlist" and "tstop"
  • value for "type" is a two element list of strings of
the form <stimulus category> <specific type of that category>
  • the first element is ALWAYS <stimulus category>
  • Eg: current inject on a cell ["current", "IClamp"]
  • value for "stimlist" is a list with elements as dictionary
of the form [ {}, {}, … ]
  • Eg1: [ {“amp”: 0.5, “dur”: 100.0, “delay”: 10.0},

    {“amp”: 1.0, “dur”: 50.0, “delay”: 10.0+100.0} ]

  • Eg2: [ {“amp_initial”: 0.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 5.0},

    {“amp_initial”: 0.5, “amp_final”: 1.0, “dur”: 5.0,

    “delay”: 10.0},

    {“amp_initial”: 1.0, “amp_final”: 0.5, “dur”: 5.0,

    “delay”: 15.0},

    {“amp_initial”: 0.5, “amp_final”: 0.0, “dur”: 5.0,

    “delay”: 20.0} ]

  • value for "tstop" is a number, time for generating the last

epoch. Therefore, "tstop": parameters["tstop"].

Returned value: Is is a dictionary of the form

{ "name":         string,
  "data":         array,
  "unit":         string,
  "resolution":   float,
  "conversion":   float,
  "timestamps":   array,
  "comments":      string,
  "description":  string }

NOTE:

  • prior to calling this method weed out recordings[“stimulus”]=”Model is not stimulated”
  • this method only accepts arrays