Skip to content

Instantly share code, notes, and snippets.

View MrBago's full-sized avatar

Bago Amirbekian MrBago

View GitHub Profile
@MrBago
MrBago / alias table timings.ipynb
Last active November 7, 2023 23:47
Notebook with timings for alias table db operations
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MrBago
MrBago / Test OutStream performance.ipynb
Last active March 25, 2022 17:23
Notebook to test performance of OutStream (stdout & print)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MrBago
MrBago / simplePyMod.py
Created November 17, 2017 23:51
A simple python module
data = "some data"
def aFunction():
pass
class BaseInterface:
"""An interface implements a specific processing task. We can use existing
the interfaces and related machinery in Nipype.
"""
inputSpec = None
outputSpec = None
def run(self, **inputs):
pass
"""This is a rough version of a workflow to download data, run bet and compute brain volumes.
"""
import os
import numpy as np
import nibabel as nib
import mintlabs
from traits.api import File, String, Int
from nipype.interfaces.base import (BaseInterfaceInputSpec, TraitedSpec,
@MrBago
MrBago / fs_keys.p
Last active December 25, 2016 22:08
msd response function
(dp1
S'cerebellum'
p2
cnumpy.core.multiarray
_reconstruct
p3
(cnumpy
ndarray
p4
(I0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MrBago
MrBago / dti_diff.py
Created May 17, 2016 21:29
Get voxelwise diff between data and DTI model predict
#!/usr/bin/env python
from dipy.reconst.dti import TensorModel
from dipy.data import read_stanford_labels
img, gtab, labels = read_stanford_labels()
data = img.get_data()
mask = labels.get_data() == 1
model = TensorModel(gtab)
fit = model.fit(data, mask)
@MrBago
MrBago / changebasis.py
Created June 17, 2015 20:43
Convert dipy basis to mrtrix2 basis
import numpy as np
from dipy.reconst import shm
from dipy.data import default_sphere
theta, phi = default_sphere.theta, default_sphere.phi
sh_order = 6
B_dipy, m_dipy, n_dipy = shm.real_sym_sh_basis(sh_order, theta, phi)
B_mrtrix, m_mrtrix, n_mrtrix = shm.real_sym_sh_mrtrix(sh_order, theta, phi)
n_coeff = len(n_dipy)
@MrBago
MrBago / boot_dg.py
Created June 4, 2015 21:59
Bootstrap and Direction Getter
from warnings import warn
import numpy as np
from dipy.reconst import shm
from dipy.core.geometry import cart2sphere
from dipy.tracking.local.interpolation import trilinear_interpolate4d
import nibabel as nib
from dipy.data import default_sphere