Skip to content

Commit d9580da

Browse files
committed
Handling of flip being an int
1 parent 7ae37e5 commit d9580da

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

mne/source_estimate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3383,8 +3383,12 @@ def _pca_flip(flip, data):
33833383
result = data.mean(axis=0) # Trivial accumulator
33843384
else:
33853385
U, s, V = _safe_svd(data, full_matrices=False)
3386-
# determine sign-flip
3387-
sign = np.sign(np.dot(U[:, 0], flip))
3386+
# determine sign-flip.
3387+
# if flip is a mere int, multiply U and sum
3388+
if isinstance(flip, int):
3389+
sign = np.sign((flip * U[:, 0]).sum())
3390+
else:
3391+
sign = np.sign(np.dot(U[:, 0], flip))
33883392
# use average power in label for scaling
33893393
scale = np.linalg.norm(s) / np.sqrt(len(data))
33903394
result = sign * scale * V[0]

0 commit comments

Comments
 (0)