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

[wip] adding afni examples #51

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
no_output_timeout: 60m
command: |
source ~/.bashrc
pytest -vs tests/test_basic_examples.py
pytest -vs tests
- store_artifacts:
path: /home/circleci/regtests
3 changes: 2 additions & 1 deletion altair_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def barplot_all(self, var_l, y_scale=None, y_max_check=False, default_col="test"
res_transf = res_plot.reset_index().melt(['env', 'index'])
if y_scale: #should be a tuple, TODO
if y_max_check:
y_max = round(self.results_flat[var_l].max().max() + .1, 2)
# might want to use #round(self.results_flat[var_l].max().max() + .1, 2)
y_max = self.results_flat[var_l].max().max() * 1.2
y_scale_update = (y_scale[0], y_max)
y_bar = alt.Y('value:Q', scale=alt.Scale(domain=y_scale_update))
else:
Expand Down
4 changes: 3 additions & 1 deletion cwl_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def _creating_workflow_cwl(self):
cmd_cwl["inputs"]["input_files_{}".format(ii)]["type"] = input_tuple[0]
cmd_cwl["inputs"]["input_files_{}".format(ii)]["inputBinding"] = {}
cmd_cwl["inputs"]["input_files_{}".format(ii)]["inputBinding"]["position"] = ii + 2
cmd_cwl["inputs"]["input_files_{}".format(ii)]["inputBinding"]["prefix"] = input_tuple[1]
# TODO: it should be changed (using dict instead of list?)
if input_tuple[1]:
cmd_cwl["inputs"]["input_files_{}".format(ii)]["inputBinding"]["prefix"] = input_tuple[1]


cmd_cwl["outputs"] = {}
Expand Down
6 changes: 2 additions & 4 deletions dashboard_template/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ d3.csv("output_all.csv", function(data) {
//tabulate(data, d3.keys(data[0]))
//grid.append(tabulate(grid, data, d3.keys(data[0])));

function update(columns_new){
// TODO: not sure if I have to update everything as in this function
function update(columns_new){
table.selectAll('thead').selectAll("tr").selectAll("th")
Expand Down Expand Up @@ -196,8 +197,6 @@ d3.csv("output_all.csv", function(data) {
.updateAxes();

update(usedaxis_list)


});

$("#selectEvents").on("select2:unselect", function(e) {
Expand All @@ -212,8 +211,7 @@ d3.csv("output_all.csv", function(data) {
.render()
.updateAxes();

update(usedaxis_list)

update(usedaxis_list)
});
});

Expand Down
61 changes: 61 additions & 0 deletions testing_functions/test_afni_stat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""Comparing statistics after AFNI run (out.ss_review.FT.txt file)"""
from __future__ import division
import os, json, pdb


def creating_dictionary(filename):
res_dict = {}
with open(filename) as f:
for line in f:
key_val = [k.strip() for k in line.split(":")]
if len(key_val) == 2:
try:
val = [float(v) for v in key_val[1].split()]
except ValueError:
continue
res_dict[key_val[0]] = val
return res_dict

def test_file_eq(file_out, file_ref=None, name=None, **kwargs):
out = {}
dict_out = creating_dictionary(file_out)
dict_ref = creating_dictionary(file_ref)

for key, val_r in dict_ref.items():
print("ALL KEYS: ", key, dict_ref[key], dict_out[key])
if (key not in dict_out.keys()) or (len(dict_out[key]) != len(dict_ref[key])):
error = -99999
else:
er_l = []
for ii in range(len(dict_ref[key])):
if dict_ref[key][ii] != 0:
er_l.append(round(1. * abs(dict_ref[key][ii] - dict_out[key][ii]) / dict_ref[key][ii], 5))
elif dict_ref[key][ii] == 0 and dict_out[key][ii] != 0:
er_l.append(1)
else:
er_l.append(0)
error = max(er_l)
if ("blur" in key or "ave" in key) and ("FWHM" not in key) and ("sresp" not in key):
out["max_rel_error: {}".format(key)] = error

report_filename = "report_{}.json".format(name)
print("TEST", report_filename)


with open(report_filename, "w") as f:
json.dump(out, f)


if __name__ == '__main__':
from argparse import ArgumentParser, RawTextHelpFormatter
parser = ArgumentParser(description=__doc__,
formatter_class=RawTextHelpFormatter)
parser.add_argument("-out", dest="file_out",
help="file with the output for testing")
parser.add_argument("-ref", dest="file_ref",
help="file with the reference output")
parser.add_argument("-name", dest="name",
help="name of the test provided by a user")
args = parser.parse_args()

test_file_eq(**vars(args))
3 changes: 2 additions & 1 deletion testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ def runner(workflow_dir):
wf = WorkflowRegtest(workflow_dir)
wf.run()
wf.merging_all_output()
wf.dashboard_workflow()
wf.dashboard_workflow()

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
60 90 120 180 240
120 150 180 210 270
0 60 120 150 240
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0 30 150 210 270
0 30 60 90 240
30 90 180 210 270
Loading