def correlation_map_without_convoluation(data, cond_filename):
  n_trs = data.shape[-1] + 5
  time_course = events2neural_rounded(cond_filename, TR, n_trs) 
  time_course=time_course[5:]
  correlations = np.zeros(data.shape[:-1])
  for i in general_utils.vol_index_iter(data.shape[:-1]):
    vox_values = data[i]
    correlations[i] = np.corrcoef(time_course, vox_values)[1, 0]
Example #2
0
def correlation_map_without_convoluation(data, cond_filename):
    n_trs = data.shape[-1] + 5
    time_course = events2neural_rounded(cond_filename, TR, n_trs)
    time_course = time_course[5:]
    correlations = np.zeros(data.shape[:-1])
    for i in general_utils.vol_index_iter(data.shape[:-1]):
        vox_values = data[i]
        correlations[i] = np.corrcoef(time_course, vox_values)[1, 0]
Example #3
0
def correlation_map_without_convoluation(data, cond_filename):
  """
  Generate a cross-correlation per voxel between BOLD signals and a square wave
  baseline function, which represents the boolean array of the on-off time 
  course. Assume that the first 5 images are already dropped.
  """
  n_trs = data.shape[-1] + 5
  time_course = events2neural_rounded(cond_filename, TR, n_trs)[5:]
  correlations = np.zeros(data.shape[:-1])

  for i in gu.vol_index_iter(data.shape[:-1]):
    vox_values = data[i]
    r = np.corrcoef(time_course, vox_values)[1, 0]
    if np.isnan(r):
      r = 0
    correlations[i] = r

  return correlations
Example #4
0
def correlation_map_without_convoluation_linear(data, cond_filename):
  """
  This is different from correlation_map_without_convoluation in that it accepts a 2d data 
  (n_samples, n_time_slices) so that it is suitable for working with
  brain masks.
  """
  n_trs = data.shape[-1] + 5
  time_course = events2neural_rounded(cond_filename, TR, n_trs)[5:]
  correlations = np.zeros(data.shape[:-1])

  for i in range(data.shape[0]):
    vox_values = data[i]
    r = np.corrcoef(time_course, vox_values)[1, 0]
    if np.isnan(r):
      r = 0
    correlations[i] = r

  return correlations
Example #5
0
def correlation_map_without_convoluation(data, cond_filename):
    """
  Generate a cross-correlation per voxel between BOLD signals and a square wave
  baseline function, which represents the boolean array of the on-off time 
  course. Assume that the first 5 images are already dropped.
  """
    n_trs = data.shape[-1] + 5
    time_course = events2neural_rounded(cond_filename, TR, n_trs)[5:]
    correlations = np.zeros(data.shape[:-1])

    for i in gu.vol_index_iter(data.shape[:-1]):
        vox_values = data[i]
        r = np.corrcoef(time_course, vox_values)[1, 0]
        if np.isnan(r):
            r = 0
        correlations[i] = r

    return correlations
Example #6
0
def correlation_map_without_convoluation_linear(data, cond_filename):
    """
  This is different from correlation_map_without_convoluation in that it accepts a 2d data 
  (n_samples, n_time_slices) so that it is suitable for working with
  brain masks.
  """
    n_trs = data.shape[-1] + 5
    time_course = events2neural_rounded(cond_filename, TR, n_trs)[5:]
    correlations = np.zeros(data.shape[:-1])

    for i in range(data.shape[0]):
        vox_values = data[i]
        r = np.corrcoef(time_course, vox_values)[1, 0]
        if np.isnan(r):
            r = 0
        correlations[i] = r

    return correlations
Example #7
0
def correlation_map_without_convoluation_linear(data, cond_filename):
    """
  This is different from correlation_map_without_convoluation in that it accepts a 2d data 
  (n_samples, n_time_slices) and compute the correlations based on the square-wave time course 
  using the given condition file. 

  """
    n_trs = data.shape[-1] + 5
    time_course = events2neural_rounded(cond_filename, TR, n_trs)
    time_course = time_course[5:]
    correlations = np.zeros(data.shape[:-1])

    for i in range(data.shape[0]):
        vox_values = data[i]
        r = np.corrcoef(time_course, vox_values)[1, 0]
        if np.isnan(r):
            r = 0
        correlations[i] = r

    return correlations
Example #8
0
def correlation_map_without_convoluation_linear(data, cond_filename):
  """
  This is different from correlation_map_without_convoluation in that it accepts a 2d data 
  (n_samples, n_time_slices) and compute the correlations based on the square-wave time course 
  using the given condition file. 

  """
  n_trs = data.shape[-1] + 5
  time_course = events2neural_rounded(cond_filename, TR, n_trs)
  time_course = time_course[5:]
  correlations = np.zeros(data.shape[:-1])

  for i in range(data.shape[0]):
    vox_values = data[i]
    r = np.corrcoef(time_course, vox_values)[1, 0]
    if np.isnan(r):
      r = 0
    correlations[i] = r

  return correlations
ext_outlier = outliers_utils.extend_diff_outliers(rms_outlier)
mask = np.ones(data.shape[-1])
mask[ext_outlier] = 0
mask = np.array(mask, dtype=bool)
data_rem=data[..., mask]
print("7.After dropping the extended RMS outliers, now the data has the shape %r.") %str(data_rem.shape)
 
#basic statistics
np.amin(data_rem) #0
np.amax(data_rem) #1550
np.mean(data_rem) #137.08845107920848

#get the correlation matrix w/ outliers
TR=2.5
n_trs = img.shape[-1]
time_course = events2neural_rounded(cond_filename, 2.5, n_trs) 
plt.plot(time_course)
plt.title("time_course")
plt.savefig("results/time_course.png")
plt.show()
print("8.The time_course is plotted and saved as 'time_course.png'")
time_course=time_course[5:]
correlations = np.zeros(data.shape[:-1])
for i in range(data.shape[0]):
    for j in range(data.shape[1]):
        for k in range(data.shape[2]):
            vox_values = data[i, j, k]
            correlations[i, j, k] = np.corrcoef(time_course, vox_values)[1, 0]
plt.imshow(correlations[:, :, 18], cmap='gray')
plt.colorbar()
plt.savefig("results/correlation_middle.png")
Example #10
0
mask[ext_outlier] = 0
mask = np.array(mask, dtype=bool)
data_rem = data[..., mask]
print(
    "7.After dropping the extended RMS outliers, now the data has the shape %r."
) % str(data_rem.shape)

#basic statistics
np.amin(data_rem)  #0
np.amax(data_rem)  #1550
np.mean(data_rem)  #137.08845107920848

#get the correlation matrix w/ outliers
TR = 2.5
n_trs = img.shape[-1]
time_course = events2neural_rounded(cond_filename, 2.5, n_trs)
plt.plot(time_course)
plt.title("time_course")
plt.savefig("results/time_course.png")
plt.show()
print("8.The time_course is plotted and saved as 'time_course.png'")
time_course = time_course[5:]
correlations = np.zeros(data.shape[:-1])
for i in range(data.shape[0]):
    for j in range(data.shape[1]):
        for k in range(data.shape[2]):
            vox_values = data[i, j, k]
            correlations[i, j, k] = np.corrcoef(time_course, vox_values)[1, 0]
plt.imshow(correlations[:, :, 18], cmap='gray')
plt.colorbar()
plt.savefig("results/correlation_middle.png")