Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit fa247bc

Browse files
committed
enh: added group statistcs calculations
1 parent 5ac09b8 commit fa247bc

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed

dmriprepViewer/src/components/Bucket.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<div class="col-md-3">
55
<div class="container">
66
<h3>{{bucket}} ({{manifestEntries.length}})</h3>
7+
<div class="mb-3">
8+
<b-button v-if="!statsReady" @click="getAllReports">
9+
Compute Statistics
10+
</b-button>
11+
</div>
712
<b-nav vertical pills class="w-100">
813
<!-- <b-nav-item active>Active</b-nav-item> -->
914
<b-nav-item v-for="(subject, index) in manifestEntries"
@@ -18,6 +23,9 @@
1823
<h1 v-if="manifestEntries.length">
1924
{{manifestEntries[currentReportIdx].split('/')[0]}}
2025
</h1>
26+
<div v-if="statsReady">
27+
<GroupStats :data="allReports" :individual="currentReport.eddy_quad"/>
28+
</div>
2129
<div v-if="ready">
2230
<report
2331
:reportProp="currentReport"
@@ -35,6 +43,7 @@
3543
import axios from 'axios';
3644
import _ from 'lodash';
3745
import Report from './Report';
46+
import GroupStats from './GroupStats';
3847
3948
export default {
4049
name: 'bucket',
@@ -44,12 +53,33 @@ export default {
4453
currentReportIdx: 0,
4554
currentReport: {},
4655
ready: false,
56+
allReports: [],
57+
statsReady: false,
4758
};
4859
},
4960
components: {
5061
Report,
62+
GroupStats,
5163
},
5264
methods: {
65+
getReport(r) {
66+
return axios.get(`https://s3-us-west-2.amazonaws.com/${this.bucket}/${r}`);
67+
},
68+
/**
69+
*
70+
*/
71+
async getAllReports() {
72+
this.statsReady = false;
73+
const reports = await _.map(this.manifestEntries, m => this.getReport(m));
74+
_.map(reports, (r) => {
75+
r.then((resp) => {
76+
if (resp.data.eddy_quad) {
77+
this.allReports.push(resp.data.eddy_quad);
78+
}
79+
});
80+
});
81+
this.statsReady = true;
82+
},
5383
/**
5484
* XML parser for pubmed query returns.
5585
*/
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<template>
2+
<div>
3+
<div class="mb-3">
4+
<p class="lead">
5+
Comparison to Group Eddy_Quad Statistics
6+
</p>
7+
<p>Absolute Motion (z-score)</p>
8+
<b-progress class="w-50 mx-auto">
9+
<b-progress-bar :value="scaleZ(individual_abs_mot_z)"
10+
:variant="getColor(0, individual_abs_mot_z)">
11+
z = {{individual_abs_mot_z}}
12+
</b-progress-bar>
13+
</b-progress>
14+
</div>
15+
<div class="mb-3">
16+
<p>Relative Motion (z-score)</p>
17+
<b-progress class="w-50 mx-auto">
18+
<b-progress-bar :value="scaleZ(individual_rel_mot_z)"
19+
:variant="getColor(0, individual_rel_mot_z)">
20+
z = {{individual_rel_mot_z}}
21+
</b-progress-bar>
22+
</b-progress>
23+
</div>
24+
25+
</div>
26+
</template>
27+
28+
<script>
29+
// import _ from 'lodash';
30+
const d3 = require('d3');
31+
32+
export default {
33+
name: 'GroupStats',
34+
props: ['data', 'individual'],
35+
data() {
36+
return {
37+
38+
};
39+
},
40+
methods: {
41+
scaleZ(val) {
42+
const scaler = d3.scaleLinear().range([0, 100]).domain([-3, 3]);
43+
return scaler(val);
44+
},
45+
getColor(direction, zScore) {
46+
if (direction) {
47+
console.log(zScore);
48+
// positive is good
49+
if (zScore <= -1) {
50+
return 'danger';
51+
} else if (zScore >= 1) {
52+
return 'success';
53+
}
54+
}
55+
console.log('here', zScore);
56+
if (zScore <= -1) {
57+
return 'success';
58+
} else if (zScore >= 1) {
59+
return 'danger';
60+
}
61+
return 'primary';
62+
},
63+
},
64+
computed: {
65+
mean_group_abs_mot() {
66+
return d3.mean(this.data, d => d.qc_mot_abs);
67+
},
68+
std_group_abs_mot() {
69+
return d3.deviation(this.data, d => d.qc_mot_abs);
70+
},
71+
individual_abs_mot_z() {
72+
if (this.individual) {
73+
return (this.individual.qc_mot_abs - this.mean_group_abs_mot) / this.std_group_abs_mot;
74+
}
75+
return null;
76+
},
77+
mean_group_rel_mot() {
78+
return d3.mean(this.data, d => d.qc_mot_rel);
79+
},
80+
std_group_rel_mot() {
81+
return d3.deviation(this.data, d => d.qc_mot_rel);
82+
},
83+
individual_rel_mot_z() {
84+
if (this.individual) {
85+
return (this.individual.qc_mot_rel - this.mean_group_rel_mot) / this.std_group_rel_mot;
86+
}
87+
return null;
88+
},
89+
},
90+
};
91+
</script>
92+
93+
<style>
94+
</style>

0 commit comments

Comments
 (0)