This file contains 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
def rescale_predictions_moons(prediction, moon_test, prediction_min=0.001, prediction_max = 0.999): | |
"""Rescale all predictions between prediction_min and prediction_max | |
keeping the same ranking within each moon. | |
Rescaling is necessary to avoid invalid submissions having | |
predictions < 0.0 or > 1.0. | |
This file contains 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 argparse | |
import nibabel as nib | |
from nibabel.streamlines import Field | |
from nibabel.orientations import aff2axcodes | |
def build_argparser(): | |
DESCRIPTION = "Convert tractograms (TCK -> TRK)." |
This file contains 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 argparse | |
import nibabel as nib | |
from nibabel.streamlines import Field | |
from nibabel.orientations import aff2axcodes | |
def build_argparser(): | |
DESCRIPTION = "Convert tractograms (TCK -> TRK)." |
This file contains 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
cabal build | |
Building git-annex-7.20190507... | |
Preprocessing executable 'git-annex' for git-annex-7.20190507... | |
[379 of 612] Compiling Remote.S3 ( Remote/S3.hs, dist/build/git-annex/git-annex-tmp/Remote/S3.o ) | |
Remote/S3.hs:462:33: error: | |
Not in scope: ‘S3.getBucketObjectVersions’ | |
Module ‘Aws.S3’ does not export ‘getBucketObjectVersions’. | |
Remote/S3.hs:480:19: error: |
This file contains 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
#!/usr/bin/env python3 | |
# from: https://stackoverflow.com/questions/53477624/python-pil-image-convert-not-replacing-color-with-the-closest-palette | |
import subprocess | |
import numpy as np | |
from PIL import Image | |
palette = [ | |
0,0,0, |
This file contains 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
""" | |
N-D Bresenham line algo , from http://code.activestate.com/recipes/578112-bresenhams-line-algorithm-in-n-dimensions/ | |
""" | |
import numpy as np | |
def _bresenhamline_nslope(slope): | |
""" | |
Normalize slope for Bresenham's line algorithm. | |
>>> s = np.array([[-2, -2, -2, 0]]) | |
>>> _bresenhamline_nslope(s) |
This file contains 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 nibabel import trackvis | |
from dipy.tracking.metrics import length | |
def load_tractome_tractography(filename_tractography): | |
""" | |
Load trk tractography following nasty (i.e. to be fixed) tractome | |
convention, i.e. removing short streamlines first. | |
See: | |
https://github.com/FBK-NILab/tractome/issues/17 |
This file contains 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
"""Statistical tests for multiclass pattern discrimination. | |
Confusion matrices from ICANN2011 MEG competition. | |
See http://www.cis.hut.fi/icann2011/meg/megicann_proceedings.pdf | |
p.14 | |
""" | |
import numpy as np | |
from scipy.special import gammaln | |
from scipy.stats import binom |
This file contains 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 scipy.special import gammaln | |
def log_multivariate_polya(X, alpha): | |
N = X.sum() | |
A = alpha.sum() | |
log_likelihood = gammaln(N+1) - gammaln(X+1).sum() | |
log_likelihood += gammaln(A) - gammaln(alpha).sum() | |
log_likelihood += gammaln(X + alpha).sum() - gammaln(N + A) | |
return log_likelihood |