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 / 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 September 20, 2023 13:05
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 ..
@fepegar
fepegar / ucl-cluster.md
Last active June 14, 2019 16:26
How to mount the cluster on a local directory on Linux

Locally

ssh-keygen -t rsa -b 4096 -C "[email protected]"  # generate the SSH key
xclip -sel clip < ~/.ssh/id_rsa.pub  # send the key to che clipboard
ssh [email protected]  # SSH to storm
ssh-add

On storm

[Add the previous key to ~/.ssh/authorized_keys], then

@fepegar
fepegar / acpc.py
Last active July 4, 2021 13:06
3D Slicer code to create an ACPC transform
import numpy as np
import SampleData
def getSampleVolume():
# Download MRHead
sampleDataLogic = SampleData.SampleDataLogic()
volumeNode = sampleDataLogic.downloadMRHead()
return volumeNode
@fepegar
fepegar / unet-constraints.ipynb
Last active April 11, 2024 06:30
Understanding U-Net shape constraints
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.