From 976a9436ee404823e708dd7e3cc3f261e57840e5 Mon Sep 17 00:00:00 2001
From: Maximilian Schmidt <max.schmidt@fz-juelich.de>
Date: Fri, 25 May 2018 18:28:31 +0900
Subject: [PATCH] Add documentation to scripts

---
 figures/Schmidt2018_dyn/compute_bold_signal.py       |  6 ++++++
 figures/Schmidt2018_dyn/compute_corrcoeff.py         |  7 ++++++-
 figures/Schmidt2018_dyn/compute_cross_correlation.py |  5 +++++
 .../compute_functional_connectivity.py               |  6 ++++++
 figures/Schmidt2018_dyn/compute_granger_causality.py |  7 +++++++
 .../Schmidt2018_dyn/compute_louvain_communities.py   |  7 +++++++
 figures/Schmidt2018_dyn/compute_pop_LvR.py           |  5 +++++
 figures/Schmidt2018_dyn/compute_pop_rates.py         |  7 ++++++-
 figures/Schmidt2018_dyn/compute_power_spectrum.py    | 12 ++++++++++++
 figures/Schmidt2018_dyn/compute_rate_histogram.py    |  6 ++++++
 figures/Schmidt2018_dyn/compute_rate_time_series.py  | 12 +++++++++++-
 11 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/figures/Schmidt2018_dyn/compute_bold_signal.py b/figures/Schmidt2018_dyn/compute_bold_signal.py
index a10f5a5..ac72a79 100644
--- a/figures/Schmidt2018_dyn/compute_bold_signal.py
+++ b/figures/Schmidt2018_dyn/compute_bold_signal.py
@@ -3,6 +3,12 @@ import os
 import sys
 
 
+"""
+Compute BOLD signal for a given area from the time series of
+population-averaged spike rates of a given simulation using the
+neuRosim package of R (see Schmidt et al. 2018 for more details).
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 area = sys.argv[3]
diff --git a/figures/Schmidt2018_dyn/compute_corrcoeff.py b/figures/Schmidt2018_dyn/compute_corrcoeff.py
index 34ced53..4bd7f88 100644
--- a/figures/Schmidt2018_dyn/compute_corrcoeff.py
+++ b/figures/Schmidt2018_dyn/compute_corrcoeff.py
@@ -6,6 +6,11 @@ import correlation_toolbox.helper as ch
 from multiarea_model import MultiAreaModel
 import sys
 
+"""
+Compute correlation coefficients for a subsample
+of neurons for the entire network from raw spike files of a given simulation.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 
@@ -31,7 +36,7 @@ M = MultiAreaModel({})
 
 spike_data = {}
 cc_dict = {}
-for area in ['V1', 'V2', 'FEF']:
+for area in M.area_list:
     cc_dict[area] = {}
     LvR_list = []
     N = []
diff --git a/figures/Schmidt2018_dyn/compute_cross_correlation.py b/figures/Schmidt2018_dyn/compute_cross_correlation.py
index fe607f7..905ebb9 100644
--- a/figures/Schmidt2018_dyn/compute_cross_correlation.py
+++ b/figures/Schmidt2018_dyn/compute_cross_correlation.py
@@ -5,6 +5,11 @@ import numpy as np
 import os
 import sys
 
+""" 
+Compute the cross-correlation betwen two given areas from their
+time series of population-averaged spike rates of a given simulation.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 area1 = sys.argv[3]
diff --git a/figures/Schmidt2018_dyn/compute_functional_connectivity.py b/figures/Schmidt2018_dyn/compute_functional_connectivity.py
index 87eb487..14afe4c 100644
--- a/figures/Schmidt2018_dyn/compute_functional_connectivity.py
+++ b/figures/Schmidt2018_dyn/compute_functional_connectivity.py
@@ -7,6 +7,12 @@ from multiarea_model import MultiAreaModel
 from scipy.spatial.distance import pdist
 from scipy.spatial.distance import squareform
 
+"""
+Compute the functional connectivity between all areas of a given
+simulation based on their time series of spiking rates or their
+estimated BOLD signal.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 method = sys.argv[3]
diff --git a/figures/Schmidt2018_dyn/compute_granger_causality.py b/figures/Schmidt2018_dyn/compute_granger_causality.py
index b93d17d..e457582 100644
--- a/figures/Schmidt2018_dyn/compute_granger_causality.py
+++ b/figures/Schmidt2018_dyn/compute_granger_causality.py
@@ -9,6 +9,13 @@ from multiarea_model.multiarea_helpers import create_mask
 from scipy.stats import levene
 from statsmodels.tsa.vector_ar.var_model import VAR
 
+
+"""
+Compute the conditional Granger causality to a given population of an
+area based on the population-averaged spike rates from a given
+simulation.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 area = sys.argv[3]
diff --git a/figures/Schmidt2018_dyn/compute_louvain_communities.py b/figures/Schmidt2018_dyn/compute_louvain_communities.py
index f3913fd..5d55872 100644
--- a/figures/Schmidt2018_dyn/compute_louvain_communities.py
+++ b/figures/Schmidt2018_dyn/compute_louvain_communities.py
@@ -8,6 +8,13 @@ import sys
 
 from multiarea_model.multiarea_model import MultiAreaModel
 
+"""
+Determines communities in the functional connectivity of either the
+experimental fMRI data used in Schmidt et al. 2018 or of a given
+simulation (the functional connectivity being based either on spike
+rates or an estimated BOLD signal).
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 method = sys.argv[3]
diff --git a/figures/Schmidt2018_dyn/compute_pop_LvR.py b/figures/Schmidt2018_dyn/compute_pop_LvR.py
index 9128ffd..cd0d070 100644
--- a/figures/Schmidt2018_dyn/compute_pop_LvR.py
+++ b/figures/Schmidt2018_dyn/compute_pop_LvR.py
@@ -6,6 +6,11 @@ from multiarea_model.analysis_helpers import pop_LvR
 from multiarea_model import MultiAreaModel
 import sys
 
+"""
+Compute LvR for the entire network from raw spike
+files of a given simulation.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 
diff --git a/figures/Schmidt2018_dyn/compute_pop_rates.py b/figures/Schmidt2018_dyn/compute_pop_rates.py
index 784f9a0..88a9945 100644
--- a/figures/Schmidt2018_dyn/compute_pop_rates.py
+++ b/figures/Schmidt2018_dyn/compute_pop_rates.py
@@ -6,6 +6,11 @@ from multiarea_model.analysis_helpers import pop_rate
 from multiarea_model import MultiAreaModel
 import sys
 
+"""
+Compute stationary spike rates for the entire network from raw spike
+files of a given simulation.
+"""
+
 data_path = sys.argv[1]
 label = sys.argv[2]
 
@@ -27,7 +32,7 @@ M = MultiAreaModel({})
 
 spike_data = {}
 pop_rates = {}
-for area in ['V1', 'V2', 'FEF']:
+for area in M.area_list:
     pop_rates[area] = {}
     rate_list = []
     N = []
diff --git a/figures/Schmidt2018_dyn/compute_power_spectrum.py b/figures/Schmidt2018_dyn/compute_power_spectrum.py
index 3cba554..3555077 100644
--- a/figures/Schmidt2018_dyn/compute_power_spectrum.py
+++ b/figures/Schmidt2018_dyn/compute_power_spectrum.py
@@ -6,6 +6,18 @@ from multiarea_model import MultiAreaModel
 from multiarea_model.analysis_helpers import centralize
 from scipy.signal import welch
 
+
+"""
+Compute the power spectrum time series for a given area of
+population-averaged spike rates of a given simulation.
+
+The spike rates can be based on three different methods:
+- binned spike histograms on all neurons ('full')
+- binned spike histograms on a subsample of 140 neurons ('subsample')
+- spike histograms convolved with a Gaussian kernel of optimal width
+  after Shimazaki et al. (2010)
+"""
+
 # Parameters for Welch Power Spectral density and spectrogram
 noverlap = 1000
 nperseg = 1024
diff --git a/figures/Schmidt2018_dyn/compute_rate_histogram.py b/figures/Schmidt2018_dyn/compute_rate_histogram.py
index c351b33..6e5dec0 100644
--- a/figures/Schmidt2018_dyn/compute_rate_histogram.py
+++ b/figures/Schmidt2018_dyn/compute_rate_histogram.py
@@ -6,6 +6,12 @@ import sys
 from multiarea_model import MultiAreaModel
 from multiarea_model.analysis_helpers import pop_rate_distribution
 
+
+"""
+Compute histogram of spike rates over single neurons for a given area
+from raw spike files of a given simulation.
+"""
+
 assert(len(sys.argv) == 4)
 data_path = sys.argv[1]
 label = sys.argv[2]
diff --git a/figures/Schmidt2018_dyn/compute_rate_time_series.py b/figures/Schmidt2018_dyn/compute_rate_time_series.py
index 4a2ebfc..c4956af 100644
--- a/figures/Schmidt2018_dyn/compute_rate_time_series.py
+++ b/figures/Schmidt2018_dyn/compute_rate_time_series.py
@@ -2,7 +2,6 @@ import json
 import neo
 import numpy as np
 import os
-import pandas as pd
 import quantities as pq
 
 from multiarea_model.analysis_helpers import pop_rate_time_series
@@ -10,6 +9,17 @@ from elephant.statistics import instantaneous_rate
 from multiarea_model import MultiAreaModel
 import sys
 
+"""
+Compute time series of population-averaged spike rates for a given
+area from raw spike files of a given simulation.
+
+Implements three different methods:
+- binned spike histograms on all neurons ('full')
+- binned spike histograms on a subsample of 140 neurons ('subsample')
+- spike histograms convolved with a Gaussian kernel of optimal width
+  after Shimazaki et al. (2010)
+"""
+
 assert(len(sys.argv) == 5)
 
 data_path = sys.argv[1]
-- 
GitLab