# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1354652310 21600
# Node ID b29f471a1754450f07859ca0f6e0f7b5ba1942fb
# Parent  5687b9076dd8350facc03263810765de6079924b
rename: nifti -> nibabel

diff --git a/make_image_from_bin.py b/make_image_from_bin.py
--- a/make_image_from_bin.py
+++ b/make_image_from_bin.py
@@ -1,11 +1,11 @@
 #### make_image_from_bin.py
 # Copyright (C) 2010 R. Cameron Craddock (cameron.craddock@gmail.com)
 #
 # This script is a part of the pyClusterROI python toolbox for the spatially constrained clustering of fMRI
 # data. It converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
-# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
+# group_mean_binfile_parcellation.npy into a nibabel file where each voxels intensity corresponds to the
 # number of the cluster to which it belongs.
 #
 # For more information refer to:
 #
 # Craddock, R. C., James, G. A., Holtzheimer, P. E., Hu, X. P., & Mayberg, H. S. (2011). A whole 
@@ -29,24 +29,24 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
+# (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nifti import NiftiImage 
+from nibabel import NiftiImage 
 from numpy import *
 
 # make_image_from_bin( image, binfile, mask )
 # 
 # Converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
-# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
+# group_mean_binfile_parcellation.npy into a nibabel file where each voxels intensity corresponds to the
 # number of the cluster to which it belongs.
-#     image:   The name of the nifti file to be written.
+#     image:   The name of the nibabel file to be written.
 #     binfile: The binfile to be converted. The file contains a n_voxel x 1 vector that is
-#              converted to a nifti file.
-#     mask:    Mask describing the space of the nifti file. This should correspond to the 
+#              converted to a nibabel file.
+#     mask:    Mask describing the space of the nibabel file. This should correspond to the 
 #              mask originally used to create the connectivity matrices used for parcellation.
 #
 def make_image_from_bin( image, binfile, mask ):
 
 	# read in the mask
@@ -68,11 +68,11 @@
         print "sum",sum(imdat)
         # map the binary data to mask
 	print "shape2",shape(a[0:sum(imdat)])
         imdat[imdat>0]=short(a[0:sum(imdat)].flatten())
 
-        # write out the image as nifti
+        # write out the image as nibabel
         thdr=nim.header
         thdr['scl_slope']=1
  
 	nim_out=NiftiImage(imdat)
 	nim_out.updateFromDict(thdr)
diff --git a/make_image_from_bin_renum.py b/make_image_from_bin_renum.py
--- a/make_image_from_bin_renum.py
+++ b/make_image_from_bin_renum.py
@@ -1,11 +1,11 @@
 #### make_image_from_bin_renum.py
 # Copyright (C) 2010 R. Cameron Craddock (cameron.craddock@gmail.com)
 #
 # This script is a part of the pyClusterROI python toolbox for the spatially constrained clustering of fMRI
 # data. It converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
-# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
+# group_mean_binfile_parcellation.npy into a nibabel file where each voxels intensity corresponds to the
 # number of the cluster to which it belongs. The clusters are renumbered to be contiguous.
 #
 # For more information refer to:
 #
 # Craddock, R. C., James, G. A., Holtzheimer, P. E., Hu, X. P., & Mayberg, H. S. (2011). A whole 
@@ -29,24 +29,24 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
+# (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nifti import NiftiImage 
+from nibabel import NiftiImage 
 from numpy import *
 
 # make_image_from_bin_renum( image, binfile, mask ):
 # 
 # Converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
-# group_mean_binfile_parcellation.npy into a nifti file where each voxels intensity corresponds to the
+# group_mean_binfile_parcellation.npy into a nibabel file where each voxels intensity corresponds to the
 # number of the cluster to which it belongs. Clusters are renumberd to be contiguous.
-#     image:   The name of the nifti file to be written.
+#     image:   The name of the nibabel file to be written.
 #     binfile: The binfile to be converted. The file contains a n_voxel x 1 vector that is
-#              converted to a nifti file.
-#     mask:    Mask describing the space of the nifti file. This should correspond to the 
+#              converted to a nibabel file.
+#     mask:    Mask describing the space of the nibabel file. This should correspond to the 
 #              mask originally used to create the connectivity matrices used for parcellation.
 #
 
 def make_image_from_bin_renum( image, binfile, mask ):
 
@@ -76,11 +76,11 @@
 
         # map the binary data to mask
 	imdat[imdat>0]=1
         imdat[imdat>0]=short(b[0:sum(imdat)].flatten())
 
-        # write out the image as nifti
+        # write out the image as nibabel
         thdr=nim.header
         thdr['scl_slope']=1
  
 	nim_out=NiftiImage(imdat)
 	nim_out.updateFromDict(thdr)
diff --git a/make_local_connectivity_ones.py b/make_local_connectivity_ones.py
--- a/make_local_connectivity_ones.py
+++ b/make_local_connectivity_ones.py
@@ -28,13 +28,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
+# (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nifti import *
+from nibabel import *
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 
 # simple function to translate 1D vector coordinates to 3D matrix coordinates, for a 3D matrix of 
diff --git a/make_local_connectivity_scorr.py b/make_local_connectivity_scorr.py
--- a/make_local_connectivity_scorr.py
+++ b/make_local_connectivity_scorr.py
@@ -29,13 +29,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
+# (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nifti import *
+from nibabel import *
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 from scipy.sparse.linalg.eigen.arpack import eigsh
 from scipy.linalg import norm, svd
diff --git a/make_local_connectivity_tcorr.py b/make_local_connectivity_tcorr.py
--- a/make_local_connectivity_tcorr.py
+++ b/make_local_connectivity_tcorr.py
@@ -29,13 +29,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/) to be installed in a directory that is
+# (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nifti import *
+from nibabel import *
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 from scipy.sparse.linalg.eigen.arpack import eigsh
 from scipy.linalg import norm, svd
diff --git a/pyClusterROI_test.py b/pyClusterROI_test.py
--- a/pyClusterROI_test.py
+++ b/pyClusterROI_test.py
@@ -28,11 +28,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
-# (http://niftilib.sourceforge.net/pynifti/)  and the pyClusterROI toolbox to be 
+# (http://nibabellib.sourceforge.net/pynibabel/)  and the pyClusterROI toolbox to be 
 # installed in a directory that is accessible through PythonPath
 import sys
 
 # this is how you would add a directory to the search path, this is useful if you
 # are running this script from a directory other than the directory where
@@ -53,11 +53,11 @@
 
 # import the functions for group clustering, only need one of these
 from group_binfile_parcellation import *
 from group_mean_binfile_parcellation import *
 
-# import if you want to write the results out to nifti, only need
+# import if you want to write the results out to nibabel, only need
 # one of these, probably just want the one that does renumbering,
 # why do i include the other one? no idea.
 from make_image_from_bin import *
 from make_image_from_bin_renum import *
 
@@ -168,11 +168,11 @@
 		ind_clust_files.append('rm_scorr_indiv_cluster_'+str(i)+'_'+str(k)+'.npy')
 
 	print '2-level parcellate scorr',k
 	group_binfile_parcellate(ind_clust_files,'rm_group_scorr_cluster_'+str(k)+'.npy',k,mask_voxels)
 
-##### Step 4. Convert the binary output .npy files to nifti
+##### Step 4. Convert the binary output .npy files to nibabel
 # this can be done with or without renumbering the clusters to make sure they are 
 # contiguous. remember, we might end up with fewer clusters than we ask for, and this
 # could result in gaps in the cluster numbering. Choose which you like, i use them
 # intermittently below as a regression test
 
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1354653834 21600
# Node ID fc76d109f560fa5790eb268b6f4f81d78c68b2a3
# Parent  b29f471a1754450f07859ca0f6e0f7b5ba1942fb
nifti: update to use newer nibabel

diff --git a/make_image_from_bin.py b/make_image_from_bin.py
--- a/make_image_from_bin.py
+++ b/make_image_from_bin.py
@@ -31,11 +31,11 @@
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), and PyNIfTI 
 # (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nibabel import NiftiImage 
+from nibabel.nifti1 import load as NiftiImage
 from numpy import *
 
 # make_image_from_bin( image, binfile, mask )
 # 
 # Converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
diff --git a/make_image_from_bin_renum.py b/make_image_from_bin_renum.py
--- a/make_image_from_bin_renum.py
+++ b/make_image_from_bin_renum.py
@@ -31,11 +31,11 @@
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), and PyNIfTI 
 # (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nibabel import NiftiImage 
+from nibabel.nifti1 import load as NiftiImage 
 from numpy import *
 
 # make_image_from_bin_renum( image, binfile, mask ):
 # 
 # Converts a NPY file generated by binfile_parcellation.py, group_binfile_parcellation.py, or 
diff --git a/make_local_connectivity_ones.py b/make_local_connectivity_ones.py
--- a/make_local_connectivity_ones.py
+++ b/make_local_connectivity_ones.py
@@ -30,11 +30,11 @@
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
 # (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nibabel import *
+from nibabel.nifti1 import load as NiftiImage
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 
 # simple function to translate 1D vector coordinates to 3D matrix coordinates, for a 3D matrix of 
@@ -81,14 +81,14 @@
                  	[-1, 1, 1],[0, 1, 1],[1, 1, 1]])
 
 
         # read in the mask
         msk=NiftiImage(maskfile)
-        msz=shape(msk.data)
+        msz=shape(msk.get_data())
 
 	# convert the 3D mask array into a 1D vector
-        mskdat=reshape(msk.data,prod(msz))
+        mskdat=reshape(msk.get_data(),prod(msz))
 
 	# determine the 1D coordinates of the non-zero 
 	# elements of the mask
         iv=nonzero(mskdat)[0]
 	m=len(iv)
diff --git a/make_local_connectivity_scorr.py b/make_local_connectivity_scorr.py
--- a/make_local_connectivity_scorr.py
+++ b/make_local_connectivity_scorr.py
@@ -31,11 +31,11 @@
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
 # (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nibabel import *
+from nibabel.nifti1 import load as NiftiImage
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 from scipy.sparse.linalg.eigen.arpack import eigsh
 from scipy.linalg import norm, svd
@@ -90,26 +90,26 @@
                  	[-1, 1, 1],[0, 1, 1],[1, 1, 1]])
 
 
         # read in the mask
         msk=NiftiImage(maskfile)
-        msz=shape(msk.data)
+        msz=shape(msk.get_data())
 
 	# convert the 3D mask array into a 1D vector
-        mskdat=reshape(msk.data,prod(msz))
+        mskdat=reshape(msk.get_data(),prod(msz))
 
 	# determine the 1D coordinates of the non-zero 
 	# elements of the mask
         iv=nonzero(mskdat)[0]
 	m=len(iv)
 
 	# read in the fmri data
 	nim=NiftiImage(infile)
-	sz=shape(nim.data)
+	sz=shape(nim.get_data())
 
 	# reshape fmri data to a num_voxels x num_timepoints array		
-	imdat=reshape(nim.data,(sz[0],prod(sz[1:])))
+	imdat=reshape(nim.get_data(),(sz[0],prod(sz[1:])))
 
 	# mask the datset to only then in-mask voxels
         imdat=imdat[:,iv]
  
         #zscore fmri time courses, this makes calculation of the
diff --git a/make_local_connectivity_tcorr.py b/make_local_connectivity_tcorr.py
--- a/make_local_connectivity_tcorr.py
+++ b/make_local_connectivity_tcorr.py
@@ -31,11 +31,11 @@
 ####
 
 # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and PyNIfTI 
 # (http://nibabellib.sourceforge.net/pynibabel/) to be installed in a directory that is
 # accessible through PythonPath 
-from nibabel import *
+from nibabel.nifti1 import load as NiftiImage
 from numpy import array
 from scipy import *
 from scipy.sparse import *
 from scipy.sparse.linalg.eigen.arpack import eigsh
 from scipy.linalg import norm, svd
@@ -91,26 +91,26 @@
                  	[-1, 1, 1],[0, 1, 1],[1, 1, 1]])
 
 
 	# read in the mask
         msk=NiftiImage(maskfile)
-        msz=shape(msk.data)
+        msz=shape(msk.get_data())
 
 	# convert the 3D mask array into a 1D vector
-        mskdat=reshape(msk.data,prod(msz))
+        mskdat=reshape(msk.get_data(),prod(msz))
 
 	# determine the 1D coordinates of the non-zero 
 	# elements of the mask
         iv=nonzero(mskdat)[0]
 	m=len(iv)
 
 	# read in the fmri data
 	nim=NiftiImage(infile)
-	sz=shape(nim.data)
+	sz=shape(nim.get_data())
 
 	# reshape fmri data to a num_voxels x num_timepoints array	
-	imdat=reshape(nim.data,(sz[0],prod(sz[1:])))
+	imdat=reshape(nim.get_data(),(sz[0],prod(sz[1:])))
 
 	# construct a sparse matrix from the mask
 	msk=csc_matrix((range(1,m+1),(iv,zeros(m))),shape=(prod(sz[1:]),1))
 
 	sparse_i=[]
