repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.network_from_edgelist
def network_from_edgelist(self, edgelist): """ Defines a network from an array. Parameters ---------- edgelist : list of lists. A list of lists which are 3 or 4 in length. For binary networks each sublist should be [i, j ,t] where i and j are node indicies and t is t...
python
def network_from_edgelist(self, edgelist): """ Defines a network from an array. Parameters ---------- edgelist : list of lists. A list of lists which are 3 or 4 in length. For binary networks each sublist should be [i, j ,t] where i and j are node indicies and t is t...
[ "def", "network_from_edgelist", "(", "self", ",", "edgelist", ")", ":", "teneto", ".", "utils", ".", "check_TemporalNetwork_input", "(", "edgelist", ",", "'edgelist'", ")", "if", "len", "(", "edgelist", "[", "0", "]", ")", "==", "4", ":", "colnames", "=", ...
Defines a network from an array. Parameters ---------- edgelist : list of lists. A list of lists which are 3 or 4 in length. For binary networks each sublist should be [i, j ,t] where i and j are node indicies and t is the temporal index. For weighted networks each subli...
[ "Defines", "a", "network", "from", "an", "array", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L227-L243
wiheto/teneto
teneto/classes/network.py
TemporalNetwork._drop_duplicate_ij
def _drop_duplicate_ij(self): """ Drops duplicate entries from the network dataframe. """ self.network['ij'] = list(map(lambda x: tuple(sorted(x)), list( zip(*[self.network['i'].values, self.network['j'].values])))) self.network.drop_duplicates(['ij', 't'], inplace=Tr...
python
def _drop_duplicate_ij(self): """ Drops duplicate entries from the network dataframe. """ self.network['ij'] = list(map(lambda x: tuple(sorted(x)), list( zip(*[self.network['i'].values, self.network['j'].values])))) self.network.drop_duplicates(['ij', 't'], inplace=Tr...
[ "def", "_drop_duplicate_ij", "(", "self", ")", ":", "self", ".", "network", "[", "'ij'", "]", "=", "list", "(", "map", "(", "lambda", "x", ":", "tuple", "(", "sorted", "(", "x", ")", ")", ",", "list", "(", "zip", "(", "*", "[", "self", ".", "ne...
Drops duplicate entries from the network dataframe.
[ "Drops", "duplicate", "entries", "from", "the", "network", "dataframe", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L260-L268
wiheto/teneto
teneto/classes/network.py
TemporalNetwork._drop_diagonal
def _drop_diagonal(self): """ Drops self-contacts from the network dataframe. """ self.network = self.network.where( self.network['i'] != self.network['j']).dropna() self.network.reset_index(inplace=True, drop=True)
python
def _drop_diagonal(self): """ Drops self-contacts from the network dataframe. """ self.network = self.network.where( self.network['i'] != self.network['j']).dropna() self.network.reset_index(inplace=True, drop=True)
[ "def", "_drop_diagonal", "(", "self", ")", ":", "self", ".", "network", "=", "self", ".", "network", ".", "where", "(", "self", ".", "network", "[", "'i'", "]", "!=", "self", ".", "network", "[", "'j'", "]", ")", ".", "dropna", "(", ")", "self", ...
Drops self-contacts from the network dataframe.
[ "Drops", "self", "-", "contacts", "from", "the", "network", "dataframe", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L270-L276
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.add_edge
def add_edge(self, edgelist): """ Adds an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be added. For weighted networks list should also contain a 'weight' key. Returns ------...
python
def add_edge(self, edgelist): """ Adds an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be added. For weighted networks list should also contain a 'weight' key. Returns ------...
[ "def", "add_edge", "(", "self", ",", "edgelist", ")", ":", "if", "not", "isinstance", "(", "edgelist", "[", "0", "]", ",", "list", ")", ":", "edgelist", "=", "[", "edgelist", "]", "teneto", ".", "utils", ".", "check_TemporalNetwork_input", "(", "edgelist...
Adds an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be added. For weighted networks list should also contain a 'weight' key. Returns -------- Updates TenetoBIDS.network datafram...
[ "Adds", "an", "edge", "from", "network", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L297-L332
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.drop_edge
def drop_edge(self, edgelist): """ Removes an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be removes. Returns -------- Updates TenetoBIDS.network dataframe ...
python
def drop_edge(self, edgelist): """ Removes an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be removes. Returns -------- Updates TenetoBIDS.network dataframe ...
[ "def", "drop_edge", "(", "self", ",", "edgelist", ")", ":", "if", "not", "isinstance", "(", "edgelist", "[", "0", "]", ",", "list", ")", ":", "edgelist", "=", "[", "edgelist", "]", "teneto", ".", "utils", ".", "check_TemporalNetwork_input", "(", "edgelis...
Removes an edge from network. Parameters ---------- edgelist : list a list (or list of lists) containing the i,j and t indicies to be removes. Returns -------- Updates TenetoBIDS.network dataframe
[ "Removes", "an", "edge", "from", "network", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L334-L363
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.calc_networkmeasure
def calc_networkmeasure(self, networkmeasure, **measureparams): """ Calculate network measure. Parameters ----------- networkmeasure : str Function to call. Functions available are in teneto.networkmeasures measureparams : kwargs kwargs for tenet...
python
def calc_networkmeasure(self, networkmeasure, **measureparams): """ Calculate network measure. Parameters ----------- networkmeasure : str Function to call. Functions available are in teneto.networkmeasures measureparams : kwargs kwargs for tenet...
[ "def", "calc_networkmeasure", "(", "self", ",", "networkmeasure", ",", "*", "*", "measureparams", ")", ":", "availablemeasures", "=", "[", "f", "for", "f", "in", "dir", "(", "teneto", ".", "networkmeasures", ")", "if", "not", "f", ".", "startswith", "(", ...
Calculate network measure. Parameters ----------- networkmeasure : str Function to call. Functions available are in teneto.networkmeasures measureparams : kwargs kwargs for teneto.networkmeasure.[networkmeasure]
[ "Calculate", "network", "measure", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L365-L385
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.generatenetwork
def generatenetwork(self, networktype, **networkparams): """ Generate a network Parameters ----------- networktype : str Function to call. Functions available are in teneto.generatenetwork measureparams : kwargs kwargs for teneto.generatenetwork....
python
def generatenetwork(self, networktype, **networkparams): """ Generate a network Parameters ----------- networktype : str Function to call. Functions available are in teneto.generatenetwork measureparams : kwargs kwargs for teneto.generatenetwork....
[ "def", "generatenetwork", "(", "self", ",", "networktype", ",", "*", "*", "networkparams", ")", ":", "availabletypes", "=", "[", "f", "for", "f", "in", "dir", "(", "teneto", ".", "generatenetwork", ")", "if", "not", "f", ".", "startswith", "(", "'__'", ...
Generate a network Parameters ----------- networktype : str Function to call. Functions available are in teneto.generatenetwork measureparams : kwargs kwargs for teneto.generatenetwork.[networktype] Returns -------- TenetoBIDS.network is...
[ "Generate", "a", "network" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L387-L413
wiheto/teneto
teneto/classes/network.py
TemporalNetwork.save_aspickle
def save_aspickle(self, fname): """ Saves object as pickle. fname : str file path. """ if fname[-4:] != '.pkl': fname += '.pkl' with open(fname, 'wb') as f: pickle.dump(self, f, pickle.HIGHEST_PROTOCOL)
python
def save_aspickle(self, fname): """ Saves object as pickle. fname : str file path. """ if fname[-4:] != '.pkl': fname += '.pkl' with open(fname, 'wb') as f: pickle.dump(self, f, pickle.HIGHEST_PROTOCOL)
[ "def", "save_aspickle", "(", "self", ",", "fname", ")", ":", "if", "fname", "[", "-", "4", ":", "]", "!=", "'.pkl'", ":", "fname", "+=", "'.pkl'", "with", "open", "(", "fname", ",", "'wb'", ")", "as", "f", ":", "pickle", ".", "dump", "(", "self",...
Saves object as pickle. fname : str file path.
[ "Saves", "object", "as", "pickle", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L441-L451
wiheto/teneto
teneto/timeseries/postprocess.py
postpro_fisher
def postpro_fisher(data, report=None): """ Performs fisher transform on everything in data. If report variable is passed, this is added to the report. """ if not report: report = {} # Due to rounding errors data[data < -0.99999999999999] = -1 data[data > 0.99999999999999] = 1 ...
python
def postpro_fisher(data, report=None): """ Performs fisher transform on everything in data. If report variable is passed, this is added to the report. """ if not report: report = {} # Due to rounding errors data[data < -0.99999999999999] = -1 data[data > 0.99999999999999] = 1 ...
[ "def", "postpro_fisher", "(", "data", ",", "report", "=", "None", ")", ":", "if", "not", "report", ":", "report", "=", "{", "}", "# Due to rounding errors", "data", "[", "data", "<", "-", "0.99999999999999", "]", "=", "-", "1", "data", "[", "data", ">"...
Performs fisher transform on everything in data. If report variable is passed, this is added to the report.
[ "Performs", "fisher", "transform", "on", "everything", "in", "data", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/postprocess.py#L10-L25
wiheto/teneto
teneto/timeseries/postprocess.py
postpro_boxcox
def postpro_boxcox(data, report=None): """ Performs box cox transform on everything in data. If report variable is passed, this is added to the report. """ if not report: report = {} # Note the min value of all time series will now be at least 1. mindata = 1 - np.nanmin(data) da...
python
def postpro_boxcox(data, report=None): """ Performs box cox transform on everything in data. If report variable is passed, this is added to the report. """ if not report: report = {} # Note the min value of all time series will now be at least 1. mindata = 1 - np.nanmin(data) da...
[ "def", "postpro_boxcox", "(", "data", ",", "report", "=", "None", ")", ":", "if", "not", "report", ":", "report", "=", "{", "}", "# Note the min value of all time series will now be at least 1.", "mindata", "=", "1", "-", "np", ".", "nanmin", "(", "data", ")",...
Performs box cox transform on everything in data. If report variable is passed, this is added to the report.
[ "Performs", "box", "cox", "transform", "on", "everything", "in", "data", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/postprocess.py#L28-L78
wiheto/teneto
teneto/timeseries/postprocess.py
postpro_standardize
def postpro_standardize(data, report=None): """ Standardizes everything in data (along axis -1). If report variable is passed, this is added to the report. """ if not report: report = {} # First make dim 1 = time. data = np.transpose(data, [2, 0, 1]) standardized_data = (data - ...
python
def postpro_standardize(data, report=None): """ Standardizes everything in data (along axis -1). If report variable is passed, this is added to the report. """ if not report: report = {} # First make dim 1 = time. data = np.transpose(data, [2, 0, 1]) standardized_data = (data - ...
[ "def", "postpro_standardize", "(", "data", ",", "report", "=", "None", ")", ":", "if", "not", "report", ":", "report", "=", "{", "}", "# First make dim 1 = time.", "data", "=", "np", ".", "transpose", "(", "data", ",", "[", "2", ",", "0", ",", "1", "...
Standardizes everything in data (along axis -1). If report variable is passed, this is added to the report.
[ "Standardizes", "everything", "in", "data", "(", "along", "axis", "-", "1", ")", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/postprocess.py#L81-L98
wiheto/teneto
teneto/timeseries/derive.py
derive_temporalnetwork
def derive_temporalnetwork(data, params): """ Derives connectivity from the data. A lot of data is inherently built with edges (e.g. communication between two individuals). However other networks are derived from the covariance of time series (e.g. brain networks between two regions). Covaria...
python
def derive_temporalnetwork(data, params): """ Derives connectivity from the data. A lot of data is inherently built with edges (e.g. communication between two individuals). However other networks are derived from the covariance of time series (e.g. brain networks between two regions). Covaria...
[ "def", "derive_temporalnetwork", "(", "data", ",", "params", ")", ":", "report", "=", "{", "}", "if", "'dimord'", "not", "in", "params", ".", "keys", "(", ")", ":", "params", "[", "'dimord'", "]", "=", "'node,time'", "if", "'report'", "not", "in", "par...
Derives connectivity from the data. A lot of data is inherently built with edges (e.g. communication between two individuals). However other networks are derived from the covariance of time series (e.g. brain networks between two regions). Covariance based metrics deriving time-resolved networks can ...
[ "Derives", "connectivity", "from", "the", "data", ".", "A", "lot", "of", "data", "is", "inherently", "built", "with", "edges", "(", "e", ".", "g", ".", "communication", "between", "two", "individuals", ")", ".", "However", "other", "networks", "are", "deri...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L16-L237
wiheto/teneto
teneto/timeseries/derive.py
_weightfun_jackknife
def _weightfun_jackknife(T, report): """ Creates the weights for the jackknife method. See func: teneto.derive.derive. """ weights = np.ones([T, T]) np.fill_diagonal(weights, 0) report['method'] = 'jackknife' report['jackknife'] = '' return weights, report
python
def _weightfun_jackknife(T, report): """ Creates the weights for the jackknife method. See func: teneto.derive.derive. """ weights = np.ones([T, T]) np.fill_diagonal(weights, 0) report['method'] = 'jackknife' report['jackknife'] = '' return weights, report
[ "def", "_weightfun_jackknife", "(", "T", ",", "report", ")", ":", "weights", "=", "np", ".", "ones", "(", "[", "T", ",", "T", "]", ")", "np", ".", "fill_diagonal", "(", "weights", ",", "0", ")", "report", "[", "'method'", "]", "=", "'jackknife'", "...
Creates the weights for the jackknife method. See func: teneto.derive.derive.
[ "Creates", "the", "weights", "for", "the", "jackknife", "method", ".", "See", "func", ":", "teneto", ".", "derive", ".", "derive", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L240-L249
wiheto/teneto
teneto/timeseries/derive.py
_weightfun_sliding_window
def _weightfun_sliding_window(T, params, report): """ Creates the weights for the sliding window method. See func: teneto.derive.derive. """ weightat0 = np.zeros(T) weightat0[0:params['windowsize']] = np.ones(params['windowsize']) weights = np.array([np.roll(weightat0, i) ...
python
def _weightfun_sliding_window(T, params, report): """ Creates the weights for the sliding window method. See func: teneto.derive.derive. """ weightat0 = np.zeros(T) weightat0[0:params['windowsize']] = np.ones(params['windowsize']) weights = np.array([np.roll(weightat0, i) ...
[ "def", "_weightfun_sliding_window", "(", "T", ",", "params", ",", "report", ")", ":", "weightat0", "=", "np", ".", "zeros", "(", "T", ")", "weightat0", "[", "0", ":", "params", "[", "'windowsize'", "]", "]", "=", "np", ".", "ones", "(", "params", "["...
Creates the weights for the sliding window method. See func: teneto.derive.derive.
[ "Creates", "the", "weights", "for", "the", "sliding", "window", "method", ".", "See", "func", ":", "teneto", ".", "derive", ".", "derive", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L252-L263
wiheto/teneto
teneto/timeseries/derive.py
_weightfun_tapered_sliding_window
def _weightfun_tapered_sliding_window(T, params, report): """ Creates the weights for the tapered method. See func: teneto.derive.derive. """ x = np.arange(-(params['windowsize'] - 1) / 2, (params['windowsize']) / 2) distribution_parameters = ','.join(map(str, params['distribution_params'])) tap...
python
def _weightfun_tapered_sliding_window(T, params, report): """ Creates the weights for the tapered method. See func: teneto.derive.derive. """ x = np.arange(-(params['windowsize'] - 1) / 2, (params['windowsize']) / 2) distribution_parameters = ','.join(map(str, params['distribution_params'])) tap...
[ "def", "_weightfun_tapered_sliding_window", "(", "T", ",", "params", ",", "report", ")", ":", "x", "=", "np", ".", "arange", "(", "-", "(", "params", "[", "'windowsize'", "]", "-", "1", ")", "/", "2", ",", "(", "params", "[", "'windowsize'", "]", ")"...
Creates the weights for the tapered method. See func: teneto.derive.derive.
[ "Creates", "the", "weights", "for", "the", "tapered", "method", ".", "See", "func", ":", "teneto", ".", "derive", ".", "derive", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L266-L283
wiheto/teneto
teneto/timeseries/derive.py
_weightfun_spatial_distance
def _weightfun_spatial_distance(data, params, report): """ Creates the weights for the spatial distance method. See func: teneto.derive.derive. """ distance = getDistanceFunction(params['distance']) weights = np.array([distance(data[n, :], data[t, :]) for n in np.arange( 0, data.shape[0]) fo...
python
def _weightfun_spatial_distance(data, params, report): """ Creates the weights for the spatial distance method. See func: teneto.derive.derive. """ distance = getDistanceFunction(params['distance']) weights = np.array([distance(data[n, :], data[t, :]) for n in np.arange( 0, data.shape[0]) fo...
[ "def", "_weightfun_spatial_distance", "(", "data", ",", "params", ",", "report", ")", ":", "distance", "=", "getDistanceFunction", "(", "params", "[", "'distance'", "]", ")", "weights", "=", "np", ".", "array", "(", "[", "distance", "(", "data", "[", "n", ...
Creates the weights for the spatial distance method. See func: teneto.derive.derive.
[ "Creates", "the", "weights", "for", "the", "spatial", "distance", "method", ".", "See", "func", ":", "teneto", ".", "derive", ".", "derive", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L286-L299
wiheto/teneto
teneto/timeseries/derive.py
_temporal_derivative
def _temporal_derivative(data, params, report): """ Performs mtd method. See func: teneto.derive.derive. """ # Data should be timexnode report = {} # Derivative tdat = data[1:, :] - data[:-1, :] # Normalize tdat = tdat / np.std(tdat, axis=0) # Coupling coupling = np.array([t...
python
def _temporal_derivative(data, params, report): """ Performs mtd method. See func: teneto.derive.derive. """ # Data should be timexnode report = {} # Derivative tdat = data[1:, :] - data[:-1, :] # Normalize tdat = tdat / np.std(tdat, axis=0) # Coupling coupling = np.array([t...
[ "def", "_temporal_derivative", "(", "data", ",", "params", ",", "report", ")", ":", "# Data should be timexnode", "report", "=", "{", "}", "# Derivative", "tdat", "=", "data", "[", "1", ":", ",", ":", "]", "-", "data", "[", ":", "-", "1", ",", ":", "...
Performs mtd method. See func: teneto.derive.derive.
[ "Performs", "mtd", "method", ".", "See", "func", ":", "teneto", ".", "derive", ".", "derive", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/derive.py#L302-L330
wiheto/teneto
teneto/utils/utils.py
binarize_percent
def binarize_percent(netin, level, sign='pos', axis='time'): """ Binarizes a network proprtionally. When axis='time' (only one available at the moment) then the top values for each edge time series are considered. Parameters ---------- netin : array or dict network (graphlet or contact rep...
python
def binarize_percent(netin, level, sign='pos', axis='time'): """ Binarizes a network proprtionally. When axis='time' (only one available at the moment) then the top values for each edge time series are considered. Parameters ---------- netin : array or dict network (graphlet or contact rep...
[ "def", "binarize_percent", "(", "netin", ",", "level", ",", "sign", "=", "'pos'", ",", "axis", "=", "'time'", ")", ":", "netin", ",", "netinfo", "=", "process_input", "(", "netin", ",", "[", "'C'", ",", "'G'", ",", "'TO'", "]", ")", "# Set diagonal to ...
Binarizes a network proprtionally. When axis='time' (only one available at the moment) then the top values for each edge time series are considered. Parameters ---------- netin : array or dict network (graphlet or contact representation), level : float Percent to keep (expressed as dec...
[ "Binarizes", "a", "network", "proprtionally", ".", "When", "axis", "=", "time", "(", "only", "one", "available", "at", "the", "moment", ")", "then", "the", "top", "values", "for", "each", "edge", "time", "series", "are", "considered", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L214-L279
wiheto/teneto
teneto/utils/utils.py
binarize_rdp
def binarize_rdp(netin, level, sign='pos', axis='time'): """ Binarizes a network based on RDP compression. Parameters ---------- netin : array or dict Network (graphlet or contact representation), level : float Delta parameter which is the tolorated error in RDP compression. ...
python
def binarize_rdp(netin, level, sign='pos', axis='time'): """ Binarizes a network based on RDP compression. Parameters ---------- netin : array or dict Network (graphlet or contact representation), level : float Delta parameter which is the tolorated error in RDP compression. ...
[ "def", "binarize_rdp", "(", "netin", ",", "level", ",", "sign", "=", "'pos'", ",", "axis", "=", "'time'", ")", ":", "netin", ",", "netinfo", "=", "process_input", "(", "netin", ",", "[", "'C'", ",", "'G'", ",", "'TO'", "]", ")", "trajectory", "=", ...
Binarizes a network based on RDP compression. Parameters ---------- netin : array or dict Network (graphlet or contact representation), level : float Delta parameter which is the tolorated error in RDP compression. sign : str, default='pos' States the sign of the thresholdi...
[ "Binarizes", "a", "network", "based", "on", "RDP", "compression", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L283-L335
wiheto/teneto
teneto/utils/utils.py
binarize
def binarize(netin, threshold_type, threshold_level, sign='pos', axis='time'): """ Binarizes a network, returning the network. General wrapper function for different binarization functions. Parameters ---------- netin : array or dict Network (graphlet or contact representation), thresh...
python
def binarize(netin, threshold_type, threshold_level, sign='pos', axis='time'): """ Binarizes a network, returning the network. General wrapper function for different binarization functions. Parameters ---------- netin : array or dict Network (graphlet or contact representation), thresh...
[ "def", "binarize", "(", "netin", ",", "threshold_type", ",", "threshold_level", ",", "sign", "=", "'pos'", ",", "axis", "=", "'time'", ")", ":", "if", "threshold_type", "==", "'percent'", ":", "netout", "=", "binarize_percent", "(", "netin", ",", "threshold_...
Binarizes a network, returning the network. General wrapper function for different binarization functions. Parameters ---------- netin : array or dict Network (graphlet or contact representation), threshold_type : str What type of thresholds to make binarization. Options: 'rdp', 'perce...
[ "Binarizes", "a", "network", "returning", "the", "network", ".", "General", "wrapper", "function", "for", "different", "binarization", "functions", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L382-L422
wiheto/teneto
teneto/utils/utils.py
process_input
def process_input(netIn, allowedformats, outputformat='G'): """ Takes input network and checks what the input is. Parameters ---------- netIn : array, dict, or TemporalNetwork Network (graphlet, contact or object) allowedformats : str Which format of network objects that are al...
python
def process_input(netIn, allowedformats, outputformat='G'): """ Takes input network and checks what the input is. Parameters ---------- netIn : array, dict, or TemporalNetwork Network (graphlet, contact or object) allowedformats : str Which format of network objects that are al...
[ "def", "process_input", "(", "netIn", ",", "allowedformats", ",", "outputformat", "=", "'G'", ")", ":", "inputtype", "=", "checkInput", "(", "netIn", ")", "# Convert TN to G representation", "if", "inputtype", "==", "'TN'", "and", "'TN'", "in", "allowedformats", ...
Takes input network and checks what the input is. Parameters ---------- netIn : array, dict, or TemporalNetwork Network (graphlet, contact or object) allowedformats : str Which format of network objects that are allowed. Options: 'C', 'TN', 'G'. outputformat: str, default=G ...
[ "Takes", "input", "network", "and", "checks", "what", "the", "input", "is", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L575-L646
wiheto/teneto
teneto/utils/utils.py
clean_community_indexes
def clean_community_indexes(communityID): """ Takes input of community assignments. Returns reindexed community assignment by using smallest numbers possible. Parameters ---------- communityID : array-like list or array of integers. Output from community detection algorithems. Returns...
python
def clean_community_indexes(communityID): """ Takes input of community assignments. Returns reindexed community assignment by using smallest numbers possible. Parameters ---------- communityID : array-like list or array of integers. Output from community detection algorithems. Returns...
[ "def", "clean_community_indexes", "(", "communityID", ")", ":", "communityID", "=", "np", ".", "array", "(", "communityID", ")", "cid_shape", "=", "communityID", ".", "shape", "if", "len", "(", "cid_shape", ")", ">", "1", ":", "communityID", "=", "communityI...
Takes input of community assignments. Returns reindexed community assignment by using smallest numbers possible. Parameters ---------- communityID : array-like list or array of integers. Output from community detection algorithems. Returns ------- new_communityID : array clea...
[ "Takes", "input", "of", "community", "assignments", ".", "Returns", "reindexed", "community", "assignment", "by", "using", "smallest", "numbers", "possible", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L649-L680
wiheto/teneto
teneto/utils/utils.py
multiple_contacts_get_values
def multiple_contacts_get_values(C): """ Given an contact representation with repeated contacts, this function removes duplicates and creates a value Parameters ---------- C : dict contact representation with multiple repeated contacts. Returns ------- :C_out: dict ...
python
def multiple_contacts_get_values(C): """ Given an contact representation with repeated contacts, this function removes duplicates and creates a value Parameters ---------- C : dict contact representation with multiple repeated contacts. Returns ------- :C_out: dict ...
[ "def", "multiple_contacts_get_values", "(", "C", ")", ":", "d", "=", "collections", ".", "OrderedDict", "(", ")", "for", "c", "in", "C", "[", "'contacts'", "]", ":", "ct", "=", "tuple", "(", "c", ")", "if", "ct", "in", "d", ":", "d", "[", "ct", "...
Given an contact representation with repeated contacts, this function removes duplicates and creates a value Parameters ---------- C : dict contact representation with multiple repeated contacts. Returns ------- :C_out: dict Contact representation with duplicate contacts re...
[ "Given", "an", "contact", "representation", "with", "repeated", "contacts", "this", "function", "removes", "duplicates", "and", "creates", "a", "value" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L683-L718
wiheto/teneto
teneto/utils/utils.py
df_to_array
def df_to_array(df, netshape, nettype): """ Returns a numpy array (snapshot representation) from thedataframe contact list Parameters: df : pandas df pandas df with columns, i,j,t. netshape : tuple network shape, format: (node, time) nettype : str ...
python
def df_to_array(df, netshape, nettype): """ Returns a numpy array (snapshot representation) from thedataframe contact list Parameters: df : pandas df pandas df with columns, i,j,t. netshape : tuple network shape, format: (node, time) nettype : str ...
[ "def", "df_to_array", "(", "df", ",", "netshape", ",", "nettype", ")", ":", "if", "len", "(", "df", ")", ">", "0", ":", "idx", "=", "np", ".", "array", "(", "list", "(", "map", "(", "list", ",", "df", ".", "values", ")", ")", ")", "G", "=", ...
Returns a numpy array (snapshot representation) from thedataframe contact list Parameters: df : pandas df pandas df with columns, i,j,t. netshape : tuple network shape, format: (node, time) nettype : str 'wu', 'wd', 'bu', 'bd' Returns: -------- ...
[ "Returns", "a", "numpy", "array", "(", "snapshot", "representation", ")", "from", "thedataframe", "contact", "list" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L721-L754
wiheto/teneto
teneto/utils/utils.py
check_distance_funciton_input
def check_distance_funciton_input(distance_func_name, netinfo): """ Funciton checks distance_func_name, if it is specified as 'default'. Then given the type of the network selects a default distance function. Parameters ---------- distance_func_name : str distance function name. netin...
python
def check_distance_funciton_input(distance_func_name, netinfo): """ Funciton checks distance_func_name, if it is specified as 'default'. Then given the type of the network selects a default distance function. Parameters ---------- distance_func_name : str distance function name. netin...
[ "def", "check_distance_funciton_input", "(", "distance_func_name", ",", "netinfo", ")", ":", "if", "distance_func_name", "==", "'default'", "and", "netinfo", "[", "'nettype'", "]", "[", "0", "]", "==", "'b'", ":", "print", "(", "'Default distance funciton specified....
Funciton checks distance_func_name, if it is specified as 'default'. Then given the type of the network selects a default distance function. Parameters ---------- distance_func_name : str distance function name. netinfo : dict the output of utils.process_input Returns -------...
[ "Funciton", "checks", "distance_func_name", "if", "it", "is", "specified", "as", "default", ".", "Then", "given", "the", "type", "of", "the", "network", "selects", "a", "default", "distance", "function", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L757-L786
wiheto/teneto
teneto/utils/utils.py
load_parcellation_coords
def load_parcellation_coords(parcellation_name): """ Loads coordinates of included parcellations. Parameters ---------- parcellation_name : str options: 'gordon2014_333', 'power2012_264', 'shen2013_278'. Returns ------- parc : array parcellation cordinates """ ...
python
def load_parcellation_coords(parcellation_name): """ Loads coordinates of included parcellations. Parameters ---------- parcellation_name : str options: 'gordon2014_333', 'power2012_264', 'shen2013_278'. Returns ------- parc : array parcellation cordinates """ ...
[ "def", "load_parcellation_coords", "(", "parcellation_name", ")", ":", "path", "=", "tenetopath", "[", "0", "]", "+", "'/data/parcellation/'", "+", "parcellation_name", "+", "'.csv'", "parc", "=", "np", ".", "loadtxt", "(", "path", ",", "skiprows", "=", "1", ...
Loads coordinates of included parcellations. Parameters ---------- parcellation_name : str options: 'gordon2014_333', 'power2012_264', 'shen2013_278'. Returns ------- parc : array parcellation cordinates
[ "Loads", "coordinates", "of", "included", "parcellations", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L789-L809
wiheto/teneto
teneto/utils/utils.py
make_parcellation
def make_parcellation(data_path, parcellation, parc_type=None, parc_params=None): """ Performs a parcellation which reduces voxel space to regions of interest (brain data). Parameters ---------- data_path : str Path to .nii image. parcellation : str Specify which parcellation t...
python
def make_parcellation(data_path, parcellation, parc_type=None, parc_params=None): """ Performs a parcellation which reduces voxel space to regions of interest (brain data). Parameters ---------- data_path : str Path to .nii image. parcellation : str Specify which parcellation t...
[ "def", "make_parcellation", "(", "data_path", ",", "parcellation", ",", "parc_type", "=", "None", ",", "parc_params", "=", "None", ")", ":", "if", "isinstance", "(", "parcellation", ",", "str", ")", ":", "parcin", "=", "''", "if", "'+'", "in", "parcellatio...
Performs a parcellation which reduces voxel space to regions of interest (brain data). Parameters ---------- data_path : str Path to .nii image. parcellation : str Specify which parcellation that you would like to use. For MNI: 'gordon2014_333', 'power2012_264', For TAL: 'shen2013_278'...
[ "Performs", "a", "parcellation", "which", "reduces", "voxel", "space", "to", "regions", "of", "interest", "(", "brain", "data", ")", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L812-L890
wiheto/teneto
teneto/utils/utils.py
create_traj_ranges
def create_traj_ranges(start, stop, N): """ Fills in the trajectory range. # Adapted from https://stackoverflow.com/a/40624614 """ steps = (1.0/(N-1)) * (stop - start) if np.isscalar(steps): return steps*np.arange(N) + start else: return steps[:, None]*np.arange(N) + start[:...
python
def create_traj_ranges(start, stop, N): """ Fills in the trajectory range. # Adapted from https://stackoverflow.com/a/40624614 """ steps = (1.0/(N-1)) * (stop - start) if np.isscalar(steps): return steps*np.arange(N) + start else: return steps[:, None]*np.arange(N) + start[:...
[ "def", "create_traj_ranges", "(", "start", ",", "stop", ",", "N", ")", ":", "steps", "=", "(", "1.0", "/", "(", "N", "-", "1", ")", ")", "*", "(", "stop", "-", "start", ")", "if", "np", ".", "isscalar", "(", "steps", ")", ":", "return", "steps"...
Fills in the trajectory range. # Adapted from https://stackoverflow.com/a/40624614
[ "Fills", "in", "the", "trajectory", "range", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L893-L903
wiheto/teneto
teneto/utils/utils.py
get_dimord
def get_dimord(measure, calc=None, community=None): """ Get the dimension order of a network measure. Parameters ---------- measure : str Name of funciton in teneto.networkmeasures. calc : str, default=None Calc parameter for the function community : bool, default=None ...
python
def get_dimord(measure, calc=None, community=None): """ Get the dimension order of a network measure. Parameters ---------- measure : str Name of funciton in teneto.networkmeasures. calc : str, default=None Calc parameter for the function community : bool, default=None ...
[ "def", "get_dimord", "(", "measure", ",", "calc", "=", "None", ",", "community", "=", "None", ")", ":", "if", "not", "calc", ":", "calc", "=", "''", "else", ":", "calc", "=", "'_'", "+", "calc", "if", "not", "community", ":", "community", "=", "''"...
Get the dimension order of a network measure. Parameters ---------- measure : str Name of funciton in teneto.networkmeasures. calc : str, default=None Calc parameter for the function community : bool, default=None If not null, then community property is assumed to be believ...
[ "Get", "the", "dimension", "order", "of", "a", "network", "measure", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L906-L969
wiheto/teneto
teneto/utils/utils.py
get_network_when
def get_network_when(tnet, i=None, j=None, t=None, ij=None, logic='and', copy=False, asarray=False): """ Returns subset of dataframe that matches index Parameters ---------- tnet : df or TemporalNetwork TemporalNetwork object or pandas dataframe edgelist i : list or int get node...
python
def get_network_when(tnet, i=None, j=None, t=None, ij=None, logic='and', copy=False, asarray=False): """ Returns subset of dataframe that matches index Parameters ---------- tnet : df or TemporalNetwork TemporalNetwork object or pandas dataframe edgelist i : list or int get node...
[ "def", "get_network_when", "(", "tnet", ",", "i", "=", "None", ",", "j", "=", "None", ",", "t", "=", "None", ",", "ij", "=", "None", ",", "logic", "=", "'and'", ",", "copy", "=", "False", ",", "asarray", "=", "False", ")", ":", "if", "isinstance"...
Returns subset of dataframe that matches index Parameters ---------- tnet : df or TemporalNetwork TemporalNetwork object or pandas dataframe edgelist i : list or int get nodes in column i (source nodes in directed networks) j : list or int get nodes in column j (target nodes...
[ "Returns", "subset", "of", "dataframe", "that", "matches", "index" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L972-L1089
wiheto/teneto
teneto/utils/utils.py
create_supraadjacency_matrix
def create_supraadjacency_matrix(tnet, intersliceweight=1): """ Returns a supraadjacency matrix from a temporal network structure Parameters -------- tnet : TemporalNetwork Temporal network (any network type) intersliceweight : int Weight that links the same node from adjacent t...
python
def create_supraadjacency_matrix(tnet, intersliceweight=1): """ Returns a supraadjacency matrix from a temporal network structure Parameters -------- tnet : TemporalNetwork Temporal network (any network type) intersliceweight : int Weight that links the same node from adjacent t...
[ "def", "create_supraadjacency_matrix", "(", "tnet", ",", "intersliceweight", "=", "1", ")", ":", "newnetwork", "=", "tnet", ".", "network", ".", "copy", "(", ")", "newnetwork", "[", "'i'", "]", "=", "(", "tnet", ".", "network", "[", "'i'", "]", ")", "+...
Returns a supraadjacency matrix from a temporal network structure Parameters -------- tnet : TemporalNetwork Temporal network (any network type) intersliceweight : int Weight that links the same node from adjacent time-points Returns -------- supranet : dataframe Su...
[ "Returns", "a", "supraadjacency", "matrix", "from", "a", "temporal", "network", "structure" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/utils.py#L1092-L1121
wiheto/teneto
teneto/utils/io.py
tnet_to_nx
def tnet_to_nx(df, t=None): """ Creates undirected networkx object """ if t is not None: df = get_network_when(df, t=t) if 'weight' in df.columns: nxobj = nx.from_pandas_edgelist( df, source='i', target='j', edge_attr='weight') else: nxobj = nx.from_pandas_edg...
python
def tnet_to_nx(df, t=None): """ Creates undirected networkx object """ if t is not None: df = get_network_when(df, t=t) if 'weight' in df.columns: nxobj = nx.from_pandas_edgelist( df, source='i', target='j', edge_attr='weight') else: nxobj = nx.from_pandas_edg...
[ "def", "tnet_to_nx", "(", "df", ",", "t", "=", "None", ")", ":", "if", "t", "is", "not", "None", ":", "df", "=", "get_network_when", "(", "df", ",", "t", "=", "t", ")", "if", "'weight'", "in", "df", ".", "columns", ":", "nxobj", "=", "nx", ".",...
Creates undirected networkx object
[ "Creates", "undirected", "networkx", "object" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/io.py#L5-L16
wiheto/teneto
teneto/communitydetection/louvain.py
temporal_louvain
def temporal_louvain(tnet, resolution=1, intersliceweight=1, n_iter=100, negativeedge='ignore', randomseed=None, consensus_threshold=0.5, temporal_consensus=True, njobs=1): r""" Louvain clustering for a temporal network. Parameters ----------- tnet : array, dict, TemporalNetwork Input netwo...
python
def temporal_louvain(tnet, resolution=1, intersliceweight=1, n_iter=100, negativeedge='ignore', randomseed=None, consensus_threshold=0.5, temporal_consensus=True, njobs=1): r""" Louvain clustering for a temporal network. Parameters ----------- tnet : array, dict, TemporalNetwork Input netwo...
[ "def", "temporal_louvain", "(", "tnet", ",", "resolution", "=", "1", ",", "intersliceweight", "=", "1", ",", "n_iter", "=", "100", ",", "negativeedge", "=", "'ignore'", ",", "randomseed", "=", "None", ",", "consensus_threshold", "=", "0.5", ",", "temporal_co...
r""" Louvain clustering for a temporal network. Parameters ----------- tnet : array, dict, TemporalNetwork Input network resolution : int resolution of Louvain clustering ($\gamma$) intersliceweight : int interslice weight of multilayer clustering ($\omega$). Must be pos...
[ "r", "Louvain", "clustering", "for", "a", "temporal", "network", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/communitydetection/louvain.py#L11-L75
wiheto/teneto
teneto/communitydetection/louvain.py
make_consensus_matrix
def make_consensus_matrix(com_membership, th=0.5): r""" Makes the consensus matrix . Parameters ---------- com_membership : array Shape should be node, time, iteration. th : float threshold to cancel noisey edges Returns ------- D : array consensus matrix ...
python
def make_consensus_matrix(com_membership, th=0.5): r""" Makes the consensus matrix . Parameters ---------- com_membership : array Shape should be node, time, iteration. th : float threshold to cancel noisey edges Returns ------- D : array consensus matrix ...
[ "def", "make_consensus_matrix", "(", "com_membership", ",", "th", "=", "0.5", ")", ":", "com_membership", "=", "np", ".", "array", "(", "com_membership", ")", "D", "=", "[", "]", "for", "i", "in", "range", "(", "com_membership", ".", "shape", "[", "0", ...
r""" Makes the consensus matrix . Parameters ---------- com_membership : array Shape should be node, time, iteration. th : float threshold to cancel noisey edges Returns ------- D : array consensus matrix
[ "r", "Makes", "the", "consensus", "matrix", ".", "Parameters", "----------" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/communitydetection/louvain.py#L84-L120
wiheto/teneto
teneto/communitydetection/louvain.py
make_temporal_consensus
def make_temporal_consensus(com_membership): r""" Matches community labels accross time-points Jaccard matching is in a greedy fashiong. Matching the largest community at t with the community at t-1. Parameters ---------- com_membership : array Shape should be node, time. Returns...
python
def make_temporal_consensus(com_membership): r""" Matches community labels accross time-points Jaccard matching is in a greedy fashiong. Matching the largest community at t with the community at t-1. Parameters ---------- com_membership : array Shape should be node, time. Returns...
[ "def", "make_temporal_consensus", "(", "com_membership", ")", ":", "com_membership", "=", "np", ".", "array", "(", "com_membership", ")", "# make first indicies be between 0 and 1.", "com_membership", "[", ":", ",", "0", "]", "=", "clean_community_indexes", "(", "com_...
r""" Matches community labels accross time-points Jaccard matching is in a greedy fashiong. Matching the largest community at t with the community at t-1. Parameters ---------- com_membership : array Shape should be node, time. Returns ------- D : array temporal cons...
[ "r", "Matches", "community", "labels", "accross", "time", "-", "points" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/communitydetection/louvain.py#L123-L167
wiheto/teneto
teneto/temporalcommunity/flexibility.py
flexibility
def flexibility(communities): """ Amount a node changes community Parameters ---------- communities : array Community array of shape (node,time) Returns -------- flex : array Size with the flexibility of each node. Notes ----- Flexbility calculates the numb...
python
def flexibility(communities): """ Amount a node changes community Parameters ---------- communities : array Community array of shape (node,time) Returns -------- flex : array Size with the flexibility of each node. Notes ----- Flexbility calculates the numb...
[ "def", "flexibility", "(", "communities", ")", ":", "# Preallocate", "flex", "=", "np", ".", "zeros", "(", "communities", ".", "shape", "[", "0", "]", ")", "# Go from the second time point to last, compare with time-point before", "for", "t", "in", "range", "(", "...
Amount a node changes community Parameters ---------- communities : array Community array of shape (node,time) Returns -------- flex : array Size with the flexibility of each node. Notes ----- Flexbility calculates the number of times a node switches its community ...
[ "Amount", "a", "node", "changes", "community" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/temporalcommunity/flexibility.py#L4-L34
wiheto/teneto
teneto/plot/slice_plot.py
slice_plot
def slice_plot(netin, ax, nodelabels=None, timelabels=None, communities=None, plotedgeweights=False, edgeweightscalar=1, timeunit='', linestyle='k-', cmap=None, nodesize=100, nodekwargs=None, edgekwargs=None): r''' Fuction draws "slice graph" and exports axis handles Parameters ---------- netin ...
python
def slice_plot(netin, ax, nodelabels=None, timelabels=None, communities=None, plotedgeweights=False, edgeweightscalar=1, timeunit='', linestyle='k-', cmap=None, nodesize=100, nodekwargs=None, edgekwargs=None): r''' Fuction draws "slice graph" and exports axis handles Parameters ---------- netin ...
[ "def", "slice_plot", "(", "netin", ",", "ax", ",", "nodelabels", "=", "None", ",", "timelabels", "=", "None", ",", "communities", "=", "None", ",", "plotedgeweights", "=", "False", ",", "edgeweightscalar", "=", "1", ",", "timeunit", "=", "''", ",", "line...
r''' Fuction draws "slice graph" and exports axis handles Parameters ---------- netin : array, dict temporal network input (graphlet or contact) ax : matplotlib figure handles. nodelabels : list nodes labels. List of strings. timelabels : list labels of dimension ...
[ "r" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/plot/slice_plot.py#L6-L181
wiheto/teneto
teneto/networkmeasures/local_variation.py
local_variation
def local_variation(data): r""" Calculates the local variaiont of inter-contact times. [LV-1]_, [LV-2]_ Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with nettype: 'bu', 'bd'. (2) dictionary of ICTs (output of *intercontacttimes*)....
python
def local_variation(data): r""" Calculates the local variaiont of inter-contact times. [LV-1]_, [LV-2]_ Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with nettype: 'bu', 'bd'. (2) dictionary of ICTs (output of *intercontacttimes*)....
[ "def", "local_variation", "(", "data", ")", ":", "ict", "=", "0", "# are ict present", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "# This could be done better", "if", "[", "k", "for", "k", "in", "list", "(", "data", ".", "keys", "(", ")", ...
r""" Calculates the local variaiont of inter-contact times. [LV-1]_, [LV-2]_ Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with nettype: 'bu', 'bd'. (2) dictionary of ICTs (output of *intercontacttimes*). Returns ------- ...
[ "r", "Calculates", "the", "local", "variaiont", "of", "inter", "-", "contact", "times", ".", "[", "LV", "-", "1", "]", "_", "[", "LV", "-", "2", "]", "_" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/local_variation.py#L9-L131
wiheto/teneto
teneto/utils/bidsutils.py
drop_bids_suffix
def drop_bids_suffix(fname): """ Given a filename sub-01_run-01_preproc.nii.gz, it will return ['sub-01_run-01', '.nii.gz'] Parameters ---------- fname : str BIDS filename with suffice. Directories should not be included. Returns ------- fname_head : str BIDS filename ...
python
def drop_bids_suffix(fname): """ Given a filename sub-01_run-01_preproc.nii.gz, it will return ['sub-01_run-01', '.nii.gz'] Parameters ---------- fname : str BIDS filename with suffice. Directories should not be included. Returns ------- fname_head : str BIDS filename ...
[ "def", "drop_bids_suffix", "(", "fname", ")", ":", "if", "'/'", "in", "fname", ":", "split", "=", "fname", ".", "split", "(", "'/'", ")", "dirnames", "=", "'/'", ".", "join", "(", "split", "[", ":", "-", "1", "]", ")", "+", "'/'", "fname", "=", ...
Given a filename sub-01_run-01_preproc.nii.gz, it will return ['sub-01_run-01', '.nii.gz'] Parameters ---------- fname : str BIDS filename with suffice. Directories should not be included. Returns ------- fname_head : str BIDS filename with fileformat : str The fil...
[ "Given", "a", "filename", "sub", "-", "01_run", "-", "01_preproc", ".", "nii", ".", "gz", "it", "will", "return", "[", "sub", "-", "01_run", "-", "01", ".", "nii", ".", "gz", "]" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/bidsutils.py#L24-L54
wiheto/teneto
teneto/utils/bidsutils.py
load_tabular_file
def load_tabular_file(fname, return_meta=False, header=True, index_col=True): """ Given a file name loads as a pandas data frame Parameters ---------- fname : str file name and path. Must be tsv. return_meta : header : bool (default True) if there is a header in the tsv fil...
python
def load_tabular_file(fname, return_meta=False, header=True, index_col=True): """ Given a file name loads as a pandas data frame Parameters ---------- fname : str file name and path. Must be tsv. return_meta : header : bool (default True) if there is a header in the tsv fil...
[ "def", "load_tabular_file", "(", "fname", ",", "return_meta", "=", "False", ",", "header", "=", "True", ",", "index_col", "=", "True", ")", ":", "if", "index_col", ":", "index_col", "=", "0", "else", ":", "index_col", "=", "None", "if", "header", ":", ...
Given a file name loads as a pandas data frame Parameters ---------- fname : str file name and path. Must be tsv. return_meta : header : bool (default True) if there is a header in the tsv file, true will use first row in file. index_col : bool (default None) if there i...
[ "Given", "a", "file", "name", "loads", "as", "a", "pandas", "data", "frame" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/bidsutils.py#L77-L115
wiheto/teneto
teneto/utils/bidsutils.py
get_sidecar
def get_sidecar(fname, allowedfileformats='default'): """ Loads sidecar or creates one """ if allowedfileformats == 'default': allowedfileformats = ['.tsv', '.nii.gz'] for f in allowedfileformats: fname = fname.split(f)[0] fname += '.json' if os.path.exists(fname): wi...
python
def get_sidecar(fname, allowedfileformats='default'): """ Loads sidecar or creates one """ if allowedfileformats == 'default': allowedfileformats = ['.tsv', '.nii.gz'] for f in allowedfileformats: fname = fname.split(f)[0] fname += '.json' if os.path.exists(fname): wi...
[ "def", "get_sidecar", "(", "fname", ",", "allowedfileformats", "=", "'default'", ")", ":", "if", "allowedfileformats", "==", "'default'", ":", "allowedfileformats", "=", "[", "'.tsv'", ",", "'.nii.gz'", "]", "for", "f", "in", "allowedfileformats", ":", "fname", ...
Loads sidecar or creates one
[ "Loads", "sidecar", "or", "creates", "one" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/bidsutils.py#L118-L136
wiheto/teneto
teneto/utils/bidsutils.py
process_exclusion_criteria
def process_exclusion_criteria(exclusion_criteria): """ Parses an exclusion critera string to get the function and threshold. Parameters ---------- exclusion_criteria : list list of strings where each string is of the format [relation][threshold]. E.g. \'<0.5\' or \'>=1\' Retur...
python
def process_exclusion_criteria(exclusion_criteria): """ Parses an exclusion critera string to get the function and threshold. Parameters ---------- exclusion_criteria : list list of strings where each string is of the format [relation][threshold]. E.g. \'<0.5\' or \'>=1\' Retur...
[ "def", "process_exclusion_criteria", "(", "exclusion_criteria", ")", ":", "relfun", "=", "[", "]", "threshold", "=", "[", "]", "for", "ec", "in", "exclusion_criteria", ":", "if", "ec", "[", "0", ":", "2", "]", "==", "'>='", ":", "relfun", ".", "append", ...
Parses an exclusion critera string to get the function and threshold. Parameters ---------- exclusion_criteria : list list of strings where each string is of the format [relation][threshold]. E.g. \'<0.5\' or \'>=1\' Returns ------- relfun : list list of numpy f...
[ "Parses", "an", "exclusion", "critera", "string", "to", "get", "the", "function", "and", "threshold", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/utils/bidsutils.py#L166-L201
wiheto/teneto
teneto/networkmeasures/reachability_latency.py
reachability_latency
def reachability_latency(tnet=None, paths=None, rratio=1, calc='global'): """ Reachability latency. This is the r-th longest temporal path. Parameters --------- data : array or dict Can either be a network (graphlet or contact), binary unidrected only. Alternative can be a paths dictionar...
python
def reachability_latency(tnet=None, paths=None, rratio=1, calc='global'): """ Reachability latency. This is the r-th longest temporal path. Parameters --------- data : array or dict Can either be a network (graphlet or contact), binary unidrected only. Alternative can be a paths dictionar...
[ "def", "reachability_latency", "(", "tnet", "=", "None", ",", "paths", "=", "None", ",", "rratio", "=", "1", ",", "calc", "=", "'global'", ")", ":", "if", "tnet", "is", "not", "None", "and", "paths", "is", "not", "None", ":", "raise", "ValueError", "...
Reachability latency. This is the r-th longest temporal path. Parameters --------- data : array or dict Can either be a network (graphlet or contact), binary unidrected only. Alternative can be a paths dictionary (output of teneto.networkmeasure.shortest_temporal_path) rratio: float (default...
[ "Reachability", "latency", ".", "This", "is", "the", "r", "-", "th", "longest", "temporal", "path", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/reachability_latency.py#L9-L72
wiheto/teneto
teneto/networkmeasures/fluctuability.py
fluctuability
def fluctuability(netin, calc='global'): r""" Fluctuability of temporal networks. This is the variation of the network's edges over time. [fluct-1]_ This is the unique number of edges through time divided by the overall number of edges. Parameters ---------- netin : array or dict Temp...
python
def fluctuability(netin, calc='global'): r""" Fluctuability of temporal networks. This is the variation of the network's edges over time. [fluct-1]_ This is the unique number of edges through time divided by the overall number of edges. Parameters ---------- netin : array or dict Temp...
[ "def", "fluctuability", "(", "netin", ",", "calc", "=", "'global'", ")", ":", "# Get input type (C or G)", "netin", ",", "_", "=", "process_input", "(", "netin", ",", "[", "'C'", ",", "'G'", ",", "'TN'", "]", ")", "netin", "[", "netin", "!=", "0", "]",...
r""" Fluctuability of temporal networks. This is the variation of the network's edges over time. [fluct-1]_ This is the unique number of edges through time divided by the overall number of edges. Parameters ---------- netin : array or dict Temporal network input (graphlet or contact) (net...
[ "r", "Fluctuability", "of", "temporal", "networks", ".", "This", "is", "the", "variation", "of", "the", "network", "s", "edges", "over", "time", ".", "[", "fluct", "-", "1", "]", "_", "This", "is", "the", "unique", "number", "of", "edges", "through", "...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/fluctuability.py#L8-L121
wiheto/teneto
teneto/networkmeasures/topological_overlap.py
topological_overlap
def topological_overlap(tnet, calc='time'): r""" Topological overlap quantifies the persistency of edges through time. If two consequtive time-points have similar edges, this becomes high (max 1). If there is high change, this becomes 0. References: [topo-1]_, [topo-2]_ Parameters ---------- t...
python
def topological_overlap(tnet, calc='time'): r""" Topological overlap quantifies the persistency of edges through time. If two consequtive time-points have similar edges, this becomes high (max 1). If there is high change, this becomes 0. References: [topo-1]_, [topo-2]_ Parameters ---------- t...
[ "def", "topological_overlap", "(", "tnet", ",", "calc", "=", "'time'", ")", ":", "tnet", "=", "process_input", "(", "tnet", ",", "[", "'C'", ",", "'G'", ",", "'TN'", "]", ")", "[", "0", "]", "numerator", "=", "np", ".", "sum", "(", "tnet", "[", "...
r""" Topological overlap quantifies the persistency of edges through time. If two consequtive time-points have similar edges, this becomes high (max 1). If there is high change, this becomes 0. References: [topo-1]_, [topo-2]_ Parameters ---------- tnet : array, dict graphlet or contact se...
[ "r", "Topological", "overlap", "quantifies", "the", "persistency", "of", "edges", "through", "time", ".", "If", "two", "consequtive", "time", "-", "points", "have", "similar", "edges", "this", "becomes", "high", "(", "max", "1", ")", ".", "If", "there", "i...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/topological_overlap.py#L5-L137
wiheto/teneto
teneto/temporalcommunity/recruitment.py
recruitment
def recruitment(temporalcommunities, staticcommunities): """ Calculates recruitment coefficient for each node. Recruitment coefficient is the average probability of nodes from the same static communities being in the same temporal communities at other time-points or during different tasks. Parameters...
python
def recruitment(temporalcommunities, staticcommunities): """ Calculates recruitment coefficient for each node. Recruitment coefficient is the average probability of nodes from the same static communities being in the same temporal communities at other time-points or during different tasks. Parameters...
[ "def", "recruitment", "(", "temporalcommunities", ",", "staticcommunities", ")", ":", "# make sure the static and temporal communities have the same number of nodes", "if", "staticcommunities", ".", "shape", "[", "0", "]", "!=", "temporalcommunities", ".", "shape", "[", "0"...
Calculates recruitment coefficient for each node. Recruitment coefficient is the average probability of nodes from the same static communities being in the same temporal communities at other time-points or during different tasks. Parameters: ------------ temporalcommunities : array temporal ...
[ "Calculates", "recruitment", "coefficient", "for", "each", "node", ".", "Recruitment", "coefficient", "is", "the", "average", "probability", "of", "nodes", "from", "the", "same", "static", "communities", "being", "in", "the", "same", "temporal", "communities", "at...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/temporalcommunity/recruitment.py#L5-L44
wiheto/teneto
teneto/plot/circle_plot.py
circle_plot
def circle_plot(netIn, ax, nodelabels=None, linestyle='k-', nodesize=1000, cmap='Set2'): r''' Function draws "circle plot" and exports axis handles Parameters ------------- netIn : temporal network input (graphlet or contact) ax : matplotlib ax handles. nodelabels : list nodes labe...
python
def circle_plot(netIn, ax, nodelabels=None, linestyle='k-', nodesize=1000, cmap='Set2'): r''' Function draws "circle plot" and exports axis handles Parameters ------------- netIn : temporal network input (graphlet or contact) ax : matplotlib ax handles. nodelabels : list nodes labe...
[ "def", "circle_plot", "(", "netIn", ",", "ax", ",", "nodelabels", "=", "None", ",", "linestyle", "=", "'k-'", ",", "nodesize", "=", "1000", ",", "cmap", "=", "'Set2'", ")", ":", "# Get input type (C or G)", "inputType", "=", "checkInput", "(", "netIn", ","...
r''' Function draws "circle plot" and exports axis handles Parameters ------------- netIn : temporal network input (graphlet or contact) ax : matplotlib ax handles. nodelabels : list nodes labels. List of strings linestyle : str line style nodesize : int size of...
[ "r" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/plot/circle_plot.py#L9-L108
wiheto/teneto
teneto/temporalcommunity/integration.py
integration
def integration(temporalcommunities, staticcommunities): """ Calculates the integration coefficient for each node. Measures the average probability that a node is in the same community as nodes from other systems. Parameters: ------------ temporalcommunities : array temporal co...
python
def integration(temporalcommunities, staticcommunities): """ Calculates the integration coefficient for each node. Measures the average probability that a node is in the same community as nodes from other systems. Parameters: ------------ temporalcommunities : array temporal co...
[ "def", "integration", "(", "temporalcommunities", ",", "staticcommunities", ")", ":", "# make sure the static and temporal communities have the same number of nodes", "if", "staticcommunities", ".", "shape", "[", "0", "]", "!=", "temporalcommunities", ".", "shape", "[", "0"...
Calculates the integration coefficient for each node. Measures the average probability that a node is in the same community as nodes from other systems. Parameters: ------------ temporalcommunities : array temporal communities vector (node,time) staticcommunities : array ...
[ "Calculates", "the", "integration", "coefficient", "for", "each", "node", ".", "Measures", "the", "average", "probability", "that", "a", "node", "is", "in", "the", "same", "community", "as", "nodes", "from", "other", "systems", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/temporalcommunity/integration.py#L5-L45
wiheto/teneto
teneto/networkmeasures/intercontacttimes.py
intercontacttimes
def intercontacttimes(tnet): """ Calculates the intercontacttimes of each edge in a network. Parameters ----------- tnet : array, dict Temporal network (craphlet or contact). Nettype: 'bu', 'bd' Returns --------- contacts : dict Intercontact times as numpy array in di...
python
def intercontacttimes(tnet): """ Calculates the intercontacttimes of each edge in a network. Parameters ----------- tnet : array, dict Temporal network (craphlet or contact). Nettype: 'bu', 'bd' Returns --------- contacts : dict Intercontact times as numpy array in di...
[ "def", "intercontacttimes", "(", "tnet", ")", ":", "# Process input", "tnet", "=", "process_input", "(", "tnet", ",", "[", "'C'", ",", "'G'", ",", "'TN'", "]", ",", "'TN'", ")", "if", "tnet", ".", "nettype", "[", "0", "]", "==", "'w'", ":", "print", ...
Calculates the intercontacttimes of each edge in a network. Parameters ----------- tnet : array, dict Temporal network (craphlet or contact). Nettype: 'bu', 'bd' Returns --------- contacts : dict Intercontact times as numpy array in dictionary. contacts['intercontacttimes'] ...
[ "Calculates", "the", "intercontacttimes", "of", "each", "edge", "in", "a", "network", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/intercontacttimes.py#L9-L108
wiheto/teneto
teneto/timeseries/report.py
gen_report
def gen_report(report, sdir='./', report_name='report.html'): """ Generates report of derivation and postprocess steps in teneto.derive """ # Create report directory if not os.path.exists(sdir): os.makedirs(sdir) # Add a slash to file directory if not included to avoid DirNameFleName ...
python
def gen_report(report, sdir='./', report_name='report.html'): """ Generates report of derivation and postprocess steps in teneto.derive """ # Create report directory if not os.path.exists(sdir): os.makedirs(sdir) # Add a slash to file directory if not included to avoid DirNameFleName ...
[ "def", "gen_report", "(", "report", ",", "sdir", "=", "'./'", ",", "report_name", "=", "'report.html'", ")", ":", "# Create report directory", "if", "not", "os", ".", "path", ".", "exists", "(", "sdir", ")", ":", "os", ".", "makedirs", "(", "sdir", ")", ...
Generates report of derivation and postprocess steps in teneto.derive
[ "Generates", "report", "of", "derivation", "and", "postprocess", "steps", "in", "teneto", ".", "derive" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/timeseries/report.py#L10-L92
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.add_history
def add_history(self, fname, fargs, init=0): """ Adds a processing step to TenetoBIDS.history. """ if init == 1: self.history = [] self.history.append([fname, fargs])
python
def add_history(self, fname, fargs, init=0): """ Adds a processing step to TenetoBIDS.history. """ if init == 1: self.history = [] self.history.append([fname, fargs])
[ "def", "add_history", "(", "self", ",", "fname", ",", "fargs", ",", "init", "=", "0", ")", ":", "if", "init", "==", "1", ":", "self", ".", "history", "=", "[", "]", "self", ".", "history", ".", "append", "(", "[", "fname", ",", "fargs", "]", ")...
Adds a processing step to TenetoBIDS.history.
[ "Adds", "a", "processing", "step", "to", "TenetoBIDS", ".", "history", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L129-L135
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.export_history
def export_history(self, dirname): """ Exports TenetoBIDShistory.py, tenetoinfo.json, requirements.txt (modules currently imported) to dirname Parameters --------- dirname : str directory to export entire TenetoBIDS history. """ mods = [(m.__name__, ...
python
def export_history(self, dirname): """ Exports TenetoBIDShistory.py, tenetoinfo.json, requirements.txt (modules currently imported) to dirname Parameters --------- dirname : str directory to export entire TenetoBIDS history. """ mods = [(m.__name__, ...
[ "def", "export_history", "(", "self", ",", "dirname", ")", ":", "mods", "=", "[", "(", "m", ".", "__name__", ",", "m", ".", "__version__", ")", "for", "m", "in", "sys", ".", "modules", ".", "values", "(", ")", "if", "m", "if", "hasattr", "(", "m"...
Exports TenetoBIDShistory.py, tenetoinfo.json, requirements.txt (modules currently imported) to dirname Parameters --------- dirname : str directory to export entire TenetoBIDS history.
[ "Exports", "TenetoBIDShistory", ".", "py", "tenetoinfo", ".", "json", "requirements", ".", "txt", "(", "modules", "currently", "imported", ")", "to", "dirname" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L137-L162
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.derive_temporalnetwork
def derive_temporalnetwork(self, params, update_pipeline=True, tag=None, njobs=1, confound_corr_report=True): """ Derive time-varying connectivity on the selected files. Parameters ---------- params : dict. See teneto.timeseries.derive_temporalnetwork for the structu...
python
def derive_temporalnetwork(self, params, update_pipeline=True, tag=None, njobs=1, confound_corr_report=True): """ Derive time-varying connectivity on the selected files. Parameters ---------- params : dict. See teneto.timeseries.derive_temporalnetwork for the structu...
[ "def", "derive_temporalnetwork", "(", "self", ",", "params", ",", "update_pipeline", "=", "True", ",", "tag", "=", "None", ",", "njobs", "=", "1", ",", "confound_corr_report", "=", "True", ")", ":", "if", "not", "njobs", ":", "njobs", "=", "self", ".", ...
Derive time-varying connectivity on the selected files. Parameters ---------- params : dict. See teneto.timeseries.derive_temporalnetwork for the structure of the param dictionary. Assumes dimord is time,node (output of other TenetoBIDS funcitons) update_pipeline : bool ...
[ "Derive", "time", "-", "varying", "connectivity", "on", "the", "selected", "files", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L164-L219
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS._derive_temporalnetwork
def _derive_temporalnetwork(self, f, i, tag, params, confounds_exist, confound_files): """ Funciton called by TenetoBIDS.derive_temporalnetwork for concurrent processing. """ data = load_tabular_file(f, index_col=True, header=True) fs, _ = drop_bids_suffix(f) save_name, ...
python
def _derive_temporalnetwork(self, f, i, tag, params, confounds_exist, confound_files): """ Funciton called by TenetoBIDS.derive_temporalnetwork for concurrent processing. """ data = load_tabular_file(f, index_col=True, header=True) fs, _ = drop_bids_suffix(f) save_name, ...
[ "def", "_derive_temporalnetwork", "(", "self", ",", "f", ",", "i", ",", "tag", ",", "params", ",", "confounds_exist", ",", "confound_files", ")", ":", "data", "=", "load_tabular_file", "(", "f", ",", "index_col", "=", "True", ",", "header", "=", "True", ...
Funciton called by TenetoBIDS.derive_temporalnetwork for concurrent processing.
[ "Funciton", "called", "by", "TenetoBIDS", ".", "derive_temporalnetwork", "for", "concurrent", "processing", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L221-L320
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.make_functional_connectivity
def make_functional_connectivity(self, njobs=None, returngroup=False, file_hdr=None, file_idx=None): """ Makes connectivity matrix for each of the subjects. Parameters ---------- returngroup : bool, default=False If true, returns the group average connectivity matrix...
python
def make_functional_connectivity(self, njobs=None, returngroup=False, file_hdr=None, file_idx=None): """ Makes connectivity matrix for each of the subjects. Parameters ---------- returngroup : bool, default=False If true, returns the group average connectivity matrix...
[ "def", "make_functional_connectivity", "(", "self", ",", "njobs", "=", "None", ",", "returngroup", "=", "False", ",", "file_hdr", "=", "None", ",", "file_idx", "=", "None", ")", ":", "if", "not", "njobs", ":", "njobs", "=", "self", ".", "njobs", "self", ...
Makes connectivity matrix for each of the subjects. Parameters ---------- returngroup : bool, default=False If true, returns the group average connectivity matrix. njobs : int How many parallel jobs to run file_idx : bool Default False, true i...
[ "Makes", "connectivity", "matrix", "for", "each", "of", "the", "subjects", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L360-L398
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS._save_namepaths_bids_derivatives
def _save_namepaths_bids_derivatives(self, f, tag, save_directory, suffix=None): """ Creates output directory and output name Paramters --------- f : str input files, includes the file bids_suffix tag : str what should be added to f in the output ...
python
def _save_namepaths_bids_derivatives(self, f, tag, save_directory, suffix=None): """ Creates output directory and output name Paramters --------- f : str input files, includes the file bids_suffix tag : str what should be added to f in the output ...
[ "def", "_save_namepaths_bids_derivatives", "(", "self", ",", "f", ",", "tag", ",", "save_directory", ",", "suffix", "=", "None", ")", ":", "file_name", "=", "f", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", ".", "split", "(", "'.'", ")", "[", ...
Creates output directory and output name Paramters --------- f : str input files, includes the file bids_suffix tag : str what should be added to f in the output file. save_directory : str additional directory that the output file should go in...
[ "Creates", "output", "directory", "and", "output", "name" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L409-L466
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.get_tags
def get_tags(self, tag, quiet=1): """ Returns which tag alternatives can be identified in the BIDS derivatives structure. """ if not self.pipeline: print('Please set pipeline first.') self.get_pipeline_alternatives(quiet) else: if tag == 'sub':...
python
def get_tags(self, tag, quiet=1): """ Returns which tag alternatives can be identified in the BIDS derivatives structure. """ if not self.pipeline: print('Please set pipeline first.') self.get_pipeline_alternatives(quiet) else: if tag == 'sub':...
[ "def", "get_tags", "(", "self", ",", "tag", ",", "quiet", "=", "1", ")", ":", "if", "not", "self", ".", "pipeline", ":", "print", "(", "'Please set pipeline first.'", ")", "self", ".", "get_pipeline_alternatives", "(", "quiet", ")", "else", ":", "if", "t...
Returns which tag alternatives can be identified in the BIDS derivatives structure.
[ "Returns", "which", "tag", "alternatives", "can", "be", "identified", "in", "the", "BIDS", "derivatives", "structure", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L468-L497
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.get_pipeline_alternatives
def get_pipeline_alternatives(self, quiet=0): """ The pipeline are the different outputs that are placed in the ./derivatives directory. get_pipeline_alternatives gets those which are found in the specified BIDS directory structure. """ if not os.path.exists(self.BIDS_dir + '/de...
python
def get_pipeline_alternatives(self, quiet=0): """ The pipeline are the different outputs that are placed in the ./derivatives directory. get_pipeline_alternatives gets those which are found in the specified BIDS directory structure. """ if not os.path.exists(self.BIDS_dir + '/de...
[ "def", "get_pipeline_alternatives", "(", "self", ",", "quiet", "=", "0", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "BIDS_dir", "+", "'/derivatives/'", ")", ":", "print", "(", "'Derivative directory not found. Is the data preproce...
The pipeline are the different outputs that are placed in the ./derivatives directory. get_pipeline_alternatives gets those which are found in the specified BIDS directory structure.
[ "The", "pipeline", "are", "the", "different", "outputs", "that", "are", "placed", "in", "the", ".", "/", "derivatives", "directory", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L499-L512
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.get_pipeline_subdir_alternatives
def get_pipeline_subdir_alternatives(self, quiet=0): """ Note ----- This function currently returns the wrong folders and will be fixed in the future. This function should return ./derivatives/pipeline/sub-xx/[ses-yy/][func/]/pipeline_subdir But it does not care about s...
python
def get_pipeline_subdir_alternatives(self, quiet=0): """ Note ----- This function currently returns the wrong folders and will be fixed in the future. This function should return ./derivatives/pipeline/sub-xx/[ses-yy/][func/]/pipeline_subdir But it does not care about s...
[ "def", "get_pipeline_subdir_alternatives", "(", "self", ",", "quiet", "=", "0", ")", ":", "if", "not", "self", ".", "pipeline", ":", "print", "(", "'Please set pipeline first.'", ")", "self", ".", "get_pipeline_alternatives", "(", ")", "else", ":", "pipeline_sub...
Note ----- This function currently returns the wrong folders and will be fixed in the future. This function should return ./derivatives/pipeline/sub-xx/[ses-yy/][func/]/pipeline_subdir But it does not care about ses-yy at the moment.
[ "Note", "-----" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L514-L538
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.get_selected_files
def get_selected_files(self, pipeline='pipeline', forfile=None, quiet=0, allowedfileformats='default'): """ Parameters ---------- pipeline : string can be \'pipeline\' (main analysis pipeline, self in tnet.set_pipeline) or \'confound\' (where confound files are, set in tnet.s...
python
def get_selected_files(self, pipeline='pipeline', forfile=None, quiet=0, allowedfileformats='default'): """ Parameters ---------- pipeline : string can be \'pipeline\' (main analysis pipeline, self in tnet.set_pipeline) or \'confound\' (where confound files are, set in tnet.s...
[ "def", "get_selected_files", "(", "self", ",", "pipeline", "=", "'pipeline'", ",", "forfile", "=", "None", ",", "quiet", "=", "0", ",", "allowedfileformats", "=", "'default'", ")", ":", "# This could be mnade better", "file_dict", "=", "dict", "(", "self", "."...
Parameters ---------- pipeline : string can be \'pipeline\' (main analysis pipeline, self in tnet.set_pipeline) or \'confound\' (where confound files are, set in tnet.set_confonud_pipeline()), \'functionalconnectivity\' quiet: int If 1, prints results. If 0, n...
[ "Parameters", "----------", "pipeline", ":", "string", "can", "be", "\\", "pipeline", "\\", "(", "main", "analysis", "pipeline", "self", "in", "tnet", ".", "set_pipeline", ")", "or", "\\", "confound", "\\", "(", "where", "confound", "files", "are", "set", ...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L540-L648
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.set_exclusion_file
def set_exclusion_file(self, confound, exclusion_criteria, confound_stat='mean'): """ Excludes subjects given a certain exclusion criteria. Parameters ---------- confound : str or list string or list of confound name(s) from confound files exclusi...
python
def set_exclusion_file(self, confound, exclusion_criteria, confound_stat='mean'): """ Excludes subjects given a certain exclusion criteria. Parameters ---------- confound : str or list string or list of confound name(s) from confound files exclusi...
[ "def", "set_exclusion_file", "(", "self", ",", "confound", ",", "exclusion_criteria", ",", "confound_stat", "=", "'mean'", ")", ":", "self", ".", "add_history", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ",", "locals", "(", "...
Excludes subjects given a certain exclusion criteria. Parameters ---------- confound : str or list string or list of confound name(s) from confound files exclusion_criteria : str or list for each confound, an exclusion_criteria should be expresse...
[ "Excludes", "subjects", "given", "a", "certain", "exclusion", "criteria", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L650-L719
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.set_exclusion_timepoint
def set_exclusion_timepoint(self, confound, exclusion_criteria, replace_with, tol=1, overwrite=True, desc=None): """ Excludes subjects given a certain exclusion criteria. Does not work on nifti files, only csv, numpy or tsc. Assumes data is node,time Parameters ---------- co...
python
def set_exclusion_timepoint(self, confound, exclusion_criteria, replace_with, tol=1, overwrite=True, desc=None): """ Excludes subjects given a certain exclusion criteria. Does not work on nifti files, only csv, numpy or tsc. Assumes data is node,time Parameters ---------- co...
[ "def", "set_exclusion_timepoint", "(", "self", ",", "confound", ",", "exclusion_criteria", ",", "replace_with", ",", "tol", "=", "1", ",", "overwrite", "=", "True", ",", "desc", "=", "None", ")", ":", "self", ".", "add_history", "(", "inspect", ".", "stack...
Excludes subjects given a certain exclusion criteria. Does not work on nifti files, only csv, numpy or tsc. Assumes data is node,time Parameters ---------- confound : str or list string or list of confound name(s) from confound files. Assumes data is node,time ex...
[ "Excludes", "subjects", "given", "a", "certain", "exclusion", "criteria", ".", "Does", "not", "work", "on", "nifti", "files", "only", "csv", "numpy", "or", "tsc", ".", "Assumes", "data", "is", "node", "time" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L721-L829
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.make_parcellation
def make_parcellation(self, parcellation, parc_type=None, parc_params=None, network='defaults', update_pipeline=True, removeconfounds=False, tag=None, njobs=None, clean_params=None, yeonetworkn=None): """ Reduces the data from voxel to parcellation space. Files get saved in a teneto folder in the deriva...
python
def make_parcellation(self, parcellation, parc_type=None, parc_params=None, network='defaults', update_pipeline=True, removeconfounds=False, tag=None, njobs=None, clean_params=None, yeonetworkn=None): """ Reduces the data from voxel to parcellation space. Files get saved in a teneto folder in the deriva...
[ "def", "make_parcellation", "(", "self", ",", "parcellation", ",", "parc_type", "=", "None", ",", "parc_params", "=", "None", ",", "network", "=", "'defaults'", ",", "update_pipeline", "=", "True", ",", "removeconfounds", "=", "False", ",", "tag", "=", "None...
Reduces the data from voxel to parcellation space. Files get saved in a teneto folder in the derivatives with a roi tag at the end. Parameters ----------- parcellation : str specify which parcellation that you would like to use. For MNI: 'power2012_264', 'gordon2014_333'. TAL: 'she...
[ "Reduces", "the", "data", "from", "voxel", "to", "parcellation", "space", ".", "Files", "get", "saved", "in", "a", "teneto", "folder", "in", "the", "derivatives", "with", "a", "roi", "tag", "at", "the", "end", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L847-L930
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.communitydetection
def communitydetection(self, community_detection_params, community_type='temporal', tag=None, file_hdr=False, file_idx=False, njobs=None): """ Calls temporal_louvain_with_consensus on connectivity data Parameters ---------- community_detection_params : dict kwargs f...
python
def communitydetection(self, community_detection_params, community_type='temporal', tag=None, file_hdr=False, file_idx=False, njobs=None): """ Calls temporal_louvain_with_consensus on connectivity data Parameters ---------- community_detection_params : dict kwargs f...
[ "def", "communitydetection", "(", "self", ",", "community_detection_params", ",", "community_type", "=", "'temporal'", ",", "tag", "=", "None", ",", "file_hdr", "=", "False", ",", "file_idx", "=", "False", ",", "njobs", "=", "None", ")", ":", "if", "not", ...
Calls temporal_louvain_with_consensus on connectivity data Parameters ---------- community_detection_params : dict kwargs for detection. See teneto.communitydetection.louvain.temporal_louvain_with_consensus community_type : str Either 'temporal' or 'static'. If ...
[ "Calls", "temporal_louvain_with_consensus", "on", "connectivity", "data" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L950-L1001
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.removeconfounds
def removeconfounds(self, confounds=None, clean_params=None, transpose=None, njobs=None, update_pipeline=True, overwrite=True, tag=None): """ Removes specified confounds using nilearn.signal.clean Parameters ---------- confounds : list List of confounds. Can be presp...
python
def removeconfounds(self, confounds=None, clean_params=None, transpose=None, njobs=None, update_pipeline=True, overwrite=True, tag=None): """ Removes specified confounds using nilearn.signal.clean Parameters ---------- confounds : list List of confounds. Can be presp...
[ "def", "removeconfounds", "(", "self", ",", "confounds", "=", "None", ",", "clean_params", "=", "None", ",", "transpose", "=", "None", ",", "njobs", "=", "None", ",", "update_pipeline", "=", "True", ",", "overwrite", "=", "True", ",", "tag", "=", "None",...
Removes specified confounds using nilearn.signal.clean Parameters ---------- confounds : list List of confounds. Can be prespecified in set_confounds clean_params : dict Dictionary of kawgs to pass to nilearn.signal.clean transpose : bool (default False) ...
[ "Removes", "specified", "confounds", "using", "nilearn", ".", "signal", ".", "clean" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1036-L1094
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.networkmeasures
def networkmeasures(self, measure=None, measure_params=None, tag=None, njobs=None): """ Calculates a network measure For available funcitons see: teneto.networkmeasures Parameters ---------- measure : str or list Mame of function(s) from teneto.networkmeasu...
python
def networkmeasures(self, measure=None, measure_params=None, tag=None, njobs=None): """ Calculates a network measure For available funcitons see: teneto.networkmeasures Parameters ---------- measure : str or list Mame of function(s) from teneto.networkmeasu...
[ "def", "networkmeasures", "(", "self", ",", "measure", "=", "None", ",", "measure_params", "=", "None", ",", "tag", "=", "None", ",", "njobs", "=", "None", ")", ":", "if", "not", "njobs", ":", "njobs", "=", "self", ".", "njobs", "self", ".", "add_his...
Calculates a network measure For available funcitons see: teneto.networkmeasures Parameters ---------- measure : str or list Mame of function(s) from teneto.networkmeasures that will be run. measure_params : dict or list of dctionaries) Containing kwar...
[ "Calculates", "a", "network", "measure" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1153-L1209
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.set_confound_pipeline
def set_confound_pipeline(self, confound_pipeline): """ There may be times when the pipeline is updated (e.g. teneto) but you want the confounds from the preprocessing pipieline (e.g. fmriprep). To do this, you set the confound_pipeline to be the preprocessing pipeline where the confound files a...
python
def set_confound_pipeline(self, confound_pipeline): """ There may be times when the pipeline is updated (e.g. teneto) but you want the confounds from the preprocessing pipieline (e.g. fmriprep). To do this, you set the confound_pipeline to be the preprocessing pipeline where the confound files a...
[ "def", "set_confound_pipeline", "(", "self", ",", "confound_pipeline", ")", ":", "self", ".", "add_history", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ",", "locals", "(", ")", ",", "1", ")", "if", "not", "os", ".", "path...
There may be times when the pipeline is updated (e.g. teneto) but you want the confounds from the preprocessing pipieline (e.g. fmriprep). To do this, you set the confound_pipeline to be the preprocessing pipeline where the confound files are. Parameters ---------- confound_pipeline : ...
[ "There", "may", "be", "times", "when", "the", "pipeline", "is", "updated", "(", "e", ".", "g", ".", "teneto", ")", "but", "you", "want", "the", "confounds", "from", "the", "preprocessing", "pipieline", "(", "e", ".", "g", ".", "fmriprep", ")", ".", "...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1319-L1340
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.set_bids_suffix
def set_bids_suffix(self, bids_suffix): """ The last analysis step is the final tag that is present in files. """ self.add_history(inspect.stack()[0][3], locals(), 1) self.bids_suffix = bids_suffix
python
def set_bids_suffix(self, bids_suffix): """ The last analysis step is the final tag that is present in files. """ self.add_history(inspect.stack()[0][3], locals(), 1) self.bids_suffix = bids_suffix
[ "def", "set_bids_suffix", "(", "self", ",", "bids_suffix", ")", ":", "self", ".", "add_history", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ",", "locals", "(", ")", ",", "1", ")", "self", ".", "bids_suffix", "=", "bids_su...
The last analysis step is the final tag that is present in files.
[ "The", "last", "analysis", "step", "is", "the", "final", "tag", "that", "is", "present", "in", "files", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1426-L1431
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.set_pipeline
def set_pipeline(self, pipeline): """ Specify the pipeline. See get_pipeline_alternatives to see what are avaialble. Input should be a string. """ self.add_history(inspect.stack()[0][3], locals(), 1) if not os.path.exists(self.BIDS_dir + '/derivatives/' + pipeline): p...
python
def set_pipeline(self, pipeline): """ Specify the pipeline. See get_pipeline_alternatives to see what are avaialble. Input should be a string. """ self.add_history(inspect.stack()[0][3], locals(), 1) if not os.path.exists(self.BIDS_dir + '/derivatives/' + pipeline): p...
[ "def", "set_pipeline", "(", "self", ",", "pipeline", ")", ":", "self", ".", "add_history", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "3", "]", ",", "locals", "(", ")", ",", "1", ")", "if", "not", "os", ".", "path", ".", "exist...
Specify the pipeline. See get_pipeline_alternatives to see what are avaialble. Input should be a string.
[ "Specify", "the", "pipeline", ".", "See", "get_pipeline_alternatives", "to", "see", "what", "are", "avaialble", ".", "Input", "should", "be", "a", "string", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1433-L1443
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.print_dataset_summary
def print_dataset_summary(self): """ Prints information about the the BIDS data and the files currently selected. """ print('--- DATASET INFORMATION ---') print('--- Subjects ---') if self.raw_data_exists: if self.BIDS.get_subjects(): print('...
python
def print_dataset_summary(self): """ Prints information about the the BIDS data and the files currently selected. """ print('--- DATASET INFORMATION ---') print('--- Subjects ---') if self.raw_data_exists: if self.BIDS.get_subjects(): print('...
[ "def", "print_dataset_summary", "(", "self", ")", ":", "print", "(", "'--- DATASET INFORMATION ---'", ")", "print", "(", "'--- Subjects ---'", ")", "if", "self", ".", "raw_data_exists", ":", "if", "self", ".", "BIDS", ".", "get_subjects", "(", ")", ":", "print...
Prints information about the the BIDS data and the files currently selected.
[ "Prints", "information", "about", "the", "the", "BIDS", "data", "and", "the", "files", "currently", "selected", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1454-L1532
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.load_frompickle
def load_frompickle(cls, fname, reload_object=False): """ Loaded saved instance of fname : str path to pickle object (output of TenetoBIDS.save_aspickle) reload_object : bool (default False) reloads object by calling teneto.TenetoBIDS (some information lost, for ...
python
def load_frompickle(cls, fname, reload_object=False): """ Loaded saved instance of fname : str path to pickle object (output of TenetoBIDS.save_aspickle) reload_object : bool (default False) reloads object by calling teneto.TenetoBIDS (some information lost, for ...
[ "def", "load_frompickle", "(", "cls", ",", "fname", ",", "reload_object", "=", "False", ")", ":", "if", "fname", "[", "-", "4", ":", "]", "!=", "'.pkl'", ":", "fname", "+=", "'.pkl'", "with", "open", "(", "fname", ",", "'rb'", ")", "as", "f", ":", ...
Loaded saved instance of fname : str path to pickle object (output of TenetoBIDS.save_aspickle) reload_object : bool (default False) reloads object by calling teneto.TenetoBIDS (some information lost, for development) Returns ------- self : ...
[ "Loaded", "saved", "instance", "of" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1541-L1564
wiheto/teneto
teneto/classes/bids.py
TenetoBIDS.load_data
def load_data(self, datatype='tvc', tag=None, measure=''): """ Function loads time-varying connectivity estimates created by the TenetoBIDS.derive function. The default grabs all data (in numpy arrays) in the teneto/../func/tvc/ directory. Data is placed in teneto.tvc_data_ Para...
python
def load_data(self, datatype='tvc', tag=None, measure=''): """ Function loads time-varying connectivity estimates created by the TenetoBIDS.derive function. The default grabs all data (in numpy arrays) in the teneto/../func/tvc/ directory. Data is placed in teneto.tvc_data_ Para...
[ "def", "load_data", "(", "self", ",", "datatype", "=", "'tvc'", ",", "tag", "=", "None", ",", "measure", "=", "''", ")", ":", "if", "datatype", "==", "'temporalnetwork'", "and", "not", "measure", ":", "raise", "ValueError", "(", "'When datatype is temporalne...
Function loads time-varying connectivity estimates created by the TenetoBIDS.derive function. The default grabs all data (in numpy arrays) in the teneto/../func/tvc/ directory. Data is placed in teneto.tvc_data_ Parameters ---------- datatype : str \'tvc\', \'parcel...
[ "Function", "loads", "time", "-", "varying", "connectivity", "estimates", "created", "by", "the", "TenetoBIDS", ".", "derive", "function", ".", "The", "default", "grabs", "all", "data", "(", "in", "numpy", "arrays", ")", "in", "the", "teneto", "/", "..", "...
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/bids.py#L1636-L1698
wiheto/teneto
teneto/networkmeasures/temporal_closeness_centrality.py
temporal_closeness_centrality
def temporal_closeness_centrality(tnet=None, paths=None): ''' Returns temporal closeness centrality per node. Parameters ----------- Input should be *either* tnet or paths. data : array or dict Temporal network input (graphlet or contact). nettype: 'bu', 'bd'. paths : pandas dat...
python
def temporal_closeness_centrality(tnet=None, paths=None): ''' Returns temporal closeness centrality per node. Parameters ----------- Input should be *either* tnet or paths. data : array or dict Temporal network input (graphlet or contact). nettype: 'bu', 'bd'. paths : pandas dat...
[ "def", "temporal_closeness_centrality", "(", "tnet", "=", "None", ",", "paths", "=", "None", ")", ":", "if", "tnet", "is", "not", "None", "and", "paths", "is", "not", "None", ":", "raise", "ValueError", "(", "'Only network or path input allowed.'", ")", "if", ...
Returns temporal closeness centrality per node. Parameters ----------- Input should be *either* tnet or paths. data : array or dict Temporal network input (graphlet or contact). nettype: 'bu', 'bd'. paths : pandas dataframe Output of TenetoBIDS.networkmeasure.shortest_temporal_...
[ "Returns", "temporal", "closeness", "centrality", "per", "node", "." ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/temporal_closeness_centrality.py#L9-L52
wiheto/teneto
teneto/networkmeasures/sid.py
sid
def sid(tnet, communities, axis=0, calc='global', decay=0): r""" Segregation integration difference (SID). An estimation of each community or global difference of within versus between community strength.[sid-1]_ Parameters ---------- tnet: array, dict Temporal network input (graphlet or ...
python
def sid(tnet, communities, axis=0, calc='global', decay=0): r""" Segregation integration difference (SID). An estimation of each community or global difference of within versus between community strength.[sid-1]_ Parameters ---------- tnet: array, dict Temporal network input (graphlet or ...
[ "def", "sid", "(", "tnet", ",", "communities", ",", "axis", "=", "0", ",", "calc", "=", "'global'", ",", "decay", "=", "0", ")", ":", "tnet", ",", "netinfo", "=", "utils", ".", "process_input", "(", "tnet", ",", "[", "'C'", ",", "'G'", ",", "'TN'...
r""" Segregation integration difference (SID). An estimation of each community or global difference of within versus between community strength.[sid-1]_ Parameters ---------- tnet: array, dict Temporal network input (graphlet or contact). Allowerd nettype: 'bu', 'bd', 'wu', 'wd' communit...
[ "r" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/sid.py#L8-L111
wiheto/teneto
teneto/networkmeasures/bursty_coeff.py
bursty_coeff
def bursty_coeff(data, calc='edge', nodes='all', communities=None, threshold_type=None, threshold_level=None, threshold_params=None): r""" Calculates the bursty coefficient.[1][2] Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with ...
python
def bursty_coeff(data, calc='edge', nodes='all', communities=None, threshold_type=None, threshold_level=None, threshold_params=None): r""" Calculates the bursty coefficient.[1][2] Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with ...
[ "def", "bursty_coeff", "(", "data", ",", "calc", "=", "'edge'", ",", "nodes", "=", "'all'", ",", "communities", "=", "None", ",", "threshold_type", "=", "None", ",", "threshold_level", "=", "None", ",", "threshold_params", "=", "None", ")", ":", "if", "t...
r""" Calculates the bursty coefficient.[1][2] Parameters ---------- data : array, dict This is either (1) temporal network input (graphlet or contact) with nettype: 'bu', 'bd'. (2) dictionary of ICTs (output of *intercontacttimes*). A weighted network can be applied if you specify thre...
[ "r", "Calculates", "the", "bursty", "coefficient", ".", "[", "1", "]", "[", "2", "]" ]
train
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/networkmeasures/bursty_coeff.py#L10-L204
ianlini/flatten-dict
flatten_dict/flatten_dict.py
flatten
def flatten(d, reducer='tuple', inverse=False): """Flatten dict-like object. Parameters ---------- d: dict-like object The dict that will be flattened. reducer: {'tuple', 'path', function} (default: 'tuple') The key joining method. If a function is given, the function will be ...
python
def flatten(d, reducer='tuple', inverse=False): """Flatten dict-like object. Parameters ---------- d: dict-like object The dict that will be flattened. reducer: {'tuple', 'path', function} (default: 'tuple') The key joining method. If a function is given, the function will be ...
[ "def", "flatten", "(", "d", ",", "reducer", "=", "'tuple'", ",", "inverse", "=", "False", ")", ":", "if", "isinstance", "(", "reducer", ",", "str", ")", ":", "reducer", "=", "REDUCER_DICT", "[", "reducer", "]", "flat_dict", "=", "{", "}", "def", "_fl...
Flatten dict-like object. Parameters ---------- d: dict-like object The dict that will be flattened. reducer: {'tuple', 'path', function} (default: 'tuple') The key joining method. If a function is given, the function will be used to reduce. 'tuple': The resulting key wi...
[ "Flatten", "dict", "-", "like", "object", "." ]
train
https://github.com/ianlini/flatten-dict/blob/77a2bf669ea6dc7446b8ad1596dc2a41d4c5a7fa/flatten_dict/flatten_dict.py#L20-L56
ianlini/flatten-dict
flatten_dict/flatten_dict.py
nested_set_dict
def nested_set_dict(d, keys, value): """Set a value to a sequence of nested keys Parameters ---------- d: Mapping keys: Sequence[str] value: Any """ assert keys key = keys[0] if len(keys) == 1: if key in d: raise ValueError("duplicated key '{}'".format(key)) ...
python
def nested_set_dict(d, keys, value): """Set a value to a sequence of nested keys Parameters ---------- d: Mapping keys: Sequence[str] value: Any """ assert keys key = keys[0] if len(keys) == 1: if key in d: raise ValueError("duplicated key '{}'".format(key)) ...
[ "def", "nested_set_dict", "(", "d", ",", "keys", ",", "value", ")", ":", "assert", "keys", "key", "=", "keys", "[", "0", "]", "if", "len", "(", "keys", ")", "==", "1", ":", "if", "key", "in", "d", ":", "raise", "ValueError", "(", "\"duplicated key ...
Set a value to a sequence of nested keys Parameters ---------- d: Mapping keys: Sequence[str] value: Any
[ "Set", "a", "value", "to", "a", "sequence", "of", "nested", "keys" ]
train
https://github.com/ianlini/flatten-dict/blob/77a2bf669ea6dc7446b8ad1596dc2a41d4c5a7fa/flatten_dict/flatten_dict.py#L59-L76
ianlini/flatten-dict
flatten_dict/flatten_dict.py
unflatten
def unflatten(d, splitter='tuple', inverse=False): """Unflatten dict-like object. Parameters ---------- d: dict-like object The dict that will be unflattened. splitter: {'tuple', 'path', function} (default: 'tuple') The key splitting method. If a function is given, the function will...
python
def unflatten(d, splitter='tuple', inverse=False): """Unflatten dict-like object. Parameters ---------- d: dict-like object The dict that will be unflattened. splitter: {'tuple', 'path', function} (default: 'tuple') The key splitting method. If a function is given, the function will...
[ "def", "unflatten", "(", "d", ",", "splitter", "=", "'tuple'", ",", "inverse", "=", "False", ")", ":", "if", "isinstance", "(", "splitter", ",", "str", ")", ":", "splitter", "=", "SPLITTER_DICT", "[", "splitter", "]", "unflattened_dict", "=", "{", "}", ...
Unflatten dict-like object. Parameters ---------- d: dict-like object The dict that will be unflattened. splitter: {'tuple', 'path', function} (default: 'tuple') The key splitting method. If a function is given, the function will be used to split. 'tuple': Use each eleme...
[ "Unflatten", "dict", "-", "like", "object", "." ]
train
https://github.com/ianlini/flatten-dict/blob/77a2bf669ea6dc7446b8ad1596dc2a41d4c5a7fa/flatten_dict/flatten_dict.py#L79-L108
salu133445/pypianoroll
pypianoroll/plot.py
plot_pianoroll
def plot_pianoroll(ax, pianoroll, is_drum=False, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='bot...
python
def plot_pianoroll(ax, pianoroll, is_drum=False, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='bot...
[ "def", "plot_pianoroll", "(", "ax", ",", "pianoroll", ",", "is_drum", "=", "False", ",", "beat_resolution", "=", "None", ",", "downbeats", "=", "None", ",", "preset", "=", "'default'", ",", "cmap", "=", "'Blues'", ",", "xtick", "=", "'auto'", ",", "ytick...
Plot a pianoroll given as a numpy array. Parameters ---------- ax : matplotlib.axes.Axes object A :class:`matplotlib.axes.Axes` object where the pianoroll will be plotted on. pianoroll : np.ndarray A pianoroll to be plotted. The values should be in [0, 1] when data type ...
[ "Plot", "a", "pianoroll", "given", "as", "a", "numpy", "array", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/plot.py#L23-L214
salu133445/pypianoroll
pypianoroll/plot.py
plot_track
def plot_track(track, filename=None, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='both', grid_linestyle=':', grid...
python
def plot_track(track, filename=None, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='both', grid_linestyle=':', grid...
[ "def", "plot_track", "(", "track", ",", "filename", "=", "None", ",", "beat_resolution", "=", "None", ",", "downbeats", "=", "None", ",", "preset", "=", "'default'", ",", "cmap", "=", "'Blues'", ",", "xtick", "=", "'auto'", ",", "ytick", "=", "'octave'",...
Plot the pianoroll or save a plot of the pianoroll. Parameters ---------- filename : The filename to which the plot is saved. If None, save nothing. beat_resolution : int The number of time steps used to represent a beat. Required and only effective when `xtick` is 'beat'. d...
[ "Plot", "the", "pianoroll", "or", "save", "a", "plot", "of", "the", "pianoroll", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/plot.py#L216-L303
salu133445/pypianoroll
pypianoroll/plot.py
plot_multitrack
def plot_multitrack(multitrack, filename=None, mode='separate', track_label='name', preset='default', cmaps=None, xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='both...
python
def plot_multitrack(multitrack, filename=None, mode='separate', track_label='name', preset='default', cmaps=None, xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', label='both', grid='both...
[ "def", "plot_multitrack", "(", "multitrack", ",", "filename", "=", "None", ",", "mode", "=", "'separate'", ",", "track_label", "=", "'name'", ",", "preset", "=", "'default'", ",", "cmaps", "=", "None", ",", "xtick", "=", "'auto'", ",", "ytick", "=", "'oc...
Plot the pianorolls or save a plot of them. Parameters ---------- filename : str The filename to which the plot is saved. If None, save nothing. mode : {'separate', 'stacked', 'hybrid'} A string that indicate the plotting mode to use. Defaults to 'separate'. - In 'separ...
[ "Plot", "the", "pianorolls", "or", "save", "a", "plot", "of", "them", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/plot.py#L305-L528
salu133445/pypianoroll
pypianoroll/plot.py
save_animation
def save_animation(filename, pianoroll, window, hop=1, fps=None, is_drum=False, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', ...
python
def save_animation(filename, pianoroll, window, hop=1, fps=None, is_drum=False, beat_resolution=None, downbeats=None, preset='default', cmap='Blues', xtick='auto', ytick='octave', xticklabel=True, yticklabel='auto', tick_loc=None, tick_direction='in', ...
[ "def", "save_animation", "(", "filename", ",", "pianoroll", ",", "window", ",", "hop", "=", "1", ",", "fps", "=", "None", ",", "is_drum", "=", "False", ",", "beat_resolution", "=", "None", ",", "downbeats", "=", "None", ",", "preset", "=", "'default'", ...
Save a pianoroll to an animation in video or GIF format. Parameters ---------- filename : str The filename to which the animation is saved. pianoroll : np.ndarray A pianoroll to be plotted. The values should be in [0, 1] when data type is float, and in [0, 127] when data type is...
[ "Save", "a", "pianoroll", "to", "an", "animation", "in", "video", "or", "GIF", "format", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/plot.py#L530-L681
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.append_track
def append_track(self, track=None, pianoroll=None, program=0, is_drum=False, name='unknown'): """ Append a multitrack.Track instance to the track list or create a new multitrack.Track object and append it to the track list. Parameters ---------- trac...
python
def append_track(self, track=None, pianoroll=None, program=0, is_drum=False, name='unknown'): """ Append a multitrack.Track instance to the track list or create a new multitrack.Track object and append it to the track list. Parameters ---------- trac...
[ "def", "append_track", "(", "self", ",", "track", "=", "None", ",", "pianoroll", "=", "None", ",", "program", "=", "0", ",", "is_drum", "=", "False", ",", "name", "=", "'unknown'", ")", ":", "if", "track", "is", "not", "None", ":", "if", "not", "is...
Append a multitrack.Track instance to the track list or create a new multitrack.Track object and append it to the track list. Parameters ---------- track : pianoroll.Track A :class:`pypianoroll.Track` instance to be appended to the track list. pianoroll :...
[ "Append", "a", "multitrack", ".", "Track", "instance", "to", "the", "track", "list", "or", "create", "a", "new", "multitrack", ".", "Track", "object", "and", "append", "it", "to", "the", "track", "list", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L143-L180
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.check_validity
def check_validity(self): """ Raise an error if any invalid attribute found. Raises ------ TypeError If an attribute has an invalid type. ValueError If an attribute has an invalid value (of the correct type). """ # tracks ...
python
def check_validity(self): """ Raise an error if any invalid attribute found. Raises ------ TypeError If an attribute has an invalid type. ValueError If an attribute has an invalid value (of the correct type). """ # tracks ...
[ "def", "check_validity", "(", "self", ")", ":", "# tracks", "for", "track", "in", "self", ".", "tracks", ":", "if", "not", "isinstance", "(", "track", ",", "Track", ")", ":", "raise", "TypeError", "(", "\"`tracks` must be a list of \"", "\"`pypianoroll.Track` in...
Raise an error if any invalid attribute found. Raises ------ TypeError If an attribute has an invalid type. ValueError If an attribute has an invalid value (of the correct type).
[ "Raise", "an", "error", "if", "any", "invalid", "attribute", "found", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L210-L253
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.clip
def clip(self, lower=0, upper=127): """ Clip the pianorolls of all tracks by the given lower and upper bounds. Parameters ---------- lower : int or float The lower bound to clip the pianorolls. Defaults to 0. upper : int or float The upper bound t...
python
def clip(self, lower=0, upper=127): """ Clip the pianorolls of all tracks by the given lower and upper bounds. Parameters ---------- lower : int or float The lower bound to clip the pianorolls. Defaults to 0. upper : int or float The upper bound t...
[ "def", "clip", "(", "self", ",", "lower", "=", "0", ",", "upper", "=", "127", ")", ":", "for", "track", "in", "self", ".", "tracks", ":", "track", ".", "clip", "(", "lower", ",", "upper", ")" ]
Clip the pianorolls of all tracks by the given lower and upper bounds. Parameters ---------- lower : int or float The lower bound to clip the pianorolls. Defaults to 0. upper : int or float The upper bound to clip the pianorolls. Defaults to 127.
[ "Clip", "the", "pianorolls", "of", "all", "tracks", "by", "the", "given", "lower", "and", "upper", "bounds", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L255-L268
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_active_length
def get_active_length(self): """ Return the maximum active length (i.e., without trailing silence) among the pianorolls of all tracks. The unit is time step. Returns ------- active_length : int The maximum active length (i.e., without trailing silence) among ...
python
def get_active_length(self): """ Return the maximum active length (i.e., without trailing silence) among the pianorolls of all tracks. The unit is time step. Returns ------- active_length : int The maximum active length (i.e., without trailing silence) among ...
[ "def", "get_active_length", "(", "self", ")", ":", "active_length", "=", "0", "for", "track", "in", "self", ".", "tracks", ":", "now_length", "=", "track", ".", "get_active_length", "(", ")", "if", "active_length", "<", "track", ".", "get_active_length", "("...
Return the maximum active length (i.e., without trailing silence) among the pianorolls of all tracks. The unit is time step. Returns ------- active_length : int The maximum active length (i.e., without trailing silence) among the pianorolls of all tracks. The uni...
[ "Return", "the", "maximum", "active", "length", "(", "i", ".", "e", ".", "without", "trailing", "silence", ")", "among", "the", "pianorolls", "of", "all", "tracks", ".", "The", "unit", "is", "time", "step", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L282-L299
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_active_pitch_range
def get_active_pitch_range(self): """ Return the active pitch range of the pianorolls of all tracks as a tuple (lowest, highest). Returns ------- lowest : int The lowest active pitch among the pianorolls of all tracks. highest : int The lo...
python
def get_active_pitch_range(self): """ Return the active pitch range of the pianorolls of all tracks as a tuple (lowest, highest). Returns ------- lowest : int The lowest active pitch among the pianorolls of all tracks. highest : int The lo...
[ "def", "get_active_pitch_range", "(", "self", ")", ":", "lowest", ",", "highest", "=", "self", ".", "tracks", "[", "0", "]", ".", "get_active_pitch_range", "(", ")", "if", "len", "(", "self", ".", "tracks", ")", ">", "1", ":", "for", "track", "in", "...
Return the active pitch range of the pianorolls of all tracks as a tuple (lowest, highest). Returns ------- lowest : int The lowest active pitch among the pianorolls of all tracks. highest : int The lowest highest pitch among the pianorolls of all tracks.
[ "Return", "the", "active", "pitch", "range", "of", "the", "pianorolls", "of", "all", "tracks", "as", "a", "tuple", "(", "lowest", "highest", ")", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L301-L322
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_downbeat_steps
def get_downbeat_steps(self): """ Return the indices of time steps that contain downbeats. Returns ------- downbeat_steps : list The indices of time steps that contain downbeats. """ if self.downbeat is None: return [] downbeat_st...
python
def get_downbeat_steps(self): """ Return the indices of time steps that contain downbeats. Returns ------- downbeat_steps : list The indices of time steps that contain downbeats. """ if self.downbeat is None: return [] downbeat_st...
[ "def", "get_downbeat_steps", "(", "self", ")", ":", "if", "self", ".", "downbeat", "is", "None", ":", "return", "[", "]", "downbeat_steps", "=", "np", ".", "nonzero", "(", "self", ".", "downbeat", ")", "[", "0", "]", ".", "tolist", "(", ")", "return"...
Return the indices of time steps that contain downbeats. Returns ------- downbeat_steps : list The indices of time steps that contain downbeats.
[ "Return", "the", "indices", "of", "time", "steps", "that", "contain", "downbeats", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L324-L337
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_empty_tracks
def get_empty_tracks(self): """ Return the indices of tracks with empty pianorolls. Returns ------- empty_track_indices : list The indices of tracks with empty pianorolls. """ empty_track_indices = [idx for idx, track in enumerate(self.tracks) ...
python
def get_empty_tracks(self): """ Return the indices of tracks with empty pianorolls. Returns ------- empty_track_indices : list The indices of tracks with empty pianorolls. """ empty_track_indices = [idx for idx, track in enumerate(self.tracks) ...
[ "def", "get_empty_tracks", "(", "self", ")", ":", "empty_track_indices", "=", "[", "idx", "for", "idx", ",", "track", "in", "enumerate", "(", "self", ".", "tracks", ")", "if", "not", "np", ".", "any", "(", "track", ".", "pianoroll", ")", "]", "return",...
Return the indices of tracks with empty pianorolls. Returns ------- empty_track_indices : list The indices of tracks with empty pianorolls.
[ "Return", "the", "indices", "of", "tracks", "with", "empty", "pianorolls", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L339-L351
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_max_length
def get_max_length(self): """ Return the maximum length of the pianorolls along the time axis (in time step). Returns ------- max_length : int The maximum length of the pianorolls along the time axis (in time step). """ max_length...
python
def get_max_length(self): """ Return the maximum length of the pianorolls along the time axis (in time step). Returns ------- max_length : int The maximum length of the pianorolls along the time axis (in time step). """ max_length...
[ "def", "get_max_length", "(", "self", ")", ":", "max_length", "=", "0", "for", "track", "in", "self", ".", "tracks", ":", "if", "max_length", "<", "track", ".", "pianoroll", ".", "shape", "[", "0", "]", ":", "max_length", "=", "track", ".", "pianoroll"...
Return the maximum length of the pianorolls along the time axis (in time step). Returns ------- max_length : int The maximum length of the pianorolls along the time axis (in time step).
[ "Return", "the", "maximum", "length", "of", "the", "pianorolls", "along", "the", "time", "axis", "(", "in", "time", "step", ")", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L353-L369
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_merged_pianoroll
def get_merged_pianoroll(self, mode='sum'): """ Return the merged pianoroll. Parameters ---------- mode : {'sum', 'max', 'any'} A string that indicates the merging strategy to apply along the track axis. Default to 'sum'. - In 'sum' mode, the...
python
def get_merged_pianoroll(self, mode='sum'): """ Return the merged pianoroll. Parameters ---------- mode : {'sum', 'max', 'any'} A string that indicates the merging strategy to apply along the track axis. Default to 'sum'. - In 'sum' mode, the...
[ "def", "get_merged_pianoroll", "(", "self", ",", "mode", "=", "'sum'", ")", ":", "stacked", "=", "self", ".", "get_stacked_pianoroll", "(", ")", "if", "mode", "==", "'any'", ":", "merged", "=", "np", ".", "any", "(", "stacked", ",", "axis", "=", "2", ...
Return the merged pianoroll. Parameters ---------- mode : {'sum', 'max', 'any'} A string that indicates the merging strategy to apply along the track axis. Default to 'sum'. - In 'sum' mode, the merged pianoroll is the sum of all the pianorolls...
[ "Return", "the", "merged", "pianoroll", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L371-L407
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.get_stacked_pianoroll
def get_stacked_pianoroll(self): """ Return a stacked multitrack pianoroll. The shape of the return array is (n_time_steps, 128, n_tracks). Returns ------- stacked : np.ndarray, shape=(n_time_steps, 128, n_tracks) The stacked pianoroll. """ m...
python
def get_stacked_pianoroll(self): """ Return a stacked multitrack pianoroll. The shape of the return array is (n_time_steps, 128, n_tracks). Returns ------- stacked : np.ndarray, shape=(n_time_steps, 128, n_tracks) The stacked pianoroll. """ m...
[ "def", "get_stacked_pianoroll", "(", "self", ")", ":", "multitrack", "=", "deepcopy", "(", "self", ")", "multitrack", ".", "pad_to_same", "(", ")", "stacked", "=", "np", ".", "stack", "(", "[", "track", ".", "pianoroll", "for", "track", "in", "multitrack",...
Return a stacked multitrack pianoroll. The shape of the return array is (n_time_steps, 128, n_tracks). Returns ------- stacked : np.ndarray, shape=(n_time_steps, 128, n_tracks) The stacked pianoroll.
[ "Return", "a", "stacked", "multitrack", "pianoroll", ".", "The", "shape", "of", "the", "return", "array", "is", "(", "n_time_steps", "128", "n_tracks", ")", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L414-L428
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.load
def load(self, filename): """ Load a npz file. Supports only files previously saved by :meth:`pypianoroll.Multitrack.save`. Notes ----- Attribute values will all be overwritten. Parameters ---------- filename : str The name of the npz...
python
def load(self, filename): """ Load a npz file. Supports only files previously saved by :meth:`pypianoroll.Multitrack.save`. Notes ----- Attribute values will all be overwritten. Parameters ---------- filename : str The name of the npz...
[ "def", "load", "(", "self", ",", "filename", ")", ":", "def", "reconstruct_sparse", "(", "target_dict", ",", "name", ")", ":", "\"\"\"Return a reconstructed instance of `scipy.sparse.csc_matrix`.\"\"\"", "return", "csc_matrix", "(", "(", "target_dict", "[", "name", "+...
Load a npz file. Supports only files previously saved by :meth:`pypianoroll.Multitrack.save`. Notes ----- Attribute values will all be overwritten. Parameters ---------- filename : str The name of the npz file to be loaded.
[ "Load", "a", "npz", "file", ".", "Supports", "only", "files", "previously", "saved", "by", ":", "meth", ":", "pypianoroll", ".", "Multitrack", ".", "save", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L438-L484
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.merge_tracks
def merge_tracks(self, track_indices=None, mode='sum', program=0, is_drum=False, name='merged', remove_merged=False): """ Merge pianorolls of the tracks specified by `track_indices`. The merged track will have program number as given by `program` and drum indicator a...
python
def merge_tracks(self, track_indices=None, mode='sum', program=0, is_drum=False, name='merged', remove_merged=False): """ Merge pianorolls of the tracks specified by `track_indices`. The merged track will have program number as given by `program` and drum indicator a...
[ "def", "merge_tracks", "(", "self", ",", "track_indices", "=", "None", ",", "mode", "=", "'sum'", ",", "program", "=", "0", ",", "is_drum", "=", "False", ",", "name", "=", "'merged'", ",", "remove_merged", "=", "False", ")", ":", "if", "mode", "not", ...
Merge pianorolls of the tracks specified by `track_indices`. The merged track will have program number as given by `program` and drum indicator as given by `is_drum`. The merged track will be appended at the end of the track list. Parameters ---------- track_indices : li...
[ "Merge", "pianorolls", "of", "the", "tracks", "specified", "by", "track_indices", ".", "The", "merged", "track", "will", "have", "program", "number", "as", "given", "by", "program", "and", "drum", "indicator", "as", "given", "by", "is_drum", ".", "The", "mer...
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L486-L538
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.pad_to_same
def pad_to_same(self): """Pad shorter pianorolls with zeros at the end along the time axis to make the resulting pianoroll lengths the same as the maximum pianoroll length among all the tracks.""" max_length = self.get_max_length() for track in self.tracks: if track.p...
python
def pad_to_same(self): """Pad shorter pianorolls with zeros at the end along the time axis to make the resulting pianoroll lengths the same as the maximum pianoroll length among all the tracks.""" max_length = self.get_max_length() for track in self.tracks: if track.p...
[ "def", "pad_to_same", "(", "self", ")", ":", "max_length", "=", "self", ".", "get_max_length", "(", ")", "for", "track", "in", "self", ".", "tracks", ":", "if", "track", ".", "pianoroll", ".", "shape", "[", "0", "]", "<", "max_length", ":", "track", ...
Pad shorter pianorolls with zeros at the end along the time axis to make the resulting pianoroll lengths the same as the maximum pianoroll length among all the tracks.
[ "Pad", "shorter", "pianorolls", "with", "zeros", "at", "the", "end", "along", "the", "time", "axis", "to", "make", "the", "resulting", "pianoroll", "lengths", "the", "same", "as", "the", "maximum", "pianoroll", "length", "among", "all", "the", "tracks", "." ...
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L581-L588
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.parse_midi
def parse_midi(self, filename, **kwargs): """ Parse a MIDI file. Parameters ---------- filename : str The name of the MIDI file to be parsed. **kwargs: See :meth:`pypianoroll.Multitrack.parse_pretty_midi` for full documentation. ...
python
def parse_midi(self, filename, **kwargs): """ Parse a MIDI file. Parameters ---------- filename : str The name of the MIDI file to be parsed. **kwargs: See :meth:`pypianoroll.Multitrack.parse_pretty_midi` for full documentation. ...
[ "def", "parse_midi", "(", "self", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "pm", "=", "pretty_midi", ".", "PrettyMIDI", "(", "filename", ")", "self", ".", "parse_pretty_midi", "(", "pm", ",", "*", "*", "kwargs", ")" ]
Parse a MIDI file. Parameters ---------- filename : str The name of the MIDI file to be parsed. **kwargs: See :meth:`pypianoroll.Multitrack.parse_pretty_midi` for full documentation.
[ "Parse", "a", "MIDI", "file", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L590-L604
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.parse_pretty_midi
def parse_pretty_midi(self, pm, mode='max', algorithm='normal', binarized=False, skip_empty_tracks=True, collect_onsets_only=False, threshold=0, first_beat_time=None): """ Parse a :class:`pretty_midi.PrettyMIDI` object. The da...
python
def parse_pretty_midi(self, pm, mode='max', algorithm='normal', binarized=False, skip_empty_tracks=True, collect_onsets_only=False, threshold=0, first_beat_time=None): """ Parse a :class:`pretty_midi.PrettyMIDI` object. The da...
[ "def", "parse_pretty_midi", "(", "self", ",", "pm", ",", "mode", "=", "'max'", ",", "algorithm", "=", "'normal'", ",", "binarized", "=", "False", ",", "skip_empty_tracks", "=", "True", ",", "collect_onsets_only", "=", "False", ",", "threshold", "=", "0", "...
Parse a :class:`pretty_midi.PrettyMIDI` object. The data type of the resulting pianorolls is automatically determined (int if 'mode' is 'sum', np.uint8 if `mode` is 'max' and `binarized` is False, bool if `mode` is 'max' and `binarized` is True). Parameters ---------- pm...
[ "Parse", "a", ":", "class", ":", "pretty_midi", ".", "PrettyMIDI", "object", ".", "The", "data", "type", "of", "the", "resulting", "pianorolls", "is", "automatically", "determined", "(", "int", "if", "mode", "is", "sum", "np", ".", "uint8", "if", "mode", ...
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L606-L804
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.remove_tracks
def remove_tracks(self, track_indices): """ Remove tracks specified by `track_indices`. Parameters ---------- track_indices : list The indices of the tracks to be removed. """ if isinstance(track_indices, int): track_indices = [track_indi...
python
def remove_tracks(self, track_indices): """ Remove tracks specified by `track_indices`. Parameters ---------- track_indices : list The indices of the tracks to be removed. """ if isinstance(track_indices, int): track_indices = [track_indi...
[ "def", "remove_tracks", "(", "self", ",", "track_indices", ")", ":", "if", "isinstance", "(", "track_indices", ",", "int", ")", ":", "track_indices", "=", "[", "track_indices", "]", "self", ".", "tracks", "=", "[", "track", "for", "idx", ",", "track", "i...
Remove tracks specified by `track_indices`. Parameters ---------- track_indices : list The indices of the tracks to be removed.
[ "Remove", "tracks", "specified", "by", "track_indices", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L815-L828
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.save
def save(self, filename, compressed=True): """ Save the multitrack pianoroll to a (compressed) npz file, which can be later loaded by :meth:`pypianoroll.Multitrack.load`. Notes ----- To reduce the file size, the pianorolls are first converted to instances of scip...
python
def save(self, filename, compressed=True): """ Save the multitrack pianoroll to a (compressed) npz file, which can be later loaded by :meth:`pypianoroll.Multitrack.load`. Notes ----- To reduce the file size, the pianorolls are first converted to instances of scip...
[ "def", "save", "(", "self", ",", "filename", ",", "compressed", "=", "True", ")", ":", "def", "update_sparse", "(", "target_dict", ",", "sparse_matrix", ",", "name", ")", ":", "\"\"\"Turn `sparse_matrix` into a scipy.sparse.csc_matrix and update\n its component...
Save the multitrack pianoroll to a (compressed) npz file, which can be later loaded by :meth:`pypianoroll.Multitrack.load`. Notes ----- To reduce the file size, the pianorolls are first converted to instances of scipy.sparse.csc_matrix, whose component arrays are then collected ...
[ "Save", "the", "multitrack", "pianoroll", "to", "a", "(", "compressed", ")", "npz", "file", "which", "can", "be", "later", "loaded", "by", ":", "meth", ":", "pypianoroll", ".", "Multitrack", ".", "load", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L830-L884
salu133445/pypianoroll
pypianoroll/multitrack.py
Multitrack.to_pretty_midi
def to_pretty_midi(self, constant_tempo=None, constant_velocity=100): """ Convert to a :class:`pretty_midi.PrettyMIDI` instance. Notes ----- - Only constant tempo is supported by now. - The velocities of the converted pianorolls are clipped to [0, 127], i.e. va...
python
def to_pretty_midi(self, constant_tempo=None, constant_velocity=100): """ Convert to a :class:`pretty_midi.PrettyMIDI` instance. Notes ----- - Only constant tempo is supported by now. - The velocities of the converted pianorolls are clipped to [0, 127], i.e. va...
[ "def", "to_pretty_midi", "(", "self", ",", "constant_tempo", "=", "None", ",", "constant_velocity", "=", "100", ")", ":", "self", ".", "check_validity", "(", ")", "pm", "=", "pretty_midi", ".", "PrettyMIDI", "(", "initial_tempo", "=", "self", ".", "tempo", ...
Convert to a :class:`pretty_midi.PrettyMIDI` instance. Notes ----- - Only constant tempo is supported by now. - The velocities of the converted pianorolls are clipped to [0, 127], i.e. values below 0 and values beyond 127 are replaced by 127 and 0, respectively. ...
[ "Convert", "to", "a", ":", "class", ":", "pretty_midi", ".", "PrettyMIDI", "instance", "." ]
train
https://github.com/salu133445/pypianoroll/blob/6224dc1e29222de2124d249acb80f3d072166917/pypianoroll/multitrack.py#L886-L952