Skip to content

Instantly share code, notes, and snippets.

Working from home

Franco Matzkin vfmatzkin

Working from home
View GitHub Profile
vfmatzkin /
Created Mar 16, 2021
I can't believe ANTs is that good in Python
# 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 /
Last active Mar 15, 2021
FSL FLIRT Registration with Python & SimpleITK
# Created by Franco Matzkin (vfmatzkin [at]
# 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: #noqa
import os
import shutil
import tempfile
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 /
Created Jan 19, 2021
Inverse parametermap calculation using SimpleElastix (SimpleITK extension)
# 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.
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.