Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non parallel workflow for integration testing #20

Merged
merged 13 commits into from
Oct 29, 2021
3 changes: 1 addition & 2 deletions connPFM/deconvolution/compute_slars.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ def main(argv):
LGR.info("Number of voxels: {}".format(nvoxels))

hrf = np.load(hrf_file)

for vox_idx in range(nvoxels):
sl.stability_lars(hrf, y[:, voxel + vox_idx])
sl.stability_lars(hrf, np.expand_dims(y[:, voxel + vox_idx], axis=-1))
auc[:, vox_idx] = np.squeeze(sl.auc)
LGR.info(
"AUC of voxel {}/{} calculated and stored...".format(str(vox_idx + 1), str(nvoxels))
Expand Down
9 changes: 7 additions & 2 deletions connPFM/deconvolution/compute_slars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
#$ -e /bcbl/home/public/PARK_VFERRER/PFM_data/slars_err.txt
#$ -S /bin/bash
#$ -q short.q

if [[ -z "${INPUT_ARGS}" ]]; then
if [[ ! -z "$1" ]]; then
INPUT_ARGS="$*"
fi
fi
eurunuela marked this conversation as resolved.
Show resolved Hide resolved
module unload python/python3.6
module load python/venv
source activate /bcbl/home/public/PARK_VFERRER/py38
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
eurunuela marked this conversation as resolved.
Show resolved Hide resolved

python -u /bcbl/home/public/PARK_VFERRER/PFM/Scripts/compute_slars.py $INPUT_ARGS
python -u $SCRIPT_DIR/compute_slars.py $INPUT_ARGS
108 changes: 67 additions & 41 deletions connPFM/deconvolution/stability_lars_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,8 @@ def run_stability_lars(data, hrf, temp, jobs, username, niter, maxiterfactor):

last = 0
LGR.info("Numer of voxels: {}".format(nvoxels))

for job_idx in range(jobs):
jobs_left = jobs - job_idx
voxels_left = nvoxels - last
voxels_job = int(np.ceil(voxels_left / jobs_left))
if job_idx == 0:
first = 0
last = first + voxels_job - 1
elif job_idx != (jobs - 1):
first = last + 1
last = first + voxels_job - 1
elif job_idx == (jobs - 1):
first = last + 1
last = nvoxels
LGR.info("First voxel: {}".format(first))
LGR.info("Last voxel: {}".format(last))

jobname = "lars" + str(job_idx)
if jobs == 0:
LGR.info("non paraleized option for testing")
input_parameters = (
"--data {} --hrf {} --nscans {} --maxiterfactor {} --nsurrogates {}"
" --nte {} --mode {} --tempdir {} --first {} --last {} --voxels {}"
Expand All @@ -68,36 +52,78 @@ def run_stability_lars(data, hrf, temp, jobs, username, niter, maxiterfactor):
nTE,
str(1),
temp,
int(first),
int(last),
int(0),
int(data.shape[1]),
nvoxels,
job_idx,
0,
)
)
subprocess.call(
"qsub "
+ " -N "
+ jobname
+ ' -v INPUT_ARGS="'
+ input_parameters
+ '"'
+ " /bcbl/home/public/PARK_VFERRER/PFM/Scripts/compute_slars.sh",
f" bash {os.path.dirname(os.path.abspath(__file__))}/compute_slars.sh "
+ input_parameters,
shell=True,
)
auc_filename = temp + "/auc_" + str(0) + ".npy"
auc = np.load(auc_filename)
else:
for job_idx in range(jobs):
jobs_left = jobs - job_idx
voxels_left = nvoxels - last
voxels_job = int(np.ceil(voxels_left / jobs_left))
if job_idx == 0:
first = 0
last = first + voxels_job - 1
elif job_idx != (jobs - 1):
first = last + 1
last = first + voxels_job - 1
elif job_idx == (jobs - 1):
first = last + 1
last = nvoxels
LGR.info("First voxel: {}".format(first))
LGR.info("Last voxel: {}".format(last))

jobname = "lars" + str(job_idx)
input_parameters = (
"--data {} --hrf {} --nscans {} --maxiterfactor {} --nsurrogates {}"
" --nte {} --mode {} --tempdir {} --first {} --last {} --voxels {}"
" --n_job {}".format(
data_filename,
filename_hrf,
str(nscans),
str(maxiterfactor),
niter,
nTE,
str(1),
temp,
int(first),
int(last),
nvoxels,
job_idx,
)
)
subprocess.call(
"qsub "
+ " -N "
+ jobname
+ ' -v INPUT_ARGS="'
+ input_parameters
+ '"'
+ f" {os.path.dirname(os.path.abspath(__file__))}/compute_slars.sh ",
shell=True,
)

while int(bget("qstat -u " + username + " | grep -v C | grep -c short" + username)[0]) > (
jobs - 1
):
time.sleep(1)

while int(bget("qstat -u " + username + " | grep -F 'lars' | grep -c " + username)[0]) > 0:
time.sleep(0.5)
while int(
bget("qstat -u " + username + " | grep -v C | grep -c short" + username)[0]
) > (jobs - 1):
time.sleep(1)

for job_idx in range(jobs):
auc_filename = temp + "/auc_" + str(job_idx) + ".npy"
if job_idx == 0:
auc = np.load(auc_filename)
else:
auc = np.hstack((auc, np.load(auc_filename)))
while int(bget("qstat -u " + username + " | grep -F 'lars' | grep -c " + username)[0]) > 0:
time.sleep(0.5)

for job_idx in range(jobs):
auc_filename = temp + "/auc_" + str(job_idx) + ".npy"
if job_idx == 0:
auc = np.load(auc_filename)
else:
auc = np.hstack((auc, np.load(auc_filename)))
return auc