Skip to content
Snippets Groups Projects
Commit 0307d4c1 authored by Maximilian Schmidt, blaustein's avatar Maximilian Schmidt, blaustein
Browse files

Improve call of Rscript in compute_bold_signal and raise proper Error

parent e378d8d7
No related branches found
No related tags found
1 merge request!1Add all necessary files for the multi-area model
import numpy as np
import os
import subprocess
import sys
......@@ -32,7 +33,6 @@ fn = os.path.join(load_path,
'synaptic_input_{}.npy'.format(area))
synaptic_input = np.load(fn)
def bold_R_parser(fn):
f = open(fn, 'r')
# skip first line
......@@ -51,7 +51,10 @@ out_fn = os.path.join(save_path,
'bold_syn_input_{}.txt'.format(area))
np.savetxt(fn, synaptic_input / np.max(synaptic_input))
os.system('Rscript --vanilla compute_bold_signal.R {} {}'.format(fn, out_fn))
try:
subprocess.run(['Rscript', '--vanilla', 'compute_bold_signal.R {} {}'.format(fn, out_fn)])
except FileNotFoundError:
raise FileNotFoundError("Executing R failed. Did you install R?")
bold_signal = bold_R_parser(out_fn)
fn = os.path.join(save_path,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment