Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Franco Matzkin vfmatzkin

🏠
Working from home
View GitHub Profile
@vfmatzkin
vfmatzkin / antspy.py
Created Mar 16, 2021
I can't believe ANTs is that good in Python
View antspy.py
# Script written by Franco Matzkin (with the great help of this amazing tool)
# Install ANTsPy with:
# pip install antspyx
# (I'm not sure this is the last version).
import ants
moving_ct_path = 'imgs/CTimage.nii.gz'
moving_mask_path = 'imgs/CT_brain_mask.nii.gz'
fixed_ct_path = 'imgs/Atlas.nii.gz'
@vfmatzkin
vfmatzkin / fsl_registration.py
Last active Mar 15, 2021
FSL FLIRT Registration with Python & SimpleITK
View fsl_registration.py
# Created by Franco Matzkin (vfmatzkin [at] gmail.com)
# This gist gives a basic intuition on how to use tmp files to run FSL's FLIRT
# commands with Python and use those images with the help of SimpleITK.
# Info on how to install FLIRT: https://gist.github.com/vfmatzkin/7987a6edf034d28427696e1fabbb2979 #noqa
import os
import shutil
import tempfile
View some_noises.py
def salt_and_pepper(img, noise_probability=1, noise_density=0.2, salt_ratio=0.1):
"""
Given a numpy image, return a salt and pepper noised image.
:param img: Image in which noise will be added. The first dimension will be taken as the batch element index.
:param noise_probability: Probability of adding the noise (by default 1).
:param noise_density: Amount of noise in the image (as a percentage).
:param salt_ratio: Ratio of salt (vs pepper) added in the image.
:return: Noised batch of images.
"""
@vfmatzkin
vfmatzkin / inverse-parammap-simpleelastix.py
Created Jan 19, 2021
Inverse parametermap calculation using SimpleElastix (SimpleITK extension)
View inverse-parammap-simpleelastix.py
# This gist is a portion of a code that doesn't work. Right now, since I
# cant use SimpleElastix easily, I switched to FSL for registration,
# which has a CLI.
import SimpleITK as sitk
import os
# Inverse parametermap calculation. It gives a SIGSEV error. Check updates in
# SimpleElastix and see if it's solved.
# https://github.com/SuperElastix/SimpleElastix/issues/167
@vfmatzkin
vfmatzkin / fsl-installation-in-google-colab.ipynb
Last active Jun 11, 2021
FSL installation in Google colab
View fsl-installation-in-google-colab.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.