-
Notifications
You must be signed in to change notification settings - Fork 0
/
QC_Reporter.py
2248 lines (1886 loc) · 64 KB
/
QC_Reporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# coding: utf-8
# In[11]:
#import pandas for dataframes, import seaborn for graphs, import csv, import os for file handling
import matplotlib
matplotlib.use('PDF')
import matplotlib.pyplot as plt
import pandas as pd
import os
import webbrowser
import math
import seaborn as sns
global df
csv_name = '/datain/pipeline_outputs_SUB_02-04-2022.csv' #INPUT csv name here
df = pd.read_csv(csv_name) #import csv
list_outliers = {} #global list of outliers for later use
study_name = csv_name.split("_")[2]
tmp = csv_name.split(".")[0]
date_dash = tmp.split("_")[3]
date = date_dash.replace("-", "/") #INPUT date updated (mm/dd/yyyy)
#drop unneeded columns ---> FOR USE WITH PAUL'S OUTPUTS ONLY, COMMENT OUT FOR OTHER STUDIES
for col in df.columns:
if (('MaximizedModularity' in col)
or ('MeanTotalStrength'in col)
or ('NetworkCharacteristic' in col) or ('TotalStrength' in col)
or ('dummyrest' in col) or ('session_id' in col)
or ('dummy_rest' in col) or ('file_name' in col) or ('1back' in col)
or ('acq_id' in col)):
del df[col]
#filter id columns to include only integers
for id in df['subject_id'].dropna():
if(len(id)>4):
idnum=id[-4:]
df['subject_id']=df['subject_id'].replace(id,idnum)
# In[3]:
#create graphs
plt.switch_backend('Agg')
for i,col in enumerate(df.columns):
try:
plt.figure(i) #blank plot, to load graphs
plt.ion()
ax = sns.scatterplot(x='subject_id',y=col, data=df)
std_line = df[col].std()
ax = sns.lineplot(x='subject_id',y=std_line+df[col].mean(), data=df)
ax = sns.lineplot(x='subject_id',y=-1*std_line+df[col].mean(), data=df)
ax = sns.lineplot(x='subject_id',y=2*std_line+df[col].mean(), data=df)
ax = sns.lineplot(x='subject_id',y=-2*std_line+df[col].mean(), data=df)
ax.set_xticklabels(df['subject_id'],rotation=270)
fig = ax.get_figure()
plt.ioff()
fig.savefig(col+'.png',backend='Agg') #save each plot in local folder
except TypeError:
print('Graph not generated for: '+col)
# In[4]:
#create descriptions for different variables using keywords, return corresponding string
def desc(name):
if('snrd' in name):
return 'Dietrich’s SNR using air background as reference:<span style="color: green"> ↑</span>'
elif('snr' in name or 'tsnr' in name):
return 'Signal-to-Noise ratio:<span style="color: green"> ↑</span>'
elif('cnr' in name):
return 'Contrast-to-noise ratio:<span style="color: green"> ↑</span>'
elif('fwhm' in name):
return 'Full-width half maximum estimations:<span style="color: green"> ↓</span>'
elif('qi2' in name):
return 'Goodness of fit of a noise model into the background noise: <span style="color: green">↓</span>'
elif('cjv' in name):
return 'Coefficient of joint variation:<span style="color: green"> ↓</span>'
elif(name.startswith('efc')):
return """Entropy focus criterion:
<span style="color: green"> ↓ more uniform distribution, less noisy</span>"""
elif('fber' in name):
return 'Foreground-background energy ratio:<span style="color: green"> ↑</span>'
elif('qi1' in name):
return 'Segmentation using mathematical morphology:<span style="color: green"> ↓</span>'
elif('inu' in name):
return 'Intensity non-uniformity estimate measurements:<span style="color: green"> ~1</span>'
elif('pve' in name):
return 'Partial volume errors:<span style="color: green"> ↓</span>'
elif('wm2max' in name):
return 'White-matter to maximum intensity ratio:<span style="color: green"> [0.6, 0.8]</span>'
elif('icv' in name):
return 'Intracranial volume fractions: <span style="color: green"> “should move within a normative range”</span>'
elif('rpve' in name):
return 'Residual partial volume errors:<span style="color: green"> ↓</span>'
elif('fd' in name):
return 'Framewise displacement:<span style="color: green"> ↓</span>'
elif('dvars' in name):
return 'Temporal derivative of timecourses RMS variance over voxels:<span style="color: green"> ↓</span>'
elif('gsr' in name):
return 'Ghost-to-signal Ratio:<span style="color: green"> ↓</span>'
elif('gcor' in name):
return 'Global correlation :<span style="color: green"> ↓</span>'
elif('spikes' in name):
return 'High frequency and global intensity :<span style="color: green"> ↓ (lessvolumes to remove if filtering)</span>'
elif('aor' in name):
return 'AFNI’s outlier ratio: mean fraction of outliers per fMRI volume'
elif('aqi' in name):
return 'AFNI’s quality index: mean quality index'
elif('coregCrossCorr' in name):
return 'Cross correlation:<span style="color: green"> ↑</span>'
elif('CoregJaccard' in name):
return 'Jaccard index:<span style="color: green"> ↑</span>'
elif('CoregDice' in name):
return 'Dice index:<span style="color: green"> ↑</span>'
elif('CoregCoverage' in name):
return 'Coverage index:<span style="color: green"> ↑</span>'
elif('regCrossCorr' in name):
return 'Cross correlation:<span style="color: green"> ↑</span>'
elif('regJaccard' in name):
return 'Jaccard index:<span style="color: green"> ↑</span>'
elif('regDice' in name):
return 'Dice index:<span style="color: green"> ↑</span>'
elif('regCoverage' in name):
return 'Coverage index:<span style="color: green"> ↑</span>'
elif('normCrossCorr' in name):
return 'Cross correlation:<span style="color: green"> ↑</span>'
elif('normJaccard' in name):
return 'Jaccard index:<span style="color: green"> ↑</span>'
elif('normDice' in name):
return 'Dice index:<span style="color: green"> ↑</span>'
elif('normCoverage' in name):
return 'Coverage index:<span style="color: green"> ↑</span>'
elif('relMeanRMSMotion' in name):
return 'Mean value of RMS motion:<span style="color: green"> ↓</span>'
elif('relMaxRMSMotion' in name):
return 'Maximum value of RMS motion:<span style="color: green"> ↓</span>'
elif('nSpikesFD' in name):
return 'Number of spikes per FD:<span style="color: green"> ↓</span>'
elif('nspikesDV' in name):
return 'Number of spikes per DV:<span style="color: green"> ↓</span>'
elif('pctSpikesDV' in name):
return 'Percentage of spikes per DV:<span style="color: green"> ↓</span>'
elif('pctSpikesFD' in name):
return 'Percentage of spikes per DV:<span style="color: green"> ↓/span>'
elif('meanDV' in name):
return 'Mean DVARS:<span style="color: green"> ↓</span>'
elif('motionDVCorrInit' in name):
return 'Correlation of RMS and DVARS before regression:<span style="color: green"> ↓</span>'
elif('motionDVCorrFinal' in name):
return 'Correlation of RMS and DVARS after regression :<span style="color: green"> ↓ lower than init</span>'
elif('nNuisanceParameters' in name):
return 'Total number of nuisance Parameters in addition to custom regressors:<span style="color: green"> ↓</span> (confound regression model-dependent)'
elif('nVolCensored' in name):
return 'Total number of volume(s) censored:<span style="color: green"> ↓</span>'
elif('estimatedLostTemporalDOF' in name):
return 'Total degree of freedom lost:<span style="color: green"> ↓</span>'
elif('mean_fd' in name):
return 'Mean framewise displacement:<span style="color: green"> ↓</span>'
elif('max_fd' in name):
return 'Maximum framewise displacement:<span style="color: green"> ↓</span>'
elif('max_translation' in name):
return '<span style="color: green"> ↓</span>'
elif('max_rotation' in name):
return '<span style="color: green"> ↓</span>'
elif('max_rel_translation' in name):
return 'Maxima of derivative of max_translation:<span style="color: green"> ↓</span>'
elif('max_rel_rotation' in name):
return 'Maxima of derivative of max_rotation:<span style="color: green"> ↓</span>'
elif('t1_dice_distance' in name):
return '<span style="color: green"> ↑</span>'
elif('mni_dice_distance' in name):
return '<span style="color: green"> ↑</span>'
elif('raw_incoherence_index ' in name):
return '<span style="color: green"> ↓</span>'
elif('raw_coherence_index ' in name):
return '<span style="color: green"> ↑</span>'
elif('t1_incoherence_index ' in name):
return '<span style="color: green"> ↓</span>'
elif('t1_coherence_index ' in name):
return '<span style="color: green"> ↑</span>'
elif('num_bad_slices' in name):
return '<span style="color: green"> ↓</span>'
elif('raw_dimension' in name):
return 'Should match protocol field of view'
elif('raw_voxel_size' in name):
return 'Should match protocol resolution'
elif('raw_max_b' in name):
return 'Should match protocol maximum b'
elif('raw_neighbor_corr' in name):
return 'Neighboring DWI Correlation (NDC)'
elif('raw_num_directions' in name):
return 'Should match protocol number of directions for dwi scan'
elif('t1_dimension' in name):
return 'Preprocessed space field of view'
elif('t1_voxel_size' in name):
return 'Preprocessed space resolution controlled by --output_resolution value'
if('t1_max_b' in name):
return 'Equal to raw_max_b'
elif('t1_neighbor_corr' in name):
return 'Equal to raw_neighbor_corr'
elif('t1_num_directions' in name):
return 'Equal to raw_num_directions'
else:
return ""
# In[5]:
def mean(name):
return str(df[name].mean())
# In[6]:
def median(name):
return str(df[name].median())
# In[7]:
def std(name):
return str(df[name].std())
# In[8]:
def rnge(name):
return str(df[name].max() - df[name].min())
# In[9]:
def outliers(name):
flag = False
outs = ""
mean_ = float(mean(name))
std_ = float(std(name))
for i in df.index:
if((mean_-2*std_)>df[name][i] or df[name][i]>(mean_+2*std_)):
if(flag):
outs += ", "+ str(df['subject_id'][i])
if df['subject_id'][i] in list_outliers:
list_outliers[df['subject_id'][i]].append(name)
else:
list_outliers[df['subject_id'][i]] = [name]
else:
outs += str(df['subject_id'][i])
flag = True
if df['subject_id'][i] in list_outliers:
list_outliers[df['subject_id'][i]].append(name)
else:
list_outliers[df['subject_id'][i]] = [name]
return outs
# In[17]:
main_name = study_name+"QCGraphs.html"
list_outliers.clear()
f = open(main_name,'w') #create QCGraphs in local folder
grphs = ""
counter = 0
for filename in os.listdir(os.getcwd()):
if filename.endswith(".png") and filename != "Illini_icon.png":
#descriptive stats
name = filename[:len(filename) - 4]
stats = """<table style="width:50% ">
<tr>
<th colspan="2">"""+name+"""</th>
</tr>
<tr>
<td>Mean</td>
<td>"""+mean(name)+"""</td>
</tr>
<tr>
<td>Median</td>
<td>"""+median(name)+"""</td>
</tr>
<tr>
<td>Std.</td>
<td>"""+std(name)+"""</td>
</tr>
<tr>
<td>Range</td>
<td>"""+rnge(name)+"""</td>
</tr>
</table>"""
#create div to align graphs
if counter%3==0:
grphs += "<div class=row>"
grphs+= ("<div class=column><h2 style='text-align:center'>"+name+"</h2><div class='image1'><img src="+ filename+
" >\n</div><br><p font-style=italic align=center><i>"+stats+
"<br><font size='+2'>" +str(desc(name))+
"</font><br>Outliers: "+outliers(name)+"</i></p></div>")
if counter % 3==2:
grphs += "</div>"
counter+=1
else:
continue
code = """<html>
<style>
body{
margin:0;
}
.row {
display: flex;
}
.column {
flex: 50%;
padding: 5px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #13294b;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.active {
background-color: #E84A27;
color: white;
}
li a:hover {
background-color: #E8E9EA;
}
.image1 {
display: flex;
justify-content: center;
}
#searchbar{
padding:13px;
border-radius: 10px;
}
input[type=text] {
width: 7%;
-webkit-transition: width 0.15s ease-in-out;
transition: width 0.15s ease-in-out;
}
input[type=text]:focus {
width: 15%;
}
</style>
<head>
<meta name="robots" content="noindex">
<ul>
<li><a class="active" href="""+study_name+"""QCGraphs.html>QCGraphs</a></li>
<li><a href="""+study_name+"""outliers.html>Outliers</a></li>
<li><a href="""+study_name+"""Anatomical.html>Anatomical</a></li>
<li><a href="""+study_name+"""ASHS.html>ASHS</a></li>
<li><a href="""+study_name+"""QSM.html>QSM</a></li>
<li><a href="""+study_name+"""Diffusion.html>Diffusion</a></li>
<li><a href="""+study_name+"""GQI.html>GQI</a></li>
<li><a href="""+study_name+"""CSD.html>CSD</a></li>
<li><a href="""+study_name+"""NODDI.html>NODDI</a></li>
<li><a href="""+study_name+"""Functional.html>Functional</a></li>
<li><a href="""+study_name+"""RSFC.html>RestingState</a></li>
<li><a href="""+study_name+"""about.html>About</a></li>
<li style="float:right; padding: 5px;"><img src="Illini_icon.png" width = 3.5% style="float:right"></li>
<input id="searchbar" onkeyup="Search_var()" type="text" name="search" placeholder="Search...">
</ul>
</head>
"""
f.write(code)
#insert graphs
code2 = """
<body style="background-color:#f0f0f0">
<div style = "text-align: center; vertical-align: middle;">
<h1>Last Updated: """+date+"""</h1>
</div>
"""+grphs+"""</body>
<script>
function Search_var() {
let input = document.getElementById('searchbar').value
input=input.toLowerCase();
let x = document.getElementsByClassName('column');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display="none";
}
else {
x[i].style.display="";
}
}
}
</script>
</html>"""
f.write(code2)
f.close()
#open html file
QCfile = 'file:///'+os.getcwd()+'/' + main_name
webbrowser.open_new_tab(QCfile)
# In[13]:
def get_outliers():
output = ""
for key in list_outliers:
output += "<div class = outliers><br><h2>"+str(key) + "</h2><h3> (" +str(len(list_outliers.get(key)))+" occurences):</h3><br>"
flag = False
for item in list_outliers.get(key):
if flag:
output += ", "+ str(item)
else:
output += str(item)
flag = True
output += "</div>"
return output
# In[14]:
outliers_name = study_name+"outliers.html"
f2 = open(outliers_name,'w') #create outliers in local folder
code = """<html>
<style>
body{
margin:0;
}
.row {
display: flex;
}
.column {
flex: 50%;
padding: 5px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #13294b;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.active {
background-color: #E84A27;
color: white;
}
li a:hover {
background-color: #E8E9EA;
}
.image1 {
display: flex;
justify-content: center;
}
#searchbar{
padding:13px;
border-radius: 10px;
}
input[type=text] {
width: 7%;
-webkit-transition: width 0.15s ease-in-out;
transition: width 0.15s ease-in-out;
}
input[type=text]:focus {
width: 15%;
}
h2{display:inline;}
h3{display:inline;}
</style>
<head>
<meta name="robots" content="noindex">
<ul>
<li><a class="active" href="""+study_name+"""QCGraphs.html>QCGraphs</a></li>
<li><a href="""+study_name+"""outliers.html>Outliers</a></li>
<li><a href="""+study_name+"""Anatomical.html>Anatomical</a></li>
<li><a href="""+study_name+"""ASHS.html>ASHS</a></li>
<li><a href="""+study_name+"""QSM.html>QSM</a></li>
<li><a href="""+study_name+"""Diffusion.html>Diffusion</a></li>
<li><a href="""+study_name+"""GQI.html>GQI</a></li>
<li><a href="""+study_name+"""CSD.html>CSD</a></li>
<li><a href="""+study_name+"""NODDI.html>NODDI</a></li>
<li><a href="""+study_name+"""Functional.html>Functional</a></li>
<li><a href="""+study_name+"""RSFC.html>RestingState</a></li>
<li><a href="""+study_name+"""about.html>About</a></li>
<li style="float:right; padding: 5px;"><img src="Illini_icon.png" width = 3.5% style="float:right"></li>
<input id="searchbar" onkeyup="Search_var()" type="text" name="search" placeholder="Search...">
</ul>
</head>
"""
f2.write(code)
#insert outliers
code2 = """
<body style="background-color:#f0f0f0">
<div style = "text-align: center; vertical-align: middle;">
<h1>Last Updated: """+date+"""</h1>
</div>
<div style = "padding:10px">
"""+get_outliers()+"""</div></body>
<script>
function Search_var() {
let input = document.getElementById('searchbar').value
input=input.toLowerCase();
let x = document.getElementsByClassName('outliers');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display="none";
}
else {
x[i].style.display="";
}
}
}
</script>
</html>"""
f2.write(code2)
f2.close()
about_name = study_name+"about.html"
f3 = open(about_name, 'w')
code = """<html>
<style>
body{
margin:0;
}
.column {
flex: 50%;
padding: 5px;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #13294b;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.active {
background-color: #E84A27;
color: white;
}
li a:hover {
background-color: #E8E9EA;
}
.image1 {
display: flex;
justify-content: center;
}
.about {
padding: 40px;
text-align: center;
background-color: #474e5d;
color: white;
}
</style>
<head>
<meta name="robots" content="noindex">
<ul>
<li><a class="active" href="""+study_name+"""QCGraphs.html>QCGraphs</a></li>
<li><a href="""+study_name+"""outliers.html>Outliers</a></li>
<li><a href="""+study_name+"""Anatomical.html>Anatomical</a></li>
<li><a href="""+study_name+"""ASHS.html>ASHS</a></li>
<li><a href="""+study_name+"""QSM.html>QSM</a></li>
<li><a href="""+study_name+"""Diffusion.html>Diffusion</a></li>
<li><a href="""+study_name+"""GQI.html>GQI</a></li>
<li><a href="""+study_name+"""CSD.html>CSD</a></li>
<li><a href="""+study_name+"""NODDI.html>NODDI</a></li>
<li><a href="""+study_name+"""Functional.html>Functional</a></li>
<li><a href="""+study_name+"""RSFC.html>RestingState</a></li>
<li><a href="""+study_name+"""about.html>About</a></li>
<li style="float:right; padding: 5px;"><img src="Illini_icon.png" width = 3.5% style="float:right"></li>
<input id="searchbar" onkeyup="Search_var()" type="text" name="search" placeholder="Search...">
</ul>
</head>
<body style="background-color:#f0f0f0">
<div class="about">
<h1>Quality Control Graphs</h1>
<p>Dr. Brad Sutton</p>
<p>Paul Camacho</p>
<p>Nishant Bhamidipati</p>
</div>
<div style='text-align:center'>
<h3>The Quality Control Metrics Graphs provide visual representations of data from the BIC Pipeline. </h3>
<h3>The subject ID's are listed on the x-axis, while the metric is on the y-axis. Descriptive statistics are included beneath each graph.</h3>
</div>
</body>
</html>"""
f3.write(code)
f3.close()
modality = "GQI"
page_name = study_name+modality+".html"
fGQI = open(page_name,'w')
grphs = ""
counter = 0
for filename in os.listdir(os.getcwd()):
if filename.endswith(".png") and (filename != "Illini_icon.png") and (("gfa" in filename) or ("ncount" in filename) or ("count_end" in filename) or ("count_pass" in filename)):
#descriptive stats
name = filename[:len(filename) - 4]
stats = """<table style="width:50% ">
<tr>
<th colspan="2">"""+name+"""</th>
</tr>
<tr>
<td>Mean</td>
<td>"""+mean(name)+"""</td>
</tr>
<tr>
<td>Median</td>
<td>"""+median(name)+"""</td>
</tr>
<tr>
<td>Std.</td>
<td>"""+std(name)+"""</td>
</tr>
<tr>
<td>Range</td>
<td>"""+rnge(name)+"""</td>
</tr>
</table>"""
#create div to align graphs
if counter%3==0:
grphs += "<div class=row>"
grphs+= ("<div class=column><h2 style='text-align:center'>"+name+"</h2><div class='image1'><img src="+ filename+
" >\n</div><br><p font-style=italic align=center><i>"+stats+
"<br><font size='+2'>" +str(desc(name))+
"</font><br>Outliers: "+outliers(name)+"</i></p></div>")
if counter % 3==2:
grphs += "</div>"
counter+=1
else:
continue
code = """<html>
<style>
body{
margin:0;
}
.row {
display: flex;
}
.column {
flex: 50%;
padding: 5px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #13294b;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.active {
background-color: #E84A27;
color: white;
}
li a:hover {
background-color: #E8E9EA;
}
.image1 {
display: flex;
justify-content: center;
}
#searchbar{
padding:13px;
border-radius: 10px;
}
input[type=text] {
width: 7%;
-webkit-transition: width 0.15s ease-in-out;
transition: width 0.15s ease-in-out;
}
input[type=text]:focus {
width: 15%;
}
</style>
<head>
<meta name="robots" content="noindex">
<ul>
<li><a class="active" href="""+study_name+"""QCGraphs.html>QCGraphs</a></li>
<li><a href="""+study_name+"""outliers.html>Outliers</a></li>
<li><a href="""+study_name+"""Anatomical.html>Anatomical</a></li>
<li><a href="""+study_name+"""ASHS.html>ASHS</a></li>
<li><a href="""+study_name+"""QSM.html>QSM</a></li>
<li><a href="""+study_name+"""Diffusion.html>Diffusion</a></li>
<li><a href="""+study_name+"""GQI.html>GQI</a></li>
<li><a href="""+study_name+"""CSD.html>CSD</a></li>
<li><a href="""+study_name+"""NODDI.html>NODDI</a></li>
<li><a href="""+study_name+"""Functional.html>Functional</a></li>
<li><a href="""+study_name+"""RSFC.html>RestingState</a></li>
<li><a href="""+study_name+"""about.html>About</a></li>
<li style="float:right; padding: 5px;"><img src="Illini_icon.png" width = 3.5% style="float:right"></li>
<input id="searchbar" onkeyup="Search_var()" type="text" name="search" placeholder="Search...">
</ul>
</head>
"""
fGQI.write(code)
#insert graphs
codeGQI = """
<body style="background-color:#f0f0f0">
<div style = "text-align: center; vertical-align: middle;">
<h1>Last Updated: """+date+"""</h1>
</div>
"""+grphs+"""</body>
<script>
function Search_var() {
let input = document.getElementById('searchbar').value
input=input.toLowerCase();
let x = document.getElementsByClassName('column');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display="none";
}
else {
x[i].style.display="";
}
}
}
</script>
</html>"""
fGQI.write(codeGQI)
fGQI.close()
modality = "CSD"
page_name = study_name+modality+".html"
fCSD = open(page_name,'w')
grphs = ""
counter = 0
for filename in os.listdir(os.getcwd()):
if filename.endswith(".png") and filename != "Illini_icon.png" and ("SC" in filename):
#descriptive stats
name = filename[:len(filename) - 4]
stats = """<table style="width:50% ">
<tr>
<th colspan="2">"""+name+"""</th>
</tr>
<tr>
<td>Mean</td>
<td>"""+mean(name)+"""</td>
</tr>
<tr>
<td>Median</td>
<td>"""+median(name)+"""</td>
</tr>
<tr>
<td>Std.</td>
<td>"""+std(name)+"""</td>
</tr>
<tr>
<td>Range</td>
<td>"""+rnge(name)+"""</td>
</tr>
</table>"""
#create div to align graphs
if counter%3==0:
grphs += "<div class=row>"
grphs+= ("<div class=column><h2 style='text-align:center'>"+name+"</h2><div class='image1'><img src="+ filename+
" >\n</div><br><p font-style=italic align=center><i>"+stats+
"<br><font size='+2'>" +str(desc(name))+
"</font><br>Outliers: "+outliers(name)+"</i></p></div>")
if counter % 3==2:
grphs += "</div>"
counter+=1
else:
continue
code = """<html>
<style>
body{
margin:0;
}
.row {
display: flex;
}
.column {
flex: 50%;
padding: 5px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #13294b;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.active {
background-color: #E84A27;
color: white;
}
li a:hover {
background-color: #E8E9EA;
}
.image1 {
display: flex;
justify-content: center;
}
#searchbar{
padding:13px;
border-radius: 10px;
}
input[type=text] {
width: 7%;
-webkit-transition: width 0.15s ease-in-out;
transition: width 0.15s ease-in-out;
}
input[type=text]:focus {
width: 15%;
}
</style>
<head>
<meta name="robots" content="noindex">
<ul>
<li><a class="active" href="""+study_name+"""QCGraphs.html>QCGraphs</a></li>
<li><a href="""+study_name+"""outliers.html>Outliers</a></li>
<li><a href="""+study_name+"""Anatomical.html>Anatomical</a></li>
<li><a href="""+study_name+"""ASHS.html>ASHS</a></li>
<li><a href="""+study_name+"""QSM.html>QSM</a></li>
<li><a href="""+study_name+"""Diffusion.html>Diffusion</a></li>
<li><a href="""+study_name+"""GQI.html>GQI</a></li>
<li><a href="""+study_name+"""CSD.html>CSD</a></li>
<li><a href="""+study_name+"""NODDI.html>NODDI</a></li>
<li><a href="""+study_name+"""Functional.html>Functional</a></li>
<li><a href="""+study_name+"""RSFC.html>RestingState</a></li>
<li><a href="""+study_name+"""about.html>About</a></li>
<li style="float:right; padding: 5px;"><img src="Illini_icon.png" width = 3.5% style="float:right"></li>
<input id="searchbar" onkeyup="Search_var()" type="text" name="search" placeholder="Search...">
</ul>