peer package

Submodules

peer.peer_func module

Functions to predict eye movements

Authors:
peer.peer_func.estimate_em(_x_fix, _y_fix, _fix_xname, _fix_yname, _output_dir)[source]
Parameters:
  • _x_fix (float) – List of predicted fixations in the x-direction
  • _y_fix (float) – List of predicted fixations in the y-direction
  • _fix_xname (string) – Filename of the CSV containing fixation predictions in the x-direction
  • _fix_yname (string) – Filename of the CSV containing fixation predictions in the y-direction
  • _output_dir (string) – Pathname of the output directory
peer.peer_func.global_signal_regression(_data, _eye_mask_path)[source]

Performs global signal regression

Parameters:
  • _data (float) – Data from an fMRI scan as a 4D numpy array
  • _eye_mask_path – Pathname for the eye mask NIfTI file (the standard MNI152 2mm FSL template is used for the linked preprint)
Returns:

4D numpy array containing fMRI data after global signal regression

Return type:

_data

peer.peer_func.load_config()[source]

Loads configuration parameters as a dictionary from config.json

Returns:Dictionary containing configuration options from the config file (config.json)
Return type:_configs
peer.peer_func.load_data(_filepath)[source]

Loads fMRI data

Parameters:_filepath (string) – Pathname of the NIfTI file used to train a model or predict eye movements
Returns:_data – 4D numpy array containing fMRI data
Return type:float
peer.peer_func.load_model(_output_dir)[source]

Loads the SVR models used to estimate eye movements

Parameters:_output_dir (string) – Pathname of the output directory
Returns:
  • _xmodel – SVR model to estimate eye movements in the x-direction
  • _ymodel – SVR model to estimate eye movements in the y-direction
  • _xname (string) – Filename of the model used to estimate eye movements in the x-direction
  • _yname (stringf) – Filename of the model used to estimate eye movements in the y-direction
peer.peer_func.motion_scrub(_ms_filename, _data_dir, _motion_threshold)[source]

Determines volumes with high motion artifact

Parameters:
  • _ms_filename (string) – Pathname of the CSV file containing the framewise displacement per time point for a given fMRI scan
  • _data_dir (string) – Pathname of the directory containing data
  • _motion_threshold (float) – Threshold for high motion (framewise displacement, defined by Power et al. 2012)
Returns:

_removed_indices – List of volumes to remove for motion scrubbing

Return type:

int

peer.peer_func.predict_fixations(_xmodel, _ymodel, _data)[source]

Predict fixations

Parameters:
  • _xmodel – SVR model to estimate eye movements in the x-direction
  • _ymodel – SVR model to estimate eye movements in the y-direction
  • _data – 4D numpy array containing fMRI data used to predict eye movements (e.g., movie data)
Returns:

  • _x_fix (float) – List of predicted fixations in the x-direction
  • _y_fix (float) – List of predicted fixations in the y-direction

peer.peer_func.prepare_data_for_svr(_data, _removed_time_points)[source]

Preprocess fMRI data prior to SVR model generation

Parameters:
  • _data (float) – 4D numpy array containing fMRI data after global signal regression
  • _removed_time_points (int) – List of volumes to remove for motion scrubbing
Returns:

  • _processed_data (float) – List of numpy arrays, where each array contains the averaged intensity values for each calibration point
  • _calibration_points_removed (int) – List of calibration points removed if all volumes for a given calibration point were high motion

peer.peer_func.save_fixations(_x_fix, _y_fix, _xname, _yname, _output_dir)[source]

Save predicted fixations

Parameters:
  • _x_fix (float) – List of predicted fixations in the x-direction
  • _y_fix (float) – List of predicted fixations in the y-direction
  • _xname (string) – Filename of the model used to estimate eye movements in the x-direction
  • _yname (string) – Filename of the model used to estimate eye movements in the y-direction
  • _output_dir (string) – Pathname of the output directory
Returns:

  • _fix_xname (string) – Filename of the CSV containing fixation predictions in the x-direction
  • _fix_yname (string) – Filename of the CSV containing fixation predictions in the y-direction

peer.peer_func.save_model(_xmodel, _ymodel, _train_file, _ms, _gsr, _output_dir)[source]

Saves the SVR models used in the PEER method

Parameters:
  • _xmodel – SVR model to estimate eye movements in the x-direction
  • _ymodel – SVR model to estimate eye movements in the y-direction
  • _train_file (string) – Pathname of the NIfTI file used to train the SVR model
  • _ms (bool) – Whether or not to use motion scrubbing
  • _gsr (bool) – Whether or not to use global signal regression
  • _output_dir – Pathname of the output directory
peer.peer_func.scaffolding()[source]

Creates the project folder and file hierarchy and returns pathnames

Returns:
  • _project_dir (string) – Pathname of the highest-level project directory
  • _data_dir (string) – Pathname of the directory containing data
  • _output_dir (string) – Pathname of the output directory
  • _stimulus_path (string) – Pathname of the PEER calibration scan stimuli
peer.peer_func.set_parameters(_configs, new=False)[source]

Sets configuration parameters

Parameters:
  • _configs – Dictionary containing configuration options from the config file (config.json)
  • new (bool) – Do you want to start from a new file?
Returns:

Updated dictionary containing configuration options from the config file (config.json)

Return type:

_configs

peer.peer_func.train_model(_data, _calibration_points_removed, _stimulus_path)[source]

Trains the SVR model used in the PEER method

Parameters:
  • _data (float) – List of numpy arrays, where each array contains the averaged intensity values for each calibration point
  • _calibration_points_removed (int) – List of calibration points removed if all volumes for a given calibration point were high motion
  • _stimulus_path (string) – Pathname of the PEER calibration scan stimuli
Returns:

  • _xmodel – SVR model to estimate eye movements in the x-direction
  • _ymodel – SVR model to estimate eye movements in the y-direction

peer.create_peer module

peer.estimate_eyemove module

peer.reset_config module

Script used on the command line to reset configuration file

Authors:
peer.reset_config.update_config()[source]

Module contents