# parameter for the intersection of the mask ths = .5 # number of parcels nbparcel = 200 # write directory write_dir = path.join(getcwd(), 'results') if not path.exists(write_dir): mkdir(write_dir) # prepare the parcel structure domain, ldata = parcel_input(mask_images, learn_images, ths) # run the algorithm fpa = hparcel(domain, ldata, nbparcel, verbose=1) # produce some output images write_parcellation_images(fpa, subject_id=subj_id, swd=write_dir) # do some parcellation-based analysis: # take some test images whose parcel-based signal needs to be assessed test_images = [ path.join(data_dir, 'spmT_%s_subj_%02d.nii' % (nbeta, n)) for n in range(nb_subj) ] # compute and write the parcel-based statistics rfx_path = path.join(write_dir, 'prfx_%s.nii' % nbeta) parcellation_based_analysis(fpa, test_images, 'one_sample', rfx_path=rfx_path) print("Wrote everything in %s" % write_dir)
pos = 3 * np.array([[6, 7], [10, 10], [15, 10]]) ampli = np.array([5, 7, 6]) sjitter = 6.0 dataset = simul.surrogate_2d_dataset(n_subj=n_subj, shape=shape, pos=pos, ampli=ampli, width=10.0) # dataset represents 2D activation images from n_subj subjects, # step 2 : prepare all the information for the parcellation nbparcel = 10 ldata = np.reshape(dataset, (n_subj, np.prod(shape), 1)) domain = dom.grid_domain_from_shape(shape) # step 3 : run the algorithm Pa = hp.hparcel(domain, ldata, nbparcel, mu=3.0) # note: play with mu to change the 'stiffness of the parcellation' # step 4: look at the results Label = np.array([np.reshape(Pa.individual_labels[:, s], shape) for s in range(n_subj)]) plt.figure(figsize=(8, 4)) plt.title('Input data') for s in range(n_subj): plt.subplot(2, 5, s + 1) plt.imshow(dataset[s], interpolation='nearest') plt.axis('off') plt.figure(figsize=(8, 4)) plt.title('Resulting parcels')
pos = 3 * np.array([[6, 7], [10, 10], [15, 10]]) ampli = np.array([5, 7, 6]) sjitter = 6.0 dataset = simul.surrogate_2d_dataset(n_subj=n_subj, shape=shape, pos=pos, ampli=ampli, width=10.0) # dataset represents 2D activation images from n_subj subjects, # step 2 : prepare all the information for the parcellation nbparcel = 10 ldata = np.reshape(dataset, (n_subj, np.prod(shape), 1)) domain = dom.grid_domain_from_shape(shape) # step 3 : run the algorithm Pa = hp.hparcel(domain, ldata, nbparcel, mu=3.0) # note: play with mu to change the 'stiffness of the parcellation' # step 4: look at the results Label = np.array([np.reshape(Pa.individual_labels[:, s], shape) for s in range(n_subj)]) import matplotlib.pylab as mp mp.figure(figsize=(8, 4)) mp.title('Input data') for s in range(n_subj): mp.subplot(2, 5, s + 1) mp.imshow(dataset[s], interpolation='nearest') mp.axis('off') mp.figure(figsize=(8, 4))
# parameter for the intersection of the mask ths = .5 # number of parcels nbparcel = 200 # write directory write_dir = path.join(getcwd(), 'results') if not path.exists(write_dir): mkdir(write_dir) # prepare the parcel structure domain, ldata = parcel_input(mask_images, learn_images, ths) # run the algorithm fpa = hparcel(domain, ldata, nbparcel, verbose=1) # produce some output images write_parcellation_images(fpa, subject_id=subj_id, swd=write_dir) # do some parcellation-based analysis: # take some test images whose parcel-based signal needs to be assessed test_images = [path.join(data_dir, 'spmT_%s_subj_%02d.nii' % (nbeta, n)) for n in range(nb_subj)] # compute and write the parcel-based statistics rfx_path = path.join(write_dir, 'prfx_%s.nii' % nbeta) parcellation_based_analysis(fpa, test_images, 'one_sample', rfx_path=rfx_path) print("Wrote everything in %s" % write_dir)