Skip to content

Instantly share code, notes, and snippets.

View fepegar's full-sized avatar

Fernando Pérez-García fepegar

View GitHub Profile
@fepegar
fepegar / test-label-sampler.ipynb
Created February 10, 2021 15:52
Test label sampler.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from pathlib import Path
import torch
import torchvision
import numpy as np
from PIL import Image
import torchio as tio
from tqdm import trange
output_dir = Path('/tmp/transformed')
@fepegar
fepegar / SITK_PT.ipynb
Last active October 20, 2020 21:28
Possible bug in SimpleITK or in PyTorch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fepegar
fepegar / parcellation_slicer.py
Created October 1, 2020 18:36
Run a brain parcellation deep learning model within 3D Slicer
# Paste this code into the Slicer Python console
pip_install('highresnet')
import SampleData
from highresnet.inference import infer
from highresnet.cli.download_oasis import download_oasis
input_path = download_oasis()
loadVolume(input_path)
@fepegar
fepegar / functions.py
Created June 24, 2020 14:49
Functions for experimental TorchIO notebooks
import numpy as np
import matplotlib.pyplot as plt
def fourier_transform(array: np.ndarray):
transformed = np.fft.fftn(array)
fshift = np.fft.fftshift(transformed)
return fshift
def inv_fourier_transform(fshift: np.ndarray):
f_ishift = np.fft.ifftshift(fshift)
import tempfile
from pathlib import Path
from subprocess import call
# pip install moviepy opencv-python scikit-image face_recognition
import cv2
import numpy as np
from PIL import Image
from tqdm import tqdm
@fepegar
fepegar / B-spline deformation.ipynb
Last active May 25, 2025 12:54
b723d15de620cd2a3a4dbd71e491b59d
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fepegar
fepegar / build_blockmatching.sh
Last active January 30, 2019 14:13
Blockmatching INRIA
# Last modified on the 14th of May, 2018
mkdir -p ~/git
cd ~/git
# Replace fepegar by your username on Inria Forge. You’ll be asked your password
user="fepegar"
# To clone the master branch:
git clone https://[email protected]/authscm/$user/git/morpheme-privat/morpheme-privat.git --depth 1
# Install zlib1g-dev if Linux
@fepegar
fepegar / install_niftyreg.sh
Last active October 16, 2024 14:02
Install NiftyReg
mkdir -p $HOME/git
cd $HOME/git
git clone https://github.com/KCL-BMEIS/niftyreg.git --depth 1
cd niftyreg
mkdir build install
cd build
# This gave me trouble on a DGX
## If cmake is run just once, make may not work. Might be related to https://stackoverflow.com/q/47684410/3956024
#cmake -DCMAKE_INSTALL_PREFIX:STRING=../install -DUSE_CUDA:BOOL=ON -DCMAKE_C_COMPILER:STRING=/usr/bin/gcc-6 ..