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)
Metadata
Release files for inverted-encoding 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| inverted_encoding-0.1.6.tar.gz | 148.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| inverted_encoding-0.1.6-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 174.9 kB
Release files / inverted_encoding-0.1.6.tar.gz
| Download URL | inverted_encoding-0.1.6.tar.gz |
|---|---|
| Size | 148.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e6ef9b7d59baddb2fa4c50833bb0040dbe7ebb98105cb14192bdc6a7191def9
|
|
BLAKE2b-256 checksum How to use checksums |
60087f65443a3a1f324844ecee99e1dcc5aee670c8d28479a353c746a8d99283
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / inverted_encoding-0.1.6-py2-none-any.whl
| Download URL | inverted_encoding-0.1.6-py2-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
a52b1eb6673b84c3c465860bb3703443faa94aa9d2656810cf2f16ffeb55af89
|
|
BLAKE2b-256 checksum How to use checksums |
06e944c0a99c8fd1bd26524ab761460a8f0ed72f571dd293a21ed43c3c413688
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|