Python NeuroWarp
Python NeuroWarp is provided as a package that can be installed via PyPi. It consists of two functions that can be called after importing neurowarp: timeseries_correlation and latency_difference - these are the general-purpose scripts enable the DTW analyses presented in Transient Attention Gates Access Consciousness: Coupling N2pc and P3 Latencies using Dynamic Time Warping.
Installation
We recommend that you create a new virtual environment for our module via:
-
Open a terminal / cmd.exe window, navigate (via
cd) to the directory you want to create the environment and enter:python -m venv neurowarp_env -
Activate the neurowarp_env via:
Windows:
path\to\neurowarp_env\Scripts\activateMacOS:
source neurowarp_env/bin/activate -
Install neurowarp via pip (enter while neurowarp_env is active):
pip install neurowarp -
The functions can be used as explained below after importing the module
For more detail on virtual environments & pip click here
DTW Temporal Correlation - neurowarp.timeseries_correlation()
Perform a DTW based bootstrap analysis to assess the temporal correlation between two time series (Figure 5 of our paper).
Important Notes
- Time series must be 2D matrices
- I.e., data points (e.g. time) x subjects (i.e., replications)
- We provide the ERPs of correct and intrusion trials for users to explore this function
Running timeseries_correlation using our ERPs
Enter the following into Python and make sure to enter your actual paths!
import neurowarpfrom scipy.io import loadmatdata = loadmat("your/path/to/example_series_N2pcP3s")series_1 = data["P3_Correct"]series_2 = data["N2pc_Correct"]name_1 = "P3"name_2 = "N2pc"savepath = "where/to/store/results/to"num_boots = 10000- The number of bootstrap samples that you want to implement
outlier = 0- Exclude outliers if their DTW area is +-5 standard deviations from the mean
try_to_fix_ylims = 1- Attempt to standardise y-limits of marginals
neurowarp.timeseries_correlation(series_1, series_2, name_1, name_2, savepath, num_boots, outlier, try_to_fix_ylims)
Note that the figure will look slightly different to that of our paper due to different x/y limits. See the replicate_figures folder if you want to replicate our figure as it was printed.
DTW Latency Difference - neurowarp.latency_difference()
Assess the latency difference between two conditions (i.e., within-subjects effect) or between two groups (i.e., across-subjects effect) of any signal of interest (in milliseconds).
Figures 3 & 4 of our paper show a two conditions analysis
Important Notes
- Reference and query time series must be 2D matrices
- I.e., data points (e.g., time) x subjects (i.e., replications)
- Time series have to be of equal sizes
- analysis_design determines whether you want to assess a within- or between-subjects latency effect (can only take “within” or “between” as input)
- We provide the ERPs of correct and intrusion trials for users to explore this function
Running timeseries_correlation using our ERPs
Enter the following into Python and make sure to enter your actual paths!
import neurowarpfrom scipy.io import loadmatdata = loadmat("your/path/to/example_series_N2pcP3s")analysis_design = "within"query = data["N2pc_Intrusion"]reference = data["N2pc_Correct"]name_query = "Intrusion"name_reference = "Correct"units = "\u03BCV"- The units that your signals are measured in (in our case micro volts)
sampling_rate = 500- The number of data points per second in Hertz
savepath = "where/to/store/results/to"permutations = 10000- The number of permutations you would like to implement in statistical testing (we recommend >=10000)
neurowarp.latency_difference(analysis_design, query, reference, name_query, name_reference,units, sampling_rate, savepath, permutations)
Dependencies
Python NeuroWarp requires the following toolboxes which are automatically installed via pip install neurowarp
- Numpy
- Matplotlib
- Tslearn
- Scipy
Tests
Python NeuroWarp was tested with Python 3.10.9.
Metadata
Release files for neurowarp 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neurowarp-0.0.5.tar.gz | 154.8 kB | Without provenance | Details for neurowarp-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neurowarp-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for neurowarp-0.0.5-py3-none-any.whl |
Total release size: 168.2 kB
Release files / neurowarp-0.0.5.tar.gz
| Download URL | neurowarp-0.0.5.tar.gz |
|---|---|
| Size | 154.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99b4d5f6b6c193f25f63cdf471878b1afc3f81dfc851f1f2aa9528f6e6e09f67
|
|
BLAKE2b-256 checksum How to use checksums |
e81889702cd2cebc43dae7b8cb805a3f149face031758e415dcbc9f26ca1a3ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / neurowarp-0.0.5-py3-none-any.whl
| Download URL | neurowarp-0.0.5-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f33c9248eb6ba82415a83da400e903c2126277754e76e27d5f18045298f8803e
|
|
BLAKE2b-256 checksum How to use checksums |
a290f991a1d6346f84c0567f41a300473952d3f08c80ff2234d73a1e6cce2e02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for neurowarp 0.0.5
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.