Skip to content

Commit d2f61ee

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4211e0b commit d2f61ee

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

nigsp/io.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ def check_mtx_dim(fname, data, shape=None):
162162
raise ValueError(f"{fname} is empty!")
163163
if data.ndim > 3:
164164
raise NotImplementedError(
165-
"Only matrices up to 3D are supported, but "
166-
f"given matrix is {data.ndim}D."
165+
f"Only matrices up to 3D are supported, but given matrix is {data.ndim}D."
167166
)
168167
if shape is not None:
169168
if data.ndim > 2:
@@ -176,8 +175,7 @@ def check_mtx_dim(fname, data, shape=None):
176175
)
177176
if shape == "square" and data.shape[0] != data.shape[1]:
178177
raise ValueError(
179-
f"Square matrix required, but {fname} matrix has "
180-
f"shape {data.shape}."
178+
f"Square matrix required, but {fname} matrix has shape {data.shape}."
181179
)
182180

183181
return data

nigsp/operations/nifti.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ def apply_mask(data, mask):
100100
f"with shape {mask.shape}"
101101
)
102102
if (data.ndim - mask.ndim) > 1:
103-
LGR.warning(f"Returning volume with {data.ndim-mask.ndim+1} dimensions.")
103+
LGR.warning(f"Returning volume with {data.ndim - mask.ndim + 1} dimensions.")
104104
else:
105-
LGR.info(f"Returning {data.ndim-mask.ndim+1}D array.")
105+
LGR.info(f"Returning {data.ndim - mask.ndim + 1}D array.")
106106

107107
mask = mask != 0
108108
return data[mask]
@@ -149,8 +149,7 @@ def unmask(data, mask, shape=None, asdata=None):
149149

150150
if shape[: mask.ndim] != mask.shape:
151151
raise ValueError(
152-
f"Cannot unmask data into shape {shape} using mask "
153-
f"with shape {mask.shape}"
152+
f"Cannot unmask data into shape {shape} using mask with shape {mask.shape}"
154153
)
155154
if data.ndim > 1 and (data.shape[0] != mask.sum()):
156155
raise ValueError(
@@ -216,10 +215,10 @@ def apply_atlas(data, atlas, mask=None):
216215
f"with shape {data.shape}"
217216
)
218217
if (data.ndim - atlas.ndim) > 1:
219-
LGR.warning(f"returning volume with {data.ndim-atlas.ndim+1} dimensions.")
218+
LGR.warning(f"returning volume with {data.ndim - atlas.ndim + 1} dimensions.")
220219
else:
221220
LGR.info(
222-
f"Returning {data.ndim-atlas.ndim+1}D array of signal averages "
221+
f"Returning {data.ndim - atlas.ndim + 1}D array of signal averages "
223222
f"in atlas {atlas}."
224223
)
225224

@@ -297,7 +296,9 @@ def unfold_atlas(data, atlas, mask=None):
297296
f"with {len(labels)} parcels"
298297
)
299298

300-
LGR.info(f"Unmasking data into atlas-like volume of {3+data.ndim-1} dimensions.")
299+
LGR.info(
300+
f"Unmasking data into atlas-like volume of {3 + data.ndim - 1} dimensions."
301+
)
301302
out = np.zeros_like(atlas, dtype="float32")
302303

303304
for ax in range(1, data.ndim):

nigsp/operations/surrogates.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def test_significance(
299299
raise ValueError(
300300
"Provided empirical data and surrogate data shapes "
301301
f"do not agree, with shapes {data.shape} and "
302-
f"{surr.shape[:data.ndim]} (last axis excluded)"
302+
f"{surr.shape[: data.ndim]} (last axis excluded)"
303303
)
304304
if not (surr[..., -1] == data).all():
305305
# Check that data was not appended yet.
@@ -332,16 +332,16 @@ def test_significance(
332332
LGR.info(f"Adopting {method} testing method.")
333333
# Testing both tails requires to split p
334334
if method == "frequentist":
335-
LGR.info(f"Testing for p={p} two-tails (p={p/2} each tail)")
335+
LGR.info(f"Testing for p={p} two-tails (p={p / 2} each tail)")
336336
p = p / 2
337337
# If there aren't enough surrogates, send a warning message on the real p
338338
# Then update p
339339
if 1 / surr.shape[-1] > p:
340340
LGR.warning(
341341
"The generated surrogates are not enough to test for "
342-
f"the selected p ({p*2} two-tails), since at least "
343-
f"{ceil(1/p)-1} surrogates are required for the selected "
344-
f"p value. Testing for p={1/surr.shape[-1]} two-tails instead."
342+
f"the selected p ({p * 2} two-tails), since at least "
343+
f"{ceil(1 / p) - 1} surrogates are required for the selected "
344+
f"p value. Testing for p={1 / surr.shape[-1]} two-tails instead."
345345
)
346346
p = 1 / surr.shape[-1]
347347

@@ -355,7 +355,7 @@ def test_significance(
355355
LGR.warning(
356356
"The provided subjects are not enough to test for "
357357
f"p={p_bernoulli} one-tail at the group level, since "
358-
f"at least {ceil(1/p_bernoulli)} subjects are required."
358+
f"at least {ceil(1 / p_bernoulli)} subjects are required."
359359
)
360360
p_bernoulli = 1 / surr.shape[1]
361361
# If there aren't enough surrogates, send a warning message on the real p
@@ -364,13 +364,13 @@ def test_significance(
364364
LGR.warning(
365365
"The generated surrogates are not enough to test for "
366366
f"p={p} two-tails at the subject level. "
367-
f"{ceil(1/p)-1} surrogates are required for p={p}."
367+
f"{ceil(1 / p) - 1} surrogates are required for p={p}."
368368
)
369369
p = 1 / surr.shape[-1]
370370

371371
LGR.info(
372372
f"Testing for p={p_bernoulli} one-tail at the group level and "
373-
f"at p={p*2} two-tails (p={p} each tail) at the subject level."
373+
f"at p={p * 2} two-tails (p={p} each tail) at the subject level."
374374
)
375375
else:
376376
raise NotImplementedError(

nigsp/operations/timeseries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def median_cutoff_frequency_idx(energy):
328328
if energy.ndim == 2:
329329
energy = energy.mean(axis=-1)
330330
half_tot_auc = _trapezoid_compat(energy, axis=0) / 2
331-
LGR.debug(f"Total AUC = {half_tot_auc*2}, targeting half of total AUC")
331+
LGR.debug(f"Total AUC = {half_tot_auc * 2}, targeting half of total AUC")
332332

333333
# Compute the AUC from first to one to last frequency,
334334
# skipping first component because AUC(1)=0.
@@ -395,7 +395,7 @@ def graph_filter(timeseries, eigenvec, freq_idx, keys=["low", "high"]): # noqa:
395395
f"eigenvector matrix of shape {eigenvec.shape}."
396396
)
397397

398-
LGR.info(f"Splitting graph into {len(freq_idx)+1} parts")
398+
LGR.info(f"Splitting graph into {len(freq_idx) + 1} parts")
399399

400400
# Check that there is the right amount of keys
401401
if len(keys) > len(freq_idx) + 1:
@@ -413,7 +413,7 @@ def graph_filter(timeseries, eigenvec, freq_idx, keys=["low", "high"]): # noqa:
413413
)
414414

415415
for i in range(len(keys), len(freq_idx) + 1):
416-
keys = keys + [f"key-{i+1:03d}"]
416+
keys = keys + [f"key-{i + 1:03d}"]
417417

418418
# Add 0 and None to freq_idx to have full indexes
419419
freq_idx = [0] + freq_idx + [None]

0 commit comments

Comments
 (0)