<commit_before>from __future__ import division
from sys import argv
import numpy as np
import matplotlib.pyplot as plt
import nibabel as nib
import convo_response

# Load f1, the BOLD image.
f1 = argv[1] # task001_run001/filtered_func_data_mni
img = nib.load('../../../data/sub001/BOLD/' + f1 + '.nii.gz')
data = img.get_data()

# Get n_trs
n_trs = data.shape[-1]

# Load f2, the condition file.
f2 = argv[2] # task001_run001/cond001
cond_data = np.loadtxt('../../../data/sub001/model/model001/onsets/' + f2 + '.txt')
getname = f2.replace('/', '_').replace('d', 'v')

# Load the specified TR
TR = 2.5
# Specify the desired level of resolution
tr_div = 100

# Use rescale_con function to get the high resolution time and neural prediction
# time course
high_res_neural, high_res_times = convo_response.rescale_cond(cond_data, n_trs,
                                                              TR, tr_div)
# Plot the high resolution convolved values
plt.plot(high_res_times, high_res_neural)
plt.xlabel('Time (seconds)')
plt.ylabel('High resolution neural prediction')
plt.savefig('../../../data/convo/High_resolution_neural_' + getname + '.png')

# Use construction_conv function to get the convolved high resolution
# hemodynamic response.
high_res_hemo, high_res_times = convo_response.constructing_convo(high_res_neural,
                                                  high_res_times)
# Write the result to a text file.
np.savetxt('../../../data/convo/' + getname + '.txt', high_res_hemo)
plt.plot(high_res_times, high_res_hemo)
plt.xlabel('Time (Seconds)')
plt.savefig('../../../data/convo/High_resolution_' + getname + '.png')<commit_msg>update a little for convo_script<commit_after>from __future__ import division
from sys import argv
import numpy as np
import matplotlib.pyplot as plt
import nibabel as nib
import convo_response

# Load f1, the BOLD image.
f1 = argv[1] # task001_run001
img = nib.load('../../../data/sub001/BOLD/' + f1 + '/filtered_func_data_mni.nii.gz')
data = img.get_data()

# Get n_trs
n_trs = data.shape[-1]

# For loop to generate all convo-reponse
block_num = [1,4,5]
for i in block_num:
	cond_data = np.loadtxt('../../../data/sub001/onsets/' + f1 + '/cond00' + str(i) + '.txt')
	getname = f1 + '/cond00' + str(i)
	getname = getname.replace('/', '_').replace('d', 'v')

	# Load the specified TR
	TR = 2.5
	# Specify the desired level of resolution
	tr_div = 100

	# Use rescale_con function to get the high resolution time and neural prediction
	# time course
	high_res_neural, high_res_times = convo_response.rescale_cond(cond_data, n_trs,
	                                                              TR, tr_div)
	# Plot the high resolution convolved values
	plt.plot(high_res_times, high_res_neural)
	plt.xlabel('Time (seconds)')
	plt.ylabel('High resolution neural prediction')
	plt.savefig('../../../data/convo/High_resolution_neural_' + getname + '.png')

	# Use construction_conv function to get the convolved high resolution
	# hemodynamic response.
	high_res_hemo, high_res_times = convo_response.constructing_convo(high_res_neural,
	                                                  high_res_times)
	# Write the result to a text file.
	np.savetxt('../../../data/convo/' + getname + '.txt', high_res_hemo)
	plt.plot(high_res_times, high_res_hemo)
	plt.xlabel('Time (Seconds)')
	plt.savefig('../../../data/convo/High_resolution_' + getname + '.png')
{'fraction_non_alphanumeric': 0.13056292366637196, 'fraction_numerical': 0.0206307102858827, 'mean_word_length': 3.2057001239157374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2644715', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1123, 'n_words': 293}