Skip to content

Commit 17feff4

Browse files
authored
Merge pull request #1 from Shotgunosine/task_fix
Task fix
2 parents 7a97edd + f2a5adf commit 17feff4

File tree

3 files changed

+64
-33
lines changed

3 files changed

+64
-33
lines changed

reports/group.html

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
$("#nrtodo").text(counts.registration["-1"])
5151
}
5252

53-
function qc_update(subj_id, stage, value) {
54-
subjs[subj_id - 1][stage] = parseInt(value)
53+
function qc_update(run_id, stage, value) {
54+
subjs[run_id][stage] = parseInt(value)
5555
updateCounts();
5656
}
5757

@@ -124,30 +124,46 @@ <h1>afni_proc.py: group report</h1>
124124
{% for config in configs %}
125125
<div class="subject mt-3 mb-3 pt-3 pb-3">
126126
<script type="text/javascript">
127-
var subj_qc = {id:{{ config['subj_id'] }}, motion:null, registration:null}
127+
{% if config['session_label'] %}
128+
var subj_qc = {id:{{ config['report_num'] }}, subject: "{{ config['subj_id'] }}", session: "{{ config['session_label'] }}", task:"{{ config['task_label'] }}", motion:null, registration:null}
129+
{% else %}
130+
var subj_qc = {id:{{ config['report_num'] }}, subject: "{{ config['subj_id'] }}", session: null, task:"{{ config['task_label'] }}", motion:null, registration:null}
131+
{% endif %}
128132
</script>
129-
130-
<h2>Subject {{ config['subj_id'] }} Summary</h2>
133+
{% if config['session_label'] %}
134+
<h2>Subject {{ config['subj_id'] }}, Session {{ config['session_label'] }}, {{ config['task_label'] }} Summary</h2>
135+
{% else %}
136+
<h2>Subject {{ config['subj_id'] }}, {{ config['task_label'] }} Summary</h2>
137+
{% endif %}
131138
<ul class="simple">
132139
<li>Subject ID: {{ config['subj_id'] }}.</li>
140+
{% if config['session_label'] %}
141+
<li>Session: {{ config['session_label'] }}</li>
142+
{% endif %}
143+
<li>Task: {{ config['task_label'] }}</li>
144+
<li>Number of runs: {{ config['num_runs'] }}</li>
133145
<li>Blocks run: {{ config['blocks'] }}.</li>
134146

135147
{% if config['warnings'] %}
136148
<li>Warnings:
137149
<ul class="sub-simple">
138150
{% for warn_name, warn_text in config['warnings'].items() %}
139-
<li>{{ warn_name }}: {{ warn_text }}</li>
151+
<li>{{ warn_name }}:
152+
{% for line in warn_text %}
153+
{{ line }}<br />
154+
{% endfor %}
155+
</li>
140156
{% endfor %}
141157
</ul>
142158
</li>
143159
{% endif %}
144160
</ul>
145161

146162
{% if config['motion_report'] %}
147-
<h3 class="muted">Subject {{ config['subj_id'] }} Motion Report</h3>
163+
<h3 class="muted">Motion Report</h3>
148164
<div class="radio">
149-
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['subj_id'] }}, 'motion', this.value)"> Good </label>
150-
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['subj_id'] }}, 'motion', this.value)"> Bad</label>
165+
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['report_num'] }}, 'motion', this.value)"> Good </label>
166+
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['report_num'] }}, 'motion', this.value)"> Bad</label>
151167
</div>
152168
<div class="embeded-report">
153169
{{ config['motion_report'] }}
@@ -158,15 +174,15 @@ <h3 class="muted">Subject {{ config['subj_id'] }} Motion Report</h3>
158174
{% endif %}
159175

160176
{% if config['volreg_report_anat'] %}
161-
<h3>Subject {{ config['subj_id'] }} Registration</h3>
177+
<h3>Registration</h3>
162178
<div class="radio">
163-
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['subj_id'] }}, 'registration', this.value)"> Good </label>
164-
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['subj_id'] }}, 'registration', this.value)"> Bad</label>
179+
<label><input type="radio" name="inlineRadio" id="inlineRating1" value="1" onclick="qc_update({{ config['report_num'] }}, 'registration', this.value)"> Good </label>
180+
<label><input type="radio" name="inlineRadio" id="inlineRating0" value="0" onclick="qc_update({{ config['report_num'] }}, 'registration', this.value)"> Bad</label>
165181
</div>
166182
<div class="embeded-report">
167183
<div>
168-
<canvas id="3Dviewer_{{ config['subj_id'] }}", onclick="change_{{ config['subj_id'] }}();" resize>
169-
<img id="spriteImg_{{ config['subj_id'] }}" class="hidden" src="data:image/jpeg;base64,{{ config['volreg_report_anat'] }}">
184+
<canvas id="3Dviewer_{{ config['report_num'] }}", onclick="change_{{ config['report_num'] }}();" resize>
185+
<img id="spriteImg_{{ config['report_num'] }}" class="hidden" src="data:image/jpeg;base64,{{ config['volreg_report_anat'] }}">
170186
</div>
171187
</div>
172188
<script type="text/javascript">
@@ -182,29 +198,29 @@ <h3>Subject {{ config['subj_id'] }} Registration</h3>
182198

183199
<script type="text/javascript">
184200

185-
var image_tracker_{{ config['subj_id'] }} = 'anat';
186-
var anat_src_{{ config['subj_id'] }} = null
201+
var image_tracker_{{ config['report_num'] }} = 'anat';
202+
var anat_src_{{ config['report_num'] }} = null
187203

188-
function change_{{ config['subj_id'] }}(){
189-
var image = document.getElementById("spriteImg_{{ config['subj_id'] }}");
204+
function change_{{ config['report_num'] }}(){
205+
var image = document.getElementById("spriteImg_{{ config['report_num'] }}");
190206

191-
if(image_tracker_{{ config['subj_id'] }}=='anat'){
192-
if(anat_src_{{ config['subj_id'] }}){
207+
if(image_tracker_{{ config['report_num'] }}=='anat'){
208+
if(anat_src_{{ config['report_num'] }}){
193209
}else{
194-
anat_src_{{ config['subj_id'] }}=image.src
210+
anat_src_{{ config['report_num'] }}=image.src
195211
}
196212
image.src="data:image/jpeg;base64,{{ config['volreg_report_func'] }}";
197-
image_tracker_{{ config['subj_id'] }}='func';
213+
image_tracker_{{ config['report_num'] }}='func';
198214
}else{
199-
image.src=anat_src_{{ config['subj_id'] }};
200-
image_tracker_{{ config['subj_id'] }}='anat';
215+
image.src=anat_src_{{ config['report_num'] }};
216+
image_tracker_{{ config['report_num'] }}='anat';
201217
}
202218
}
203219

204220
$( window ).load(function() {
205221
var brain = brainsprite({
206-
canvas: "3Dviewer_{{ config['subj_id'] }}",
207-
sprite: "spriteImg_{{ config['subj_id'] }}",
222+
canvas: "3Dviewer_{{ config['report_num'] }}",
223+
sprite: "spriteImg_{{ config['report_num'] }}",
208224
nbSlice: { 'Y':{{ config['anat_ap_ext'] }} , 'Z':{{ config['anat_is_ext'] }} }
209225
});
210226
});

reports/individual.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,26 @@ <h1>afni_proc.py: individual report</h1>
104104

105105
<h2>Summary</h2>
106106
<ul class="simple">
107-
<li>Subject ID: {{ subj_id }}.</li>
107+
<li>Subject ID: {{ subj_id }}</li>
108+
{% if session_label %}
109+
<li>Session: {{ session_label }}</li>
110+
{% endif %}
111+
<li>Task: {{ task_label }}</li>
112+
<li>Number of runs: {{ num_runs }}</li>
108113
<li>Blocks run: {{ blocks }}.</li>
109-
<li>AP extent: {{ anat_ap_ext }}.</li>
110-
<li>IS extent: {{ anat_is_ext }}.</li>
114+
<li>AP extent: {{ anat_ap_ext }}</li>
115+
<li>IS extent: {{ anat_is_ext }}</li>
111116

112117

113118
{% if warnings %}
114119
<li>Warnings:
115120
<ul class="sub-simple">
116121
{% for warn_name, warn_text in warnings.items() %}
117-
<li>{{ warn_name }}: {{ warn_text }}</li>
122+
<li>{{ warn_name }}:
123+
{% for line in warn_text %}
124+
{{ line }}<br />
125+
{% endfor %}
126+
</li>
118127
{% endfor %}
119128
</ul>
120129
</li>

run.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def run(command, env={}, shell=False):
217217

218218
args = parser.parse_args()
219219

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

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

259259
all_configs = []
260+
report_num = 0
260261
for subject_label in subjects_to_analyze:
261262

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

281282
for session_label in sessions_to_analyze:
282-
283283
if sessions_exist:
284284
session_out_dir = os.path.join(subj_out_dir,"ses-%s"%session_label)
285-
286285
else:
287286
session_out_dir = subj_out_dir
288287
os.makedirs(session_out_dir, exist_ok = True)
@@ -341,7 +340,13 @@ def run(command, env={}, shell=False):
341340
pb_lod.append(pbd)
342341
pb_df = pd.DataFrame(pb_lod)
343342
config['subj_id'] = pb_df.subj.unique()[0]
343+
config['task_label'] = task_label
344+
config['num_runs'] = len(pb_df.run.unique())
344345
config['blocks'] = ' '.join(pb_df.block.unique())
346+
config['report_num'] = report_num
347+
report_num += 1
348+
if session_label != '':
349+
config['session_label'] = session_label
345350

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

0 commit comments

Comments
 (0)