############## significant voxels
# Create contrast matrix for each beta:
t, p = linear_modeling.t_stat(X, [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], beta, MRSS, df)
# using Bonferroni correction for setting threshold
threshold = 0.05 / n_trs
sig_pos = np.where(p <= threshold)
print("The activated voxels under threshold of 0.05/133 are " + str(sig_pos[1]))
# none is significant

############## plotting of significant voxels
# reshape p values
p_val = np.ones(vol_shape + (p.shape[0],))
p_val[in_brain_mask, :] = p.T
########## Beta 1 + ... + Beta 6
linear_modeling.p_map(1, 1, p_val[..., 0], threshold)
plt.savefig("../../../data/maps/dct_sig_p_map.png")
plt.close()

# using a higher threshold
threshold = 0.05 / 110
sig_pos = np.where(p <= threshold)
print("The activated voxels under threshold of 0.05/110 are " + str(sig_pos[1]))
linear_modeling.p_map(1, 1, p_val[..., 0], threshold)
plt.savefig("../../../data/maps/dct_sig2_p_map.png")
plt.close()

############## CV select the model
result = np.array([])

cv = linear_modeling.split_data(y)
fig.subplots_adjust(right=0.85)
cax = fig.add_axes([0.9, 0.15, 0.03, 0.7])
fig.suptitle("Back Level for P-value", fontsize=20)
fig.colorbar(io, cax=cax)
plt.savefig("../../../data/maps/block_p_back_map.png")

# Visualizing t values for the back slice
fig, axes = plt.subplots(nrows=4, ncols=4)
for i, ax in zip(range(25, 58, 2), axes.flat):
    im = ax.imshow(mean_data[:, :, i], cmap="gray", alpha=0.5)
    i0 = ax.imshow(t_vols[:, :, i, 0], cmap=nice_cmap, alpha=0.5)
fig.subplots_adjust(right=0.85)
cax = fig.add_axes([0.9, 0.15, 0.03, 0.7])
fig.colorbar(io, cax=cax)
plt.savefig("../../../data/maps/block_t_back_map.png")

# generate p-map
linear_modeling.p_map(1, 1, p_vols, 0.05)
plt.savefig("../../../data/maps/block_p_map_0_05.png")
linear_modeling.p_map(1, 1, p_vols, 0.05 / 133)
plt.savefig("../../../data/maps/block_p_map.png")

# P-value of auxilliary regression
plt.figure()
plt.plot(range(stat_table.shape[0]), stat_table)
plt.xlabel("Voxel")
plt.ylabel("P-value of auxilliary regression")
line = plt.axhline(0.01, ls="--", color="red")
plt.title("Hypothesis test on Heteroscedasticity")
plt.savefig("../../../data/GLS/block_p_auxi.png")
Example #3
0
# Create contrast matrix for each beta:
t, p = linear_modeling.t_stat(X, [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
                              beta, MRSS, df)
# using Bonferroni correction for setting threshold
threshold = 0.05 / n_trs
sig_pos = np.where(p <= threshold)
print('The activated voxels under threshold of 0.05/133 are ' +
      str(sig_pos[1]))
# none is significant

############## plotting of significant voxels
# reshape p values
p_val = np.ones(vol_shape + (p.shape[0], ))
p_val[in_brain_mask, :] = p.T
########## Beta 1 + ... + Beta 6
linear_modeling.p_map(1, 1, p_val[..., 0], threshold)
plt.savefig("../../../data/maps/dct_sig_p_map.png")
plt.close()

# using a higher threshold
threshold = 0.05 / 110
sig_pos = np.where(p <= threshold)
print('The activated voxels under threshold of 0.05/110 are ' +
      str(sig_pos[1]))
linear_modeling.p_map(1, 1, p_val[..., 0], threshold)
plt.savefig("../../../data/maps/dct_sig2_p_map.png")
plt.close()

############## CV select the model
result = np.array([])