Creating a custom ctv - galizia-lab/pyview GitHub Wiki

A custom CTV is essentially a python function with a specific signature:

def <ctv_name>(time_trace, first_frame, last_frame, sampling_period, stim_on_times, stim_off_times, flags, p1):
    """
    <insert a brief description of the method here>
    :param time_trace: iterable of numbers
    :param first_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
    :param last_frame: int, interpreted as a frame number, where frames are numbered 1, 2, 3...
    :param sampling_period: float, sampling period of <time_trace>, in ms
    :param stim_on_times: list of floats, stimulus onset times, in ms
    :param stim_off_times: list of floats, stimulus offset times, in ms
    :param flags: FlagsManager object, is a mapping of flag names to flags values with additional functions
    :param p1: pandas.Series object, internal representation of data
    :return: float
    """
    <insert python code calculating CTV value from the time trace <time_trace> using other available variables>
    return <your calculated CTV value>

Procedure

  1. Copy the above template to a file
  2. Replace <ctv_name> with the name you want to give to your CTV method. Note that this name:
    • can only contain lower case letters (a-z), upper case letters (A-Z), numbers (0-9) and the underscore (_)
    • cannot start with a number or an underscore
  3. Replace <insert a brief description of the method here> above with a brief description of your method
  4. Replace <insert python code calculating CTV value from the time trace <time_trace> using other available variables> with the body of your CTV function. Here you can use the variables described above in the doc string, i.e. time_trace, first_frame, last_frame etc.
  5. Replace <your calculated CTV value> with the variable containing the CTV value calculated.

flags and p1

The time trace (time_trace), its sampling period (sampling_period), stimulus information (stim_on_times and stim_off_times) and a couple of general purpose numerical flags (first_frame and last_frame, respectively from CTV_firstframe and CTV_lastframe) are available in the body of CTV method. When other information about data or flags from VIEW are needed to implement the CTV method, they are available in flags and p1.

Specification in VIEW

To use a custom CTV in view, set the flag CTV_Method to the name of the ctv (i.e., <ctv_name> above) and CTV_MethodFile to the full path of the file containing this function.

⚠️ **GitHub.com Fallback** ⚠️