Skip to content

Commit

Permalink
Merge pull request #1 from Shotgunosine/task_fix
Browse files Browse the repository at this point in the history
Task fix
  • Loading branch information
Shotgunosine authored Dec 21, 2017
2 parents 7a97edd + f2a5adf commit 17feff4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 33 deletions.
68 changes: 42 additions & 26 deletions reports/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
$("#nrtodo").text(counts.registration["-1"])
}

function qc_update(subj_id, stage, value) {
subjs[subj_id - 1][stage] = parseInt(value)
function qc_update(run_id, stage, value) {
subjs[run_id][stage] = parseInt(value)
updateCounts();
}

Expand Down Expand Up @@ -124,30 +124,46 @@ <h1>afni_proc.py: group report</h1>
{% for config in configs %}
<div class="subject mt-3 mb-3 pt-3 pb-3">
<script type="text/javascript">
var subj_qc = {id:{{ config['subj_id'] }}, motion:null, registration:null}
{% if config['session_label'] %}
var subj_qc = {id:{{ config['report_num'] }}, subject: "{{ config['subj_id'] }}", session: "{{ config['session_label'] }}", task:"{{ config['task_label'] }}", motion:null, registration:null}
{% else %}
var subj_qc = {id:{{ config['report_num'] }}, subject: "{{ config['subj_id'] }}", session: null, task:"{{ config['task_label'] }}", motion:null, registration:null}
{% endif %}
</script>

<h2>Subject {{ config['subj_id'] }} Summary</h2>
{% if config['session_label'] %}
<h2>Subject {{ config['subj_id'] }}, Session {{ config['session_label'] }}, {{ config['task_label'] }} Summary</h2>
{% else %}
<h2>Subject {{ config['subj_id'] }}, {{ config['task_label'] }} Summary</h2>
{% endif %}
<ul class="simple">
<li>Subject ID: {{ config['subj_id'] }}.</li>
{% if config['session_label'] %}
<li>Session: {{ config['session_label'] }}</li>
{% endif %}
<li>Task: {{ config['task_label'] }}</li>
<li>Number of runs: {{ config['num_runs'] }}</li>
<li>Blocks run: {{ config['blocks'] }}.</li>

{% if config['warnings'] %}
<li>Warnings:
<ul class="sub-simple">
{% for warn_name, warn_text in config['warnings'].items() %}
<li>{{ warn_name }}: {{ warn_text }}</li>
<li>{{ warn_name }}:
{% for line in warn_text %}
{{ line }}<br />
{% endfor %}
</li>
{% endfor %}
</ul>
</li>
{% endif %}
</ul>

{% if config['motion_report'] %}
<h3 class="muted">Subject {{ config['subj_id'] }} Motion Report</h3>
<h3 class="muted">Motion Report</h3>
<div class="radio">
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['subj_id'] }}, 'motion', this.value)"> Good </label>
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['subj_id'] }}, 'motion', this.value)"> Bad</label>
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['report_num'] }}, 'motion', this.value)"> Good </label>
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['report_num'] }}, 'motion', this.value)"> Bad</label>
</div>
<div class="embeded-report">
{{ config['motion_report'] }}
Expand All @@ -158,15 +174,15 @@ <h3 class="muted">Subject {{ config['subj_id'] }} Motion Report</h3>
{% endif %}

{% if config['volreg_report_anat'] %}
<h3>Subject {{ config['subj_id'] }} Registration</h3>
<h3>Registration</h3>
<div class="radio">
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['subj_id'] }}, 'registration', this.value)"> Good </label>
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['subj_id'] }}, 'registration', this.value)"> Bad</label>
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['report_num'] }}, 'registration', this.value)"> Good </label>
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['report_num'] }}, 'registration', this.value)"> Bad</label>
</div>
<div class="embeded-report">
<div>
<canvas id="3Dviewer_{{ config['subj_id'] }}", onclick="change_{{ config['subj_id'] }}();" resize>
<img id="spriteImg_{{ config['subj_id'] }}" class="hidden" src="data:image/jpeg;base64,{{ config['volreg_report_anat'] }}">
<canvas id="3Dviewer_{{ config['report_num'] }}", onclick="change_{{ config['report_num'] }}();" resize>
<img id="spriteImg_{{ config['report_num'] }}" class="hidden" src="data:image/jpeg;base64,{{ config['volreg_report_anat'] }}">
</div>
</div>
<script type="text/javascript">
Expand All @@ -182,29 +198,29 @@ <h3>Subject {{ config['subj_id'] }} Registration</h3>

<script type="text/javascript">

var image_tracker_{{ config['subj_id'] }} = 'anat';
var anat_src_{{ config['subj_id'] }} = null
var image_tracker_{{ config['report_num'] }} = 'anat';
var anat_src_{{ config['report_num'] }} = null

function change_{{ config['subj_id'] }}(){
var image = document.getElementById("spriteImg_{{ config['subj_id'] }}");
function change_{{ config['report_num'] }}(){
var image = document.getElementById("spriteImg_{{ config['report_num'] }}");

if(image_tracker_{{ config['subj_id'] }}=='anat'){
if(anat_src_{{ config['subj_id'] }}){
if(image_tracker_{{ config['report_num'] }}=='anat'){
if(anat_src_{{ config['report_num'] }}){
}else{
anat_src_{{ config['subj_id'] }}=image.src
anat_src_{{ config['report_num'] }}=image.src
}
image.src="data:image/jpeg;base64,{{ config['volreg_report_func'] }}";
image_tracker_{{ config['subj_id'] }}='func';
image_tracker_{{ config['report_num'] }}='func';
}else{
image.src=anat_src_{{ config['subj_id'] }};
image_tracker_{{ config['subj_id'] }}='anat';
image.src=anat_src_{{ config['report_num'] }};
image_tracker_{{ config['report_num'] }}='anat';
}
}

$( window ).load(function() {
var brain = brainsprite({
canvas: "3Dviewer_{{ config['subj_id'] }}",
sprite: "spriteImg_{{ config['subj_id'] }}",
canvas: "3Dviewer_{{ config['report_num'] }}",
sprite: "spriteImg_{{ config['report_num'] }}",
nbSlice: { 'Y':{{ config['anat_ap_ext'] }} , 'Z':{{ config['anat_is_ext'] }} }
});
});
Expand Down
17 changes: 13 additions & 4 deletions reports/individual.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,26 @@ <h1>afni_proc.py: individual report</h1>

<h2>Summary</h2>
<ul class="simple">
<li>Subject ID: {{ subj_id }}.</li>
<li>Subject ID: {{ subj_id }}</li>
{% if session_label %}
<li>Session: {{ session_label }}</li>
{% endif %}
<li>Task: {{ task_label }}</li>
<li>Number of runs: {{ num_runs }}</li>
<li>Blocks run: {{ blocks }}.</li>
<li>AP extent: {{ anat_ap_ext }}.</li>
<li>IS extent: {{ anat_is_ext }}.</li>
<li>AP extent: {{ anat_ap_ext }}</li>
<li>IS extent: {{ anat_is_ext }}</li>


{% if warnings %}
<li>Warnings:
<ul class="sub-simple">
{% for warn_name, warn_text in warnings.items() %}
<li>{{ warn_name }}: {{ warn_text }}</li>
<li>{{ warn_name }}:
{% for line in warn_text %}
{{ line }}<br />
{% endfor %}
</li>
{% endfor %}
</ul>
</li>
Expand Down
12 changes: 9 additions & 3 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def run(command, env={}, shell=False):

args = parser.parse_args()

bad_chars = ['`', '|', '&', ';', '>', '<', '$', '?', '(', ')', '\.', ':', '[', ']']
bad_chars = ['`', '|', '&', ';', '>', '<', '$', '?', '\.', ':', '[', ']']

if args.afni_proc is not None:
cmd_skeleton = args.afni_proc
Expand Down Expand Up @@ -257,6 +257,7 @@ def run(command, env={}, shell=False):
# make tasks to analyze

all_configs = []
report_num = 0
for subject_label in subjects_to_analyze:

# get anatomical path
Expand All @@ -279,10 +280,8 @@ def run(command, env={}, shell=False):
sessions_to_analyze = ['']

for session_label in sessions_to_analyze:

if sessions_exist:
session_out_dir = os.path.join(subj_out_dir,"ses-%s"%session_label)

else:
session_out_dir = subj_out_dir
os.makedirs(session_out_dir, exist_ok = True)
Expand Down Expand Up @@ -341,7 +340,13 @@ def run(command, env={}, shell=False):
pb_lod.append(pbd)
pb_df = pd.DataFrame(pb_lod)
config['subj_id'] = pb_df.subj.unique()[0]
config['task_label'] = task_label
config['num_runs'] = len(pb_df.run.unique())
config['blocks'] = ' '.join(pb_df.block.unique())
config['report_num'] = report_num
report_num += 1
if session_label != '':
config['session_label'] = session_label

try:
mot_path = make_motion_plot(task_out_dir, subject_label)
Expand All @@ -360,6 +365,7 @@ def run(command, env={}, shell=False):
if os.path.getsize(wf_path) > 0:
with open(wf_path, 'r') as h:
warns[wf] = h.readlines()
warns[wf] = [ww.replace('\n', '') for ww in warns[wf]]
except FileNotFoundError:
pass
if len(warns) > 0:
Expand Down

0 comments on commit 17feff4

Please sign in to comment.