Skip to content

ndi.viz.modulationIndex

 MODULATIONINDEX Adds a modulation index column to a table based on paired responses.
    T_OUT = NDI.VIZ.MODULATIONINDEX(T, NAMEVALUEARGS) calculates a
    modulation index and adds it as a new column to the input table T.

    DESCRIPTION:
    This function identifies pairs of rows corresponding to 'mean' (unmodulated)
    and 'F1' (modulated) responses and computes an index (2 * X.TC.F1/(X.TC.F1+X.TC.mean)).
    The result is added as a new column to the input table. The column name is derived
    from the tuning curve data column (e.g., if data is from 'X.TC.mean',
    the new column will be 'X.TC.modulationIndex').

    For each calculated index, the value is assigned to BOTH rows in the
    'mean'/'F1' pair. All other rows not part of a successful pair calculation
    will have a NaN value in this new column.

    The function performs several steps:
    1.  Identifies columns for response type ('mean'/'F1') and tuning curve data.
    2.  Groups rows based on identifying columns (e.g., element ID, session ID).
    3.  Pairs 'mean' and 'F1' rows within each group using the closest timestamp.
    4.  Calculates the modulation index for each pair and populates the new column.

    INPUTS:
    T - A MATLAB table containing the data. This table will be modified.

    NAME-VALUE PAIRS:
    'restrictToZeroTwo' - (Optional) Logical. If true (default), the calculated
        modulation index is restricted to the range [0, 2].
    'responseTypeColumn' - (Optional) Name of the column that indicates the
        response type ('mean' or 'F1'). Searched automatically if not provided.
    'TuningCurveMeanColumn' - (Optional) Name of the column with tuning curve data.
        Searched automatically if not provided.
    'rowPairConstantColumns' - (Optional) Cell array of columns that must have
        identical values to form a group.
        Default: {'depends_on_element_id', 'base.session_id', ...
                  'document_class.class_name', 'document_class.class_version'}

    OUTPUTS:
    T - The input table with one new column, `X.TC.modulationIndex`, added.

    EXAMPLE:
    % Assume 'myData' is a table structured like the example in the prompt.
    myData_with_MI = ndi.viz.modulationIndex(myData);