Skip to content

Instantly share code, notes, and snippets.

View dancebean's full-sized avatar

dancebean

View GitHub Profile
@jcreinhold
jcreinhold / tif_to_nii.py
Last active August 13, 2025 01:52
Convert TIFF image directory (of one image) to NIfTI
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
tif_to_nii
command line executable to convert a directory of tif images
(from one image) to a nifti image stacked along a user-specified axis
call as: python tif_to_nii.py /path/to/tif/ /path/to/nifti
(append optional arguments to the call as desired)
@jcreinhold
jcreinhold / resnet3d.ipynb
Last active July 26, 2021 08:24
3d resnet for nifti images in fastai
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yashkumaratri
yashkumaratri / Google Colab SSH
Created December 31, 2018 05:19
SSH into google colab
#CODE
#Generate root password
import random, string
password = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(20))
#Download ngrok
! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
! unzip -qq -n ngrok-stable-linux-amd64.zip
#Setup sshd
@jcreinhold
jcreinhold / nii_to_tif.py
Last active August 1, 2023 18:23
Convert NIfTI images into multiple TIF images
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
nii_to_tif
command line executable to convert 3d nifti images to
individual tiff images along a user-specified axis
call as: python nii_to_tif.py /path/to/nifti /path/to/tif
(append optional arguments to the call as desired)
@gilrosenthal
gilrosenthal / Fast.ai install script
Created July 4, 2018 20:14
Fast.ai Install on Google Colab
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
@ahmedhosny
ahmedhosny / nrrd_to_nifti.py
Created December 12, 2017 15:49
nrrd to nifti
import nrrd # pip install pynrrd
import nibabel as nib # pip install nibabel
import numpy as np
# load nrrd
_nrrd = nrrd.read('/path/to/nrrd.nrrd')
data = _nrrd[0]
header = _nrrd[1]
print data.shape, header
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@somada141
somada141 / python_dicom_load_vtk.md
Last active July 14, 2024 00:53
Load DICOM data into a NumPy array with VTK #python #dicom #medical #imagedata #vtk #fileIO

Imports:

import vtk
from vtk.util import numpy_support
import numpy

Create a vtkDICOMImageReader object, set its directory to the one containing all DICOM files, and Update to read in all data: