def init(random_state=None, a=-.4, b=.28, n_samples=16): if random_state is None: random_state = np.random.randint(2 ** 31 - 1) random_state = check_random_state(random_state) tree = htree.construct_tree(arity=4, depth=2) # Create sample Theta = phase_transition._get_mx(a, b, mx_type='smith') X = random_state.normal(size=(n_samples, Theta.shape[0])) return tree, X, Theta
from nilearn import masking from nilearn import signal import htree if getuser() == 'rphlypo' and socket.gethostname() != 'drago': ROOT_DIR = '/volatile' else: ROOT_DIR = '/storage' subject_dirs = sorted(glob.glob( os.path.join(ROOT_DIR, 'data/HCP/Q2/*/MNINonLinear/Results'))) N_JOBS = min(cpu_count() - 4, 36) TREE = htree.construct_tree() def out_brain_confounds(epi_img, mask_img): """ Return the 5 principal components of the signal outside the brain. """ mask_img = check_niimg(mask_img) mask_img = nibabel.Nifti1Image( np.logical_not(mask_img.get_data()).astype(np.int), mask_img.get_affine()) sigs = masking.apply_mask(epi_img, mask_img) # Remove the constant signals non_constant = np.any(np.diff(sigs, axis=0) != 0, axis=0) sigs = sigs[:, non_constant] sigs = signal.clean(sigs, detrend=True)