-
Previous study (Klein et al.) : Fit torus graph to multivariate circular data and view test statistics under null hypothesis that two nodes are independent.
-
Ours : Regularized score matching of the torus graph model to obtain sparse solutions.
-
Note: These models do not handle time series information.
- model/
- model (old)
- torus_graph (new) : class
- torus_graph_cupy (new) : accelerated with cupy, only in GPU environment
- output: the results will be saved.
- utils/
- utils: preprocessing for neuroscience time series data.
- visualize: visualization of correlation matrix (and its variant)
- simulation : for simulation studies
- script
- bias_correction.py : to check SMIC is correcting the inherit bias. long computation.
- main : to run inference. It takes around 15min for naive estimation and additional 15~30min for Group LASSO estimation.
- constant : file names and so on.
- run_paper_experiment : reproduction of results in our paper
- view*.py : to observe estimated graph structures and properties
import sys
sys.path.append(".")
from model.torus_graph import Torus_Graph
from utils.simulation import sample_from_torus_graph, star_shaped_sample
import numpy as np
data_arr = star_shaped_sample(1000) # 5 dimensional sample from a torus graph
M = Torus_Graph(5)
M.estimate(data_arr,mode="naive")
# M.estimate(data_arr,mode="lasso") #If you want to use lasso, run it after naive estimation, otherwise it fails.
M.plot(weight=True)
With Cupy(GPU) acceleration [not recommended]
import sys
sys.path.append(".")
from model.torus_graph_cupy import Torus_Graph
from utils.simulation import sample_from_torus_graph, star_shaped_sample
import numpy as np
data_arr = star_shaped_sample(1000) # 5 dimensional sample from a torus graph
M = Torus_Graph(5)
M.estimate(data_arr,mode="naive")
M.plot(weight=True)
- lasso : regularization on full parameters equally
- glasso : regularization on d nodes and on d*(d-1)/2 edges by group (Group LASSO)
M.lambda_list = [0] + np.logspace(-3,0.5, num=99).tolist() #recommended canditate set of lambdas
M.glasso_weight = [0 for _ in range(2*M.d)] + [1 for _ in range(2*M.d*M.d-2*M.d)] #recommended weight setting of regularization terms
M.estimate(data_arr,mode="glasso")
python script/main.py
#or
python script/run_paper_experiment.py -e 0 -p 2 -s 0
Sequence task
bash run.sh
CV1() runs 5 dimensional Group LASSO. (100 candidates)
CV2() runs 3 dimensional naive estimation. (
python script/crossvalidation.py
Set path to load.
#script/view_graph.py
...
filename = "PATH TO YOUR PKL FILE"
...
Then run it to output images with colored edges and nodes. The size of nodes reflects the degree. The color of nodes represents community structures.
python script/view_graph.py
This repository is partly a reimplementation of Klein et al, 2020.
We thank the developers of the EEG dataset we used Chennu et al., 2016.
coming soon...