TimeseriesGenerator

class managers.operatorsTranscribe.metadata_timeseriesgenerator.TimeseriesGenerator

Available Methods:

Method name Method type
forrecording() class method
recordings_cellstimulus() class method
forcellrecordings_nostimulus() class method
forcellrecordings_stimulus() class method
forcellrecording() class method
forrecording() class method
cellrecordings_response() static method
recordings_cell_currentstimulus() static method
static cellrecordings_response(model, cellregion, rec_t, specific_rec_i, rec_v, 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_v
fifth
  • string “not stimulated” or
  • array; eg: recordings[“stimulus”] = rec_i
sixth
  • 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_i
  • but recordings["stimulus"] = array = specific_rec_i
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 forcellrecordings_nostimulus(). 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 forcellrecordings_stimulus().

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 forcellrecordings_nostimulus(chosenmodel, recordings, runtimeparameters)

Creates time-series metadata for unstimulated cells. This method calls cellrecordings_response(). However this method is called by forcellrecording().

Arguments:

Argument Value type
first instantiated model
second
  • dictionary of the recordings

  • keys: "time", "response" and "stimulus"

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

    cellregion_b: array},

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

third
  • dictionary of the run-time parameters
  • keys: "dt", "celsius", "tstop", "v_init"
  • Eg: {“dt”: 0.01, “celsius”: 30, “tstop”: 100, “v_init”: 65}

Returned value: Dictionary whose elements themselves are dictionaries. The length of the root dictionary is equal to the number of cell regions, say, a soma and an axon. The keys of the parent dictionary are the cell region names. Their respective values are themselves dictionaries, see cellrecordings_response().

classmethod forcellrecordings_stimulus(chosenmodel, recordings, runtimeparameters, stimparameters)

Creates time-series metadata for stimulated cells. This method calls cellrecordings_response() and also recordings_cellstimulus(). However this method is called by forcellrecording().

Arguments:

Argument Value type
first instantiated model
second
  • dictionary of the recordings

  • keys: "time", "response" and "stimulus"

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

    cellregion_b: array},

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

third
  • dictionary of the run-time parameters
  • keys: "dt", "celsius", "tstop", "v_init"
  • Eg: {“dt”: 0.01, “celsius”: 30, “tstop”: 100, “v_init”: 65}
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: Dictionary whose elements themselves are dictionaries. The length of the root dictionary is equal to 1 + the number of cell regions, say, a soma and an axon. The keys of the parent dictionary are “stimulus” plus the cell region names. Their respective values are themselves dictionaries, see recordings_cellstimulus() for “stimulus” key value and see cellrecordings_response() for the cell regions key values.

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_currentstimulus(model, rec_t, rec_i, 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_i
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
classmethod recordings_cellstimulus(model, rec_t, rec_i, parameters, stimparameters)

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

Arguments:

Argument Value type
first instantiated model
second array; eg: recordings[“time”] = rec_t
third array; eg: recordings[“stimulus”] = rec_i
fourth
  • dictionary for runtime parameters
  • keys "dt", "celsius", "tstop", "v_init"
  • Eg: {“dt”: 0.01, “celsius”: 30, “tstop”: 100, “v_init”: 65}
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: See recordings_cell_currentstimulus().

NOTE:

  • this function is meant for generic stimulation of a cell
  • present release only supports current injection so this function may appear to be exactly the same as recordings_cell_currentstimulus().