Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

nilearn.glm.first_level.check_design_matrix

nilearn.glm.first_level.check_design_matrix(design_matrix)[source]

Check that the provided DataFrame is indeed a valid design matrix descriptor, and returns a triplet of fields.

Parameters:
design matrixpandas.DataFrame

Describes a design matrix.

Returns:
frame_timesarray of shape (n_frames,),

Sampling times of the design matrix in seconds.

matrixarray of shape (n_frames, n_regressors), dtype=’f’

Numerical values for the design matrix.

namesarray of shape (n_events,), dtype=’f’

Per-event onset time (in seconds)

Examples

>>> import pandas as pd
>>> from nilearn.glm.first_level import check_design_matrix
>>>
>>> # Create a mock design matrix.
>>> design_matrix = pd.DataFrame(
...     data={"col1": [1, 2], "col2": [3, 4]},
...     index=[3, 4],
... )
>>>
>>> # Check the design matrix.
>>> frame_times, matrix, names = check_design_matrix(design_matrix)
>>> frame_times
Index([3, 4], dtype='int64')
>>> matrix
array([[1, 3],
       [2, 4]])
>>> names
['col1', 'col2']