Skip to main content

Implementation of inverted encoding model as described in Scotti, Chen, & Golomb

Project description

Inverted Encoding

Python package for easy implementation of inverted encoding modeling as described in Scotti, Chen, & Golomb (in-prep).

Contact: scottibrain@gmail.com (Paul Scotti)


Installation

Run the following to install:

pip install inverted-encoding

Usage

from inverted_encoding import IEM, permutation, circ_diff
import numpy as np

predictions, confidences, aligned_at_prediction_recons, aligned_at_zero_recons = IEM(trialbyvoxel,features,stim_max=180,is_circular=True)
# use "help(IEM)" for more information, below is a summary:
# trialbyvoxel: your matrix of brain activations, does not necessarily have to be voxels
# features: array of your stimulus features (must be integers within range defined by stim_max)
# stim_max=180 means that your stimulus space ranges 0-179° degrees
# is_circular=True for a circular stimulus space, False for non-circular stimulus space
# predictions: array of predicted stimulus for each trial
# confidences: array of goodness of fit values for each trial
# aligned_at_prediction_recons: trial-by-trial reconstructions (matrix of num_trials x stim_max) such that
# when plotted ideally each reconstruction is centered at the original trial stimulus
# aligned_at_zero_recons: trial-by-trial reconstructions aligned at zero, such that when
# plotted ideally each reconstruction is centered at zero on the x axis (e.g., plt.plot(aligned_at_zero_recons[trial,:]))

## Compute mean absolute error (MAE) by doing the following, then compare to null distribution:
if is_circular: # if your stimulus space is circular, need to compute circular differences
    mae = np.mean(np.abs(circ_diff(predictions,features,stim_max))) 
else:
    mae = np.mean(np.abs(predictions-features)) 
null_mae_distribution = permutation(features,stim_max=180,num_perm=1000,is_circular=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inverted_encoding-0.2.0.tar.gz (171.2 kB view details)

Uploaded Source

Built Distribution

inverted_encoding-0.2.0-py2-none-any.whl (26.7 kB view details)

Uploaded Python 2

File details

Details for the file inverted_encoding-0.2.0.tar.gz.

File metadata

  • Download URL: inverted_encoding-0.2.0.tar.gz
  • Upload date:
  • Size: 171.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for inverted_encoding-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a04be7da08d1543c1b0d5ff05eab708d777ddd310753ffbeb9bbf5aecea370c4
MD5 c8790aa699520c79e1101bbd198d11ba
BLAKE2b-256 b3b8e6d5123d1722d6e9350d884d54807d633af035f03647b2d8ab6f52f00eca

See more details on using hashes here.

File details

Details for the file inverted_encoding-0.2.0-py2-none-any.whl.

File metadata

  • Download URL: inverted_encoding-0.2.0-py2-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for inverted_encoding-0.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 dce9b2c734fa5dab9712f68489fb4dbda5b967b2c944c1ab83374f1ff81e837d
MD5 f832ce7bac66f33e9255b9a729118cfe
BLAKE2b-256 de7377f47f1ad3d79e0b5061903be82b9b1637b51754ad469bb57c3e69e4cdc0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page