def call_calc_centrality(): import time datafile = "/data/Projects/ABIDE_Initiative/CPAC/test_qp/Centrality_Working/resting_preproc_0051466_session_1/_mask_mask_abide_90percent_gm_3mm/_scan_rest_1_rest/resample_functional_to_template_0/residual_wtsimt_flirt.nii.gz" template = "/home2/data/Projects/ABIDE_Initiative/CPAC/abide/templates/masks/mask_abide_90percent_gm_3mm.nii.gz" method_options = [True, False] weight_options = [True, True] option = 0 threshold = 0.266037302736 allocated_memory = 12 start = time.clock() calc_centrality(datafile, template, method_options, weight_options, option, threshold, allocated_memory) end = time.clock() print (end-start)
def test_calc_centrality(): infile = "/home2/data/Projects/ABIDE_Initiative/CPAC/test_qp/All_Output/sym_links/pipeline_MerrittIsland/_compcor_ncomponents_5_linear1.global1.motion1.quadratic1.compcor1.CSF_0.96_GM_0.7_WM_0.96/0051466_session_1/scan_rest_1_rest/func/functional_mni.nii.gz" maskfile = "/home2/data/Projects/ABIDE_Initiative/CPAC/abide/templates/masks/mask_abide_90percent_gm.nii.gz" tmp1 = calc_centrality(infile, maskfile, [1,0], [1,1], 0, 0.01, 12) # datafile : string (nifti file) # path to subject data file # template : string (nifti file) # path to mask/parcellation unit # method_options : list (boolean) # list of two booleans for binarize and weighted options respectively # weight_options : list (boolean) # list of two booleans for binarize and weighted options respectively # option : an integer # 0 for probability p_value, 1 for sparsity threshold, # any other for threshold value # threshold : a float # pvalue/sparsity_threshold/threshold value # allocated_memory : string # amount of memory allocated to degree centrality config_file = "files/config_fsl.yml" subject_infos = common.gen_file_map(CPAC_OUTPUT) curdir = os.getcwd() os.chdir(__file__) conf = common.load_configuration(config_file) old_subject_file = common.load_subject_list(conf.subjectListFile) new_subject_file = setup_group_subject_list(config_file, subject_infos) os.chdir(curdir) # All should be right here assert_equal(np.array(old_subject_file), np.array(new_subject_file)) # Case where only one path is correct """
threshold = args.rho elif args.no_threshold: option = 3 threshold = None else: raise SystemExit("You must specify one threshold option: --pvalue, --sparsity, --rho, or --no-threshold.") ### # Call on the Big Guy/Gal (CPAC) ### curdir = os.getcwd() os.chdir(args.outdir) out_list = calc_centrality(args.input, args.mask, method_options, weight_options, option, threshold, args.memlimit) os.chdir(curdir) ### # Z-Score ### def zscore_image(infile, mask, outfile): import os, commands cmd = "fslstats %s -k %s -m" % (infile, mask) print cmd mean = commands.getstatusoutput(cmd) mean = float(mean[1])
import sys sys.path.insert(0, '/home2/data/Projects/CPAC_Regression_Test/nipype-installs/fcp-indi-nipype/running-install/lib/python2.7/site-packages') sys.path.insert(1, "/home2/data/Projects/CPAC_Regression_Test/2013-05-30_cwas/C-PAC") sys.path.append("/home/data/PublicProgram/epd-7.2-2-rh5-x86_64/lib/python2.7/site-packages") from CPAC.network_centrality import calc_centrality datafile = "/data/Projects/ABIDE_Initiative/CPAC/test_qp/Centrality_Working/resting_preproc_0051466_session_1/_mask_mask_abide_90percent_gm_3mm/_scan_rest_1_rest/resample_functional_to_template_0/residual_wtsimt_flirt.nii.gz" template = "/home2/data/Projects/ABIDE_Initiative/CPAC/abide/templates/masks/mask_abide_90percent_gm_3mm.nii.gz" method_options = [True, False] weight_options = [True, True] option = 0 threshold = 0.001 allocated_memory = 1 calc_centrality(datafile, template, method_options, weight_options, option, threshold, allocated_memory) #datafile = "/data/Projects/ABIDE_Initiative/CPAC/test_qp/Centrality_Working/resting_preproc_0051466_session_1/_mask_mask_abide_90percent_gm_4mm/_scan_rest_1_rest/resample_functional_to_template_0/residual_wtsimt_flirt.nii.gz" #template = "/home2/data/Projects/ABIDE_Initiative/CPAC/abide/templates/masks/mask_abide_90percent_gm_4mm.nii.gz" #method_options = [True, False] #weight_options = [True, True] #option = 0 #threshold = 0.266037302736 #allocated_memory = 12 # #calc_centrality(datafile, template, method_options, weight_options, option, threshold, allocated_memory)
elif args.no_threshold: option = 3 threshold = None else: raise SystemExit( "You must specify one threshold option: --pvalue, --sparsity, --rho, or --no-threshold." ) ### # Call on the Big Guy/Gal (CPAC) ### curdir = os.getcwd() os.chdir(args.outdir) out_list = calc_centrality(args.input, args.mask, method_options, weight_options, option, threshold, args.memlimit) os.chdir(curdir) ### # Z-Score ### def zscore_image(infile, mask, outfile): import os, commands cmd = "fslstats %s -k %s -m" % (infile, mask) print cmd mean = commands.getstatusoutput(cmd) mean = float(mean[1])