def main(maskname, output, k): """ This loops through input subjects, constructs individual cortical cluster maps, and then generates a single map at the group level. """ # keep track of the time T0 = time() # perform random clustering localcon = os.path.dirname(maskname) + "/rm_ones_connectivity.npy" if os.path.isfile(localcon) == False: # calculates local connectivity from binary mask make_local_connectivity_ones(maskname, localcon) if os.path.isfile(output + str(k[0]) + ".npy") == False: # segments into k clusters using local connectivity binfile_parcellate(localcon, output, k) if os.path.isfile(output + str(k[0]) + ".nii.gz") == False: # write out a nifti make_image_from_bin_renum(output + str(k[0]) + ".nii.gz", output + str(k[0]) + ".npy", maskname) T1 = time() print "**** Done in " + str(T1 - T0)
def main(maskname, output, k): """ This loops through input subjects, constructs individual cortical cluster maps, and then generates a single map at the group level. """ # keep track of the time T0 = time() # perform random clustering localcon = os.path.dirname(maskname) + '/rm_ones_connectivity.npy' if os.path.isfile(localcon) == False: # calculates local connectivity from binary mask make_local_connectivity_ones(maskname, localcon) if os.path.isfile(output + str(k[0]) + '.npy') == False: # segments into k clusters using local connectivity binfile_parcellate(localcon, output, k) if os.path.isfile(output + str(k[0]) + '.nii.gz') == False: # write out a nifti make_image_from_bin_renum(output + str(k[0]) + '.nii.gz', output + str(k[0]) + '.npy', maskname) T1 = time() print '**** Done in ' + str(T1 - T0)
### print "3. Clustering" from binfile_parcellation import * ks = [25,50,100,200,400,800,1600,3200] # For random custering, this is all we need to do, there is no need for group # level clustering, remember that the output filename is a prefix, and infile = outfile outbase = path.join(obase, "random_ones_cluster") binfile_parcellate(infile, outbase, ks) ### # 4. Save ### print "4. Save" from make_image_from_bin_renum import * for k in ks: print "\tk #%i" % k binfile = path.join(obase, "random_ones_cluster_%i.npy" % k) imgfile = path.join(roidir, "rois_random_k%04i.nii.gz" % k) make_image_from_bin_renum(imgfile, binfile, maskfile)
### # 3. Group-Mean Clustering ### # Done in 05* ### # 4. Convert binary output .npy files to nifti ### ks = [5,10,20,25,40,50,80,100,150,160,200,250,300,320,350,400,450,500, 550,600,640] network_names = ["visual", "somatomotor", "dorsal_attention", "ventral_attention", "limbic", "frontoparietal", "default"] for network in network_names: print "Network: %s" % network for k in ks: print "\tk #%i" % k binfile = path.join(obase, "group_mean_scorr_cluster_%s_%i.npy" % (network, k)) imgfile = path.join(obase, "group_mean_scorr_cluster_%s_%i.nii.gz" % (network, k)) roifile = path.join(rbase, "yeo_%s_3mm.nii.gz" % network) make_image_from_bin_renum(imgfile, binfile, roifile)
### # 3. 'Clustering' ### print "3. Clustering" from binfile_parcellation import * ks = [25, 50, 100, 200, 400, 800, 1600, 3200] # For random custering, this is all we need to do, there is no need for group # level clustering, remember that the output filename is a prefix, and infile = outfile outbase = path.join(obase, "random_ones_cluster") binfile_parcellate(infile, outbase, ks) ### # 4. Save ### print "4. Save" from make_image_from_bin_renum import * for k in ks: print "\tk #%i" % k binfile = path.join(obase, "random_ones_cluster_%i.npy" % k) imgfile = path.join(roidir, "rois_random_k%04i.nii.gz" % k) make_image_from_bin_renum(imgfile, binfile, maskfile)
### # 3. Group-Mean Clustering ### # Done in 05* ### # 4. Convert binary output .npy files to nifti ### ks = [ 5, 10, 20, 25, 40, 50, 80, 100, 150, 160, 200, 250, 300, 320, 350, 400, 450, 500, 550, 600, 640 ] network_names = [ "visual", "somatomotor", "dorsal_attention", "ventral_attention", "limbic", "frontoparietal", "default" ] for network in network_names: print "Network: %s" % network for k in ks: print "\tk #%i" % k binfile = path.join( obase, "group_mean_scorr_cluster_%s_%i.npy" % (network, k)) imgfile = path.join( obase, "group_mean_scorr_cluster_%s_%i.nii.gz" % (network, k)) roifile = path.join(rbase, "yeo_%s_3mm.nii.gz" % network) make_image_from_bin_renum(imgfile, binfile, roifile)