DynamicsAndNeuralSystems / pyspi

Comparative analysis of pairwise interactions in multivariate time series.
https://time-series-features.gitbook.io/pyspi/
GNU General Public License v3.0
199 stars 26 forks source link

Compute only subset of SPIs in Calculator #4

Closed LuRoe7 closed 2 years ago

LuRoe7 commented 2 years ago

First of all: great preprint, great package!! It will facilitate the research at our lab essentially!!!

I was wondering how to tell the Calculator function to compute only a few SPIs that I am interested in in order to save processing time?

Best, Lukas

olivercliff commented 2 years ago

Hi Lukas,

Thank you! I'm working on documentation that illustrates how to use all the toolkit's functionality like this. In the meantime, I'll put some details here.

You can easily use a subset of the SPIs by editing the configuration file, config.yaml, to only include statistics that you want. I tried to make the names in the configuration file as user-friendly as possible, but if you're unsure of what any of them are, you should be able to cross-reference them with the supplementary material in the preprint (or simply ask me).

To make sure you don't override the original config.yaml, though, I would probably suggest editing a local copy of the file (details below).

Say you've cloned the repository to ~/toolkits/pyspi, and you're working in the directory ~/workspace. First, copy the config.yaml file to your working directory:

cp ~/toolkits/pyspi/pyspi/config.yaml ~/workspace/myconfig.yaml

Once you've got your local version, edit the myconfig.yaml file to remove any SPIs you're not interested in. A minimal myconfig.yaml might look like the following if you're only interested in computing a covariance matrix using the maximum likelihood estimator:

# Basic statistics
.statistics.basic:

  # Covariance
  covariance:

    # Maximum likelihood estimator
    - estimator: EmpiricalCovariance

Now, when you instantiate the calculator, instead of using the default config.yaml, you can input your bespoke file:

from pyspi.calculator import Calculator

calc = Caculator(dataset=dataset,configfile='~/workspace/myconfig.yaml')
calc.compute()
LuRoe7 commented 2 years ago

Thank you! And again: amazing work :)