Skip to content

Commit

Permalink
trying to fix fixing stats again
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronearlerichardson committed Mar 13, 2024
1 parent 07fc825 commit 9f0c7d0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ieeg/calc/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,8 @@ def tail_compare(diff: np.ndarray | float | int,


def shuffle_test(sig1: np.ndarray, sig2: np.ndarray, n_perm: int = 1000,
axis: int = 0, func: callable = mean_diff, seed: int = None
) -> np.ndarray:
axis: int = 0, func: callable = mean_diff, seed: int = None,
n_jobs: int = -3) -> np.ndarray:
"""Time permutation shuffle test between two set of observations.
The test is performed by shuffling the trials and calculating the test
Expand All @@ -745,6 +745,9 @@ def shuffle_test(sig1: np.ndarray, sig2: np.ndarray, n_perm: int = 1000,
axis keyword input to denote observations (trials, for example).
seed : int, optional
The seed for the random number generator.
n_jobs : int, optional
The number of jobs to run in parallel. Only used if the permutation
test will exceed memory. Default is -3.
Returns
-------
Expand Down Expand Up @@ -789,7 +792,7 @@ def _shuffle_test(idx_1, idx_2):
return func(fake_sig1, fake_sig2, axis=axis)

diff = np.zeros((n_perm, *shape[:axis], *shape[axis + 1:]))
proc = Parallel(n_jobs=-2, verbose=40)(delayed(_shuffle_test)(
proc = Parallel(n_jobs=n_jobs, verbose=40)(delayed(_shuffle_test)(
idx1[i], idx2[i]) for i in range(n_perm))
for i, out in enumerate(proc):
diff[i] = out
Expand Down

0 comments on commit 9f0c7d0

Please sign in to comment.