This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Levenshtein import editops | |
def match_list(A, B, on_replace="delete"): | |
"""Match two lists of different sizes and return corresponding indice | |
Parameters | |
---------- | |
A: list | array, shape (n,) | |
The values of the first list | |
B: list | array: shape (m, ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy.linalg import multi_dot | |
from scipy.linalg import svd | |
from sklearn.linear_model import RidgeCV | |
from sklearn.model_selection import KFold | |
def get_from_indices(X, indices): | |
out = np.zeros_like(X[0]) | |
for idx in np.unique(indices): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import urllib.request | |
import subprocess | |
import pandas as pd # pip install pandas | |
import betterbib # pip install betterbib | |
import bibtexparser # pip install bibtexparser | |
from bibtexparser.bparser import BibTexParser | |
def fix_duplicated_entries(lines): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Time2v2(): | |
def __init__(self, metric='cosine', scale=True, to=None): | |
self.metric = metric | |
self.to = to | |
self.scale = scale | |
def __call__(self, y_true, y_pred): | |
from torch.nn import CosineSimilarity | |
from numpy.random import permutation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.metrics import pairwise_distances | |
from numpy.random import permutation | |
from time import time | |
def cc_2v2(true, pred, metric="cosine"): | |
assert len(true) == len(pred) | |
ns = len(true) | |
first = permutation(ns) # first group of TR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import numpy as np | |
import mne | |
import nibabel as nib | |
import matplotlib.pyplot as plt | |
def split_parc(xyz, label, n, axis='y'): | |
axes = dict(x=0, y=1, z=2) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
fig, axes = plt.subplots(6, 1, sharex=True, sharey=True, figsize=[4, 6]) | |
np.random.seed(1) | |
hypotheses = ( | |
('No Similarity', np.random.randn(5)/1e1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numba import jit | |
@jit | |
def fast_auc(ytrue_sorted): | |
nfalse = np.zeros(ytrue_sorted.shape[1:]) | |
auc = np.zeros(ytrue_sorted.shape[1:]) | |
n = len(ytrue_sorted) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.colors import ListedColormap | |
import colorcet | |
import numpy as np | |
ice_fire = np.vstack([ | |
colorcet.cm.fire(np.linspace(1, 0, 127))[:, [2, 1, 0, 3]], | |
colorcet.cm.fire(np.linspace(0, 1, 127)) | |
]) | |
ice_fire = ListedColormap(ice_fire) | |
fire = colorcet.cm.fire(np.linspace(0, 1, 127)) |