Skip to main content

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,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 0-179° degrees
# nfolds refers to the K to use for KFold cross-validation. We recommend setting this to the number of runs you have for 1-run-left-out CV.
# 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.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inverted-encoding 0.2.3
File Size Uploaded Provenance Actions
inverted_encoding-0.2.3.tar.gz 155.8 kB Without provenance Details for inverted_encoding-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inverted-encoding 0.2.3
File Interpreter ABI Platform Actions
inverted_encoding-0.2.3-py3-none-any.whl Python 3 none any Details for inverted_encoding-0.2.3-py3-none-any.whl

Total release size: 182.7 kB

Release files / inverted_encoding-0.2.3.tar.gz

Download URL inverted_encoding-0.2.3.tar.gz
Size 155.8 kB
Tags Source
SHA-256 checksum
How to use checksums
49ffbfc02782556afedd9db2404907cffbd16be13306d1be89ccf2c2bfdb3916
BLAKE2b-256 checksum
How to use checksums
ec77ab4005b23ea1318936ee821b885c74dfdc9967f6e883b60d9dbeae11dfd5
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.12

Release files / inverted_encoding-0.2.3-py3-none-any.whl

Download URL inverted_encoding-0.2.3-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1dc075404f9c412043771a743986ed9a076f29c54e7038c25a946899563d038
BLAKE2b-256 checksum
How to use checksums
98086e671b28a6817f6a67481a93a2f6b1d3bf7e3ca8a72dab9d56334eb2cb5f
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.12

Security for inverted-encoding 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page