Skip to content

Instantly share code, notes, and snippets.

View anibalsolon's full-sized avatar
🕷️

Anibal Sólon anibalsolon

🕷️
View GitHub Profile
@anibalsolon
anibalsolon / nrrd2nifti.py
Last active October 7, 2021 00:50
NRRD segmentation to Nifti using Slicer Python API
"""
Usage:
Slicer --python-script nrrd2nifti.py --no-splash --no-main-window -- Segmentation.seg.nrrd
"""
import os
import sys
if len(sys.argv) == 1:
This file has been truncated, but you can view the full file.
- anat: s3://fcp-indi/data/Projects/ABIDE/RawDataBIDS/CMU_a/sub-0050642/anat/sub-0050642_T1w.nii.gz
creds_path: null
func:
rest_run-1:
scan: s3://fcp-indi/data/Projects/ABIDE/RawDataBIDS/CMU_a/sub-0050642/func/sub-0050642_task-rest_run-1_bold.nii.gz
scan_parameters:
AcquisitionDuration: !!binary |
ODowNg==
AcquisitionMatrix: !!binary |
NjR4NjQ=
@anibalsolon
anibalsolon / audio.py
Last active February 19, 2020 02:25
Listening to audio on Jupyter notebooks
import io
import base64
import numpy as np
from IPython.core.display import HTML
from scipy.io import loadmat, wavfile
data = loadmat('./sounds.mat')['sounds']
test = loadmat('./icaTest.mat')
def player(wave, bitrate=11025):
@anibalsolon
anibalsolon / data.py
Last active February 3, 2020 21:01
MNIST Reader
# DOWNLOAD:
# curl -O http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
# curl -O http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
# curl -O http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
# curl -O http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
# USAGE:
# TrD = TrainData() # or TestData
# X, y = TrD[0:1000] # get first 1000 images
# X, y = TrD[:] # get 'em all
def anicor(matrix1, matrix2):
d1 = matrix1.shape[-1]
d2 = matrix2.shape[-1]
def zscore(data, axis):
data -= data.mean(axis=axis,keepdims=True)
data /= data.std(axis=axis,keepdims=True)
return np.nan_to_num(data, copy=False)
assert d1 == d2
@anibalsolon
anibalsolon / aws.sh
Created June 19, 2018 20:15
Instance profile w/ role to access all S3 buckets
#!/bin/bash
echo '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "ec2.amazonaws.com"},
"Action": "sts:AssumeRole"
}
@anibalsolon
anibalsolon / recursion_and_sublists.py
Last active April 30, 2017 22:36
Faça uma função recursiva em Python que recebe uma lista L e retorna uma lista composta por todas as sublistas de L.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def compositions(l, init=None):
# Use init argument or
# start an empty list (for the first list)
init = init or []