Skip to content

Instantly share code, notes, and snippets.

@dgobbi
dgobbi / dicom_to_nifti.py
Last active April 17, 2024 10:43
Program to convert DICOM to NIFTI, includes useful functions for reconstructing DICOM series
"""
Module: dicom_to_nifti.py
Nov 28, 2019
David Gobbi
"""
import pydicom
import nibabel as nib
import numpy as np
@dgobbi
dgobbi / QtImageExample.py
Created November 28, 2019 19:23
Simple image display with QVTKRenderWindowInteractor
# coding=utf-8
"""
Example of displaying an image with VTK/Qt/Python.
Original author: David Gobbi
This example does not include proper image orientation or interaction.
"""
import sys
@dgobbi
dgobbi / QVTKRenderWindowInteractor.py
Last active February 15, 2024 07:30
Simple QVTKRenderWindowInteractor example in Python
# coding=utf-8
"""
A simple VTK widget for PyQt or PySide.
See http://www.trolltech.com for Qt documentation,
http://www.riverbankcomputing.co.uk for PyQt, and
http://pyside.github.io for PySide.
This class is based on the vtkGenericRenderWindowInteractor and is
therefore fairly powerful. It should also play nicely with the
vtk3DWidget code.
@dgobbi
dgobbi / readdump.py
Last active August 7, 2020 17:29
Parse the output from dicomdump and write out as json
#! /usr/bin/env python
"""
This program reads the output from "dicomdump" and converts it to json.
The latest version of this code can be found at gist.github.com/dgobbi
Note that this code is incomplete, incorrect, and may destroy your data.
It comes with absolutely no warranties. Use at your own risk.
"""
@dgobbi
dgobbi / ViewImage2D.py
Created May 13, 2021 03:07
View large images with vtkImageResliceMapper
#! /usr/bin/env python
import sys
import os
import mmap
import vtk
usage = """
Usage: "ViewImage2D [options] image
@dgobbi
dgobbi / split_nifti.py
Created December 13, 2023 17:36
Split multi-volume nifti into volumes
#! /usr/bin/env python
"""
Split a 4D NIFTI file into separate volumes.
Dec 11, 2023
David Gobbi
"""
usage="""