Skip to content

Instantly share code, notes, and snippets.

@bthirion
Last active August 29, 2015 13:58
Show Gist options
  • Save bthirion/9982582 to your computer and use it in GitHub Desktop.
Save bthirion/9982582 to your computer and use it in GitHub Desktop.
Issue with nibabel.read_img_data
from os import path
import numpy as np
import matplotlib.pyplot as plt
from nibabel import load
from nibabel.loadsave import read_img_data
# Local import to $NIPY/examples/labs/need_data
from get_data_light import DATA_DIR, get_first_level_dataset
#######################################
# Data and analysis parameters
#######################################
# volume mask
# This dataset is large
get_first_level_dataset()
img_path = path.join(DATA_DIR, 's12069_swaloc1_corr.nii.gz')
img = load(img_path)
im1 = img.get_data()[:, :, :, 0]
im2 = read_img_data(img)[:, :, :, 0]
# affine = img.get_affine()
plt.figure()
plt.subplot(121)
plt.imshow(im1[:, :, 20])
plt.subplot(122)
plt.imshow(im2[:, :, 20])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment