%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline]. For more information, type 'help(pylab)'.
from os.path import join as pjoin, expanduser, isfile, isdir
DIRBASE = pjoin(expanduser('~'),'data','duncan_k')
DDATA = pjoin(DIRBASE,'ds107')
print DDATA
/home/jb/data/duncan_k/ds107
import nipy
import os
os.path.realpath(nipy.__file__)
'/home/jb/.local/lib/python2.7/site-packages/nipy/__init__.pyc'
import nibabel as nib
fname_sub = pjoin(DDATA, 'sub042', 'BOLD', 'task001_run001', 'bold.nii.gz')
sub_img = nib.load(fname_sub)
hdr = sub_img.get_header()
print hdr
<class 'nibabel.nifti1.Nifti1Header'> object, endian='<' sizeof_hdr : 348 data_type : db_name : extents : 0 session_error : 0 regular : r dim_info : 0 dim : [ 4 64 64 35 165 1 1 1] intent_p1 : 0.0 intent_p2 : 0.0 intent_p3 : 0.0 intent_code : none datatype : int16 bitpix : 16 slice_start : 0 pixdim : [ 1. 3. 3. 3. 3. 0. 0. 0.] vox_offset : 352.0 scl_slope : 1.0 scl_inter : 0.0 slice_end : 0 slice_code : unknown xyzt_units : 10 cal_max : 0.0 cal_min : 0.0 slice_duration : 0.0 toffset : 0.0 glmax : 0 glmin : 0 descrip : FSL4.0 aux_file : qform_code : scanner sform_code : scanner quatern_b : 0.0 quatern_c : 0.0 quatern_d : 0.0 qoffset_x : -93.0 qoffset_y : -103.418151855 qoffset_z : -45.4796600342 srow_x : [ 3. 0. 0. -93.] srow_y : [ 0. 3. 0. -103.41815186] srow_z : [ 0. 0. 3. -45.47966003] intent_name : magic : n+1
hdr.get_dim_info()
(None, None, None)
import nipy.algorithms.diagnostics as nads
tdiff = nads.time_slice_diffs(sub_img.get_data(), time_axis=-1, slice_axis=-2)
nads.plot_tsdiffs(tdiff)
[<matplotlib.axes.AxesSubplot at 0x5466d10>, <matplotlib.axes.AxesSubplot at 0x549d290>, <matplotlib.axes.AxesSubplot at 0x547a2d0>, <matplotlib.axes.AxesSubplot at 0x59e0390>]
data = sub_img.get_data()
print data.shape
std_arr = np.std(data, axis=3)
sagittal = std_arr[17,:,:]
plt.imshow(sagittal.T[-1:0:-1,:])
(64, 64, 35, 165)
<matplotlib.image.AxesImage at 0x6b16bd0>
plt.imshow??