Skip to content

Phase Encoding Analysis (Python)

mario.senden edited this page May 31, 2020 · 5 revisions

In phase-encoded retinotopic mapping stimulation is periodic, allowing polar angle (rotating wedge) and eccentricity (expanding / contracting ring) to be encoded in the phase of the BOLD signal observed in each voxel. This phase can be extracted in a number of ways (e.g. cross-correlation). In the PEA tool provided in the CNI toolbox, the phase is extracted by using a cosine and sine wave at the stimulation frequency as predictors in a linear regression. This allows not only to extract phase and amplitude of each voxel's response from the fit beta coefficients, but also to obtain an F-statistic and p-value to assess statistical significance. Below follows an instruction on how to use the tool.

Instantiation

The tool needs to be instantiated with a number of parameters:

  • f_sampling - sampling frequency of data acquisition (1 / TR)
  • f_stim - stimulation frequency of the retinotopy experiment
  • n_samples - number of samples (functional volumes)
  • n_rows - number of rows (1st volumetric dimension of 4D data tensor)
  • n_cols - number of columns (2nd volumetric dimension of 4D data tensor)
  • n_slices - number of rows (3rd volumetric dimension of 4D data tensor)
from cni_tlbx import PEA

n_samples, n_rows, n_cols, n_slices = data.shape
parameters = {'f_sampling': sampling_frequency,
        'f_stim': stimulation_frequency,
        'n_samples': n_samples,
        'n_rows': n_rows,
        'n_cols': n_cols,
        'n_slices': n_slices}

pea = PEA(parameters)

Usage

The pea instance can now be used to analyze data from runs sharing the same basic parameters specified before. For each of such run, a signal delay (in seconds; caused by the sluggishness of the BOLD signal) and a direction of rotation needs to be specified. Note that contracting rings are considered to move clockwise while expanding rings are consider to move counter-clockwise.

pea.set_delay(delay_value)
pea.set_direction('ccw')
results = pea.fitting(data)

During fitting, voxels whose mean signal intensity falls below a threshold will be skipped during analysis. This threshold can be adjusted. Specifically, the fitting function takes two optional arguments:

  • threshold - a mean signal intensity threshold below which a voxel is skipped (default = 100)
  • mask - a binary mask specifying for which voxels the analysis shouldbe carried out (default = [])

The function returns a dictionary (results) with four keys:

  • phase - phase of a voxel's signal at stimulation frequency
  • amplitude - amplitude of a voxel's signal at stimulation frequency
  • f_statistic - F statistic per voxel
  • p_value - P value per voxel

Values corresponding to each key retain the volumetric dimensions of the data.