From 01de6fd1e47100aaa99391b21af03dfcd83962f4 Mon Sep 17 00:00:00 2001 From: Cameron Craddock Date: Fri, 13 Sep 2013 00:42:03 -0400 Subject: [PATCH] modified test script to remove commented out code modified make_local_connectivity_* to print status --- make_local_connectivity_ones.py | 2 +- make_local_connectivity_scorr.py | 3 +-- make_local_connectivity_tcorr.py | 1 + pyClusterROI_test.py | 24 ++++++++++-------------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/make_local_connectivity_ones.py b/make_local_connectivity_ones.py index e753bf7..7b50844 100755 --- a/make_local_connectivity_ones.py +++ b/make_local_connectivity_ones.py @@ -121,7 +121,7 @@ def make_local_connectivity_ones( maskfile, outfile ): # loop over all of the voxels in the mask for i in range(0,m): - if i % 100 == 0: print 'voxel# ', i + if i % 1000 == 0: print 'voxel #', i # calculate the voxels that are in the 3D neighborhood # of the center voxel diff --git a/make_local_connectivity_scorr.py b/make_local_connectivity_scorr.py index 6afe9aa..19e24ca 100755 --- a/make_local_connectivity_scorr.py +++ b/make_local_connectivity_scorr.py @@ -161,6 +161,7 @@ def make_local_connectivity_scorr( infile, maskfile, outfile, thresh ): sparse_w=[[]] for i in range(0,m): + if i % 1000 == 0: print 'voxel #', i # convert index into 3D and calculate neighbors ndx3d=indx_1dto3d(iv[i],sz[:-1])+neighbors # convert resulting 3D indices into 1D @@ -193,8 +194,6 @@ def make_local_connectivity_scorr( infile, maskfile, outfile, thresh ): sparse_i=append(sparse_i,ondx1d,0) sparse_j=append(sparse_j,(ondx1d[nndx])*ones(len(ondx1d))) sparse_w=append(sparse_w,R[nndx,:],1) - if i % 100 == 0: - print "Completed voxel # %d"%(i) # insure that the weight vector is the correct shape diff --git a/make_local_connectivity_tcorr.py b/make_local_connectivity_tcorr.py index 271fa3d..9039b6b 100755 --- a/make_local_connectivity_tcorr.py +++ b/make_local_connectivity_tcorr.py @@ -138,6 +138,7 @@ def make_local_connectivity_tcorr( infile, maskfile, outfile, thresh ): # loop over all of the voxels in the mask for i in range(0,m): + if i % 1000 == 0: print 'voxel #', i # calculate the voxels that are in the 3D neighborhood # of the center voxel ndx3d=indx_1dto3d(iv[i],sz[:-1])+neighbors diff --git a/pyClusterROI_test.py b/pyClusterROI_test.py index c0c2b42..c1ba803 100644 --- a/pyClusterROI_test.py +++ b/pyClusterROI_test.py @@ -49,13 +49,13 @@ # this scripts requires NumPy (numpy.scipy.org), SciPy (www.scipy.org), and # NiBabel (http://niftilib.sourceforge.net/pynifti/) 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 # the pyClusterROI is installed. Or if for some reason your NumPy, SciPy, or # NiBabel libraries are in a non-standard location, do this before you import # the files/libraries that require the change in path +# import sys # sys.path.append("/home/user/python_toolboxes") # import the different functions we will use from pyClusterROI @@ -78,14 +78,10 @@ from make_image_from_bin import * from make_image_from_bin_renum import * -#import mkl - from time import time T0 = time() -#mkl.set_num_threads = 4 - # the name of the maskfile that we will be using maskname="gm_maskfile.nii.gz" @@ -100,19 +96,19 @@ # the easiest is random clustering which doesn't require any functional # data, just the mask print 'ones connectivity' -#make_local_connectivity_ones( maskname, 'rm_ones_connectivity.npy') +make_local_connectivity_ones( maskname, 'rm_ones_connectivity.npy') # construct the connectivity matrices using tcorr and a r>0.5 threshold -#for idx, in_file in enumerate(infiles[:1]): -# -# # construct an output filename for this file -# outname='rm_tcorr_conn_'+str(idx)+'.npy' -# -# print 'tcorr connectivity',in_file -# # call the funtion to make connectivity -# make_local_connectivity_tcorr( in_file, maskname, outname, 0.5 ) +for idx, in_file in enumerate(infiles): + + # construct an output filename for this file + outname='rm_tcorr_conn_'+str(idx)+'.npy' + + print 'tcorr connectivity',in_file + # call the funtion to make connectivity + make_local_connectivity_tcorr( in_file, maskname, outname, 0.5 ) # construct the connectivity matrices using scorr and a r>0.5 threshold