Skip to content

Commit 80b5560

Browse files
committed
autopep8 ran
1 parent eb36163 commit 80b5560

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

src/scilpy/cli/scil_connectivity_functional_graph_measures.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ def _build_arg_parser():
5858
help='Input fonctional connectivity matrix (.npy).')
5959
p.add_argument('out_json',
6060
help='Path of the output json.')
61-
p.add_argument('--conn_threshold', type=float, default=0.25,
62-
help='Threshold for the functional connectivity values. All values \n'
63-
'lower or equal to will be set to zero. (default: 0.25)')
61+
p.add_argument(
62+
'--conn_threshold',
63+
type=float,
64+
default=0.25,
65+
help='Threshold for the functional connectivity values. All values \n'
66+
'lower or equal to will be set to zero. (default: 0.25)')
6467
p.add_argument('--filtering_mask',
6568
help='Binary filtering mask to apply before computing the '
6669
'measures.')
@@ -89,7 +92,7 @@ def main():
8992
else:
9093
logging.info('Using --append_json, make sure to delete {} '
9194
'before re-launching a group analysis.'.format(
92-
args.out_json))
95+
args.out_json))
9396

9497
if args.append_json and args.overwrite:
9598
parser.error('Cannot use the append option at the same time as '
@@ -99,11 +102,12 @@ def main():
99102
conn_matrix = load_matrix_in_any_format(args.in_conn_matrix)
100103

101104
if args.filtering_mask:
102-
mask_matrix = load_matrix_in_any_format(args.filtering_mask).astype(bool)
105+
mask_matrix = load_matrix_in_any_format(
106+
args.filtering_mask).astype(bool)
103107
conn_matrix *= mask_matrix
104108

105-
gtm_dict = evaluate_functional_graph_measures(conn_matrix, args.conn_threshold,
106-
args.avg_node_wise)
109+
gtm_dict = evaluate_functional_graph_measures(
110+
conn_matrix, args.conn_threshold, args.avg_node_wise)
107111

108112
if os.path.isfile(args.out_json) and args.append_json:
109113
with open(args.out_json) as json_data:

src/scilpy/cli/scil_connectivity_structural_graph_measures.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _build_arg_parser():
6060
p.add_argument('out_json',
6161
help='Path of the output json.')
6262

63-
p.add_argument('--length_matrix',
63+
p.add_argument('--length_matrix',
6464
help='Input length-weighted matrix (.npy).')
6565
p.add_argument('--filtering_mask',
6666
help='Binary filtering mask to apply before computing the '
@@ -93,7 +93,7 @@ def main():
9393
else:
9494
logging.info('Using --append_json, make sure to delete {} '
9595
'before re-launching a group analysis.'.format(
96-
args.out_json))
96+
args.out_json))
9797

9898
if args.append_json and args.overwrite:
9999
parser.error('Cannot use the append option at the same time as '
@@ -102,20 +102,21 @@ def main():
102102

103103
conn_matrix = load_matrix_in_any_format(args.in_conn_matrix)
104104
len_matrix = None
105-
105+
106106
if args.length_matrix:
107107
len_matrix = load_matrix_in_any_format(args.length_matrix)
108108

109109
if args.filtering_mask:
110-
mask_matrix = load_matrix_in_any_format(args.filtering_mask).astype(bool)
110+
mask_matrix = load_matrix_in_any_format(
111+
args.filtering_mask).astype(bool)
111112
conn_matrix *= mask_matrix
112-
113+
113114
if args.length_matrix:
114115
len_matrix *= mask_matrix
115116

116117
if len_matrix is None:
117118
print("Warning: No length-weighted matrix provided. ")
118-
119+
119120
gtm_dict = evaluate_graph_measures(conn_matrix, len_matrix,
120121
args.avg_node_wise, args.small_world)
121122

src/scilpy/connectivity/matrix_tools.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def evaluate_functional_graph_measures(conn_matrix, conn_threshold,
8383
Parameters
8484
----------
8585
conn_matrix: np.ndarray
86-
2D matrix of functional connectivity weights
86+
2D matrix of functional connectivity weights
8787
conn_threshold: float
8888
2D matrix of bundle lengths.
8989
avg_node_wise: bool
@@ -114,11 +114,12 @@ def list_cast(_input):
114114
Wp = np.copy(conn_matrix)
115115
Wp = np.abs(conn_matrix)
116116
Wp[Wp <= conn_threshold] = 0
117-
117+
118118
gtm_dict = {}
119119
ci, gtm_dict['modularity'] = bct.modularity_louvain_und(Wp, seed=0)
120120
gtm_dict['assortativity'] = bct.assortativity_wei(Wp, flag=0)
121-
gtm_dict['participation'] = func_cast(bct.participation_coef_sign(Wp, ci)[0])
121+
gtm_dict['participation'] = func_cast(
122+
bct.participation_coef_sign(Wp, ci)[0])
122123
gtm_dict['clustering'] = func_cast(bct.clustering_coef_wu(Wp))
123124

124125
gtm_dict['nodal_strength'] = func_cast(bct.strengths_und(Wp))
@@ -127,7 +128,7 @@ def list_cast(_input):
127128
# Rich club always gives an error for the matrix rank and gives NaN
128129
with warnings.catch_warnings():
129130
warnings.simplefilter("ignore")
130-
tmp_rich_club = bct.rich_club_wu(Wp)
131+
tmp_rich_club = bct.rich_club_wu(Wp)
131132
gtm_dict['rich_club'] = func_cast(tmp_rich_club[~np.isnan(tmp_rich_club)])
132133

133134
return gtm_dict
@@ -170,12 +171,14 @@ def list_cast(_input):
170171

171172
gtm_dict = {}
172173

173-
if len_matrix is not None :
174-
betweenness_centrality = bct.betweenness_wei(len_matrix) / ((N-1)*(N-2))
174+
if len_matrix is not None:
175+
betweenness_centrality = bct.betweenness_wei(
176+
len_matrix) / ((N - 1) * (N - 2))
175177
gtm_dict['betweenness_centrality'] = func_cast(betweenness_centrality)
176-
gtm_dict['local_efficiency'] = func_cast(bct.efficiency_wei(len_matrix,
177-
local=True))
178-
gtm_dict['global_efficiency'] = func_cast(bct.efficiency_wei(len_matrix))
178+
gtm_dict['local_efficiency'] = func_cast(
179+
bct.efficiency_wei(len_matrix, local=True))
180+
gtm_dict['global_efficiency'] = func_cast(
181+
bct.efficiency_wei(len_matrix))
179182

180183
# Path length gives an infinite distance for unconnected nodes
181184
# All of this is simply to fix that
@@ -193,12 +196,9 @@ def list_cast(_input):
193196
gtm_dict['path_length'].insert(i, -1)
194197
gtm_dict['edge_count'].insert(i, -1)
195198

196-
197199
if small_world:
198200
gtm_dict['omega'], gtm_dict['sigma'] = omega_sigma(len_matrix)
199201

200-
201-
202202
ci, gtm_dict['modularity'] = bct.modularity_louvain_und(conn_matrix,
203203
seed=0)
204204
gtm_dict['assortativity'] = bct.assortativity_wei(conn_matrix,

0 commit comments

Comments
 (0)