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 (inprep).
Contact: scottibrain@gmail.com (Paul Scotti)
Installation
Run the following to install:
pip install invertedencoding
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,nfolds=num_runs,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 0179° degrees
# nfolds refers to the K to use for KFold crossvalidation. We recommend setting this to the number of runs you have for 1runleftout CV.
# is_circular=True for a circular stimulus space, False for noncircular stimulus space
# predictions: array of predicted stimulus for each trial
# confidences: array of goodness of fit values for each trial
# aligned_at_prediction_recons: trialbytrial 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: trialbytrial 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(predictionsfeatures))
null_mae_distribution = permutation(features,stim_max=180,num_perm=1000,is_circular=True)
Project details
Release history Release notifications  RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
inverted_encoding0.2.3.tar.gz
(155.8 kB
view hashes)
Built Distribution
Close
Hashes for inverted_encoding0.2.3py3noneany.whl
Algorithm  Hash digest  

SHA256  b1dc075404f9c412043771a743986ed9a076f29c54e7038c25a946899563d038 

MD5  8530dd8a22bc715c98d9c0e95fab614a 

BLAKE2b256  98086e671b28a6817f6a67481a93a2f6b1d3bf7e3ca8a72dab9d56334eb2cb5f 