def LOCAL_FUNCTION_get_5Hz_frames_from_25Hz_frames(frames_25Hz):
    n_frames = np.shape(frames_25Hz)[0]
    W = np.shape(frames_25Hz)[1]

    frames_5Hz = np.zeros((n_frames/5,W,W))
    pb = ProgressBar(W)
    for x in range(W):
        pb.animate(x+1)
        for y in range(W):
            frames_5Hz[:,x,y] = (frames_25Hz[:,x,y]).reshape(-1,5).mean(axis=1)
    return frames_5Hz
Ejemplo n.º 2
0
def convolve_s_with_hrf(S,S_times,hrf,TR_times):
	X = np.shape(S)[0]
	Y = np.shape(S)[1]
	s_conv_hrf = np.zeros((X,Y,len(TR_times)))
	pb = ProgressBar(X)
	for x in range(X):
		pb.animate(x+1)
		for y in range(Y):
			s = S[x,y,:]
			hp = np.convolve(s, hrf)[:(np.shape(s)[0])]
			hp_interp = np.interp(TR_times,S_times,hp)
			s_conv_hrf[x,y,:] = hp_interp
	return s_conv_hrf
Ejemplo n.º 3
0
def convolve_s_with_hrf(S, S_times, hrf, TR_times):
    X = np.shape(S)[0]
    Y = np.shape(S)[1]
    s_conv_hrf = np.zeros((X, Y, len(TR_times)))
    pb = ProgressBar(X)
    for x in range(X):
        pb.animate(x + 1)
        for y in range(Y):
            s = S[x, y, :]
            hp = np.convolve(s, hrf)[:(np.shape(s)[0])]
            hp_interp = np.interp(TR_times, S_times, hp)
            s_conv_hrf[x, y, :] = hp_interp
    return s_conv_hrf
Ejemplo n.º 4
0
def vol_to_voxels(vol):
	print('vol_to_voxels(vol)')
	XYZT = np.shape(vol)
	mask = vol[:,:,:,0].copy()
	mask[mask>0]=1
	mask[mask<=0]=0
	n_voxels = np.sum(mask)
	n_TRs = XYZT[3]
	voxels = np.zeros((n_TRs, n_voxels))
	vox_xyzs = np.zeros((n_voxels,3))
	ctr = 0
	pb = ProgressBar(XYZT[0])
	for x in range(XYZT[0]):
		pb.animate(x+1)
		for y in range(XYZT[1]):
			for z in range(XYZT[2]):
				if mask[x,y,z]:
					voxels[:,ctr] = (vol[x,y,z,:]-np.mean(vol[x,y,z,:]))/np.std(vol[x,y,z,:])
					vox_xyzs[ctr,:] = [x,y,z]
					ctr += 1
	return voxels,vox_xyzs