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

Commit 0d717db

Browse files
authored
Merge pull request #57 from akeshavan/incorporate_eddy_quad
some more edits to the report
2 parents 20179a9 + 36fc03e commit 0d717db

File tree

4 files changed

+152
-5
lines changed

4 files changed

+152
-5
lines changed

dmriprepViewer/src/components/BrainSprite.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default {
4242
brain: null,
4343
showOrig: true,
4444
done: false,
45+
ready: false,
4546
};
4647
},
4748
methods: {
@@ -64,7 +65,10 @@ export default {
6465
},
6566
mounted() {
6667
this.$nextTick(() => {
67-
setTimeout(() => { this.initBrainSprite(); }, 1);
68+
setTimeout(() => {
69+
this.ready = true;
70+
this.initBrainSprite();
71+
}, 100);
6872
});
6973
},
7074
};

dmriprepViewer/src/components/Bucket.vue

Lines changed: 48 additions & 2 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
*/
@@ -118,10 +148,14 @@ export default {
118148
},
119149
updateReport() {
120150
this.ready = false;
121-
axios.get(`https://s3-us-west-2.amazonaws.com/${this.bucket}/${this.manifestEntries[this.currentReportIdx]}`)
151+
const reportUrl = `https://s3-us-west-2.amazonaws.com/${this.bucket}/${this.manifestEntries[this.currentReportIdx]}`;
152+
return axios.get(reportUrl)
122153
.then((resp) => {
123154
this.currentReport = resp.data;
124155
this.ready = true;
156+
this.$router.replace({ name: 'Bucket',
157+
params: { bucket: this.bucket },
158+
query: { report: reportUrl } });
125159
});
126160
},
127161
},
@@ -139,7 +173,19 @@ export default {
139173
},
140174
},
141175
mounted() {
142-
this.getS3Manifest().then(this.updateReport);
176+
let path = null;
177+
if (this.$route.query) {
178+
if (this.$route.query.report) {
179+
path = this.$route.query.report.split(`https://s3-us-west-2.amazonaws.com/${this.bucket}/`)[1];
180+
}
181+
}
182+
183+
this.getS3Manifest().then(this.updateReport).then(() => {
184+
if (path) {
185+
this.currentReportIdx = this.manifestEntries.indexOf(path);
186+
}
187+
this.getAllReports();
188+
});
143189
},
144190
};
145191
</script>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 = {{numberFormatter(individual_abs_mot_z)}})</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 = {{numberFormatter(individual_abs_mot_z)}}
12+
</b-progress-bar>
13+
</b-progress>
14+
</div>
15+
<div class="mb-3">
16+
<p>Relative Motion (Z = {{numberFormatter(individual_rel_mot_z)}})</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 = {{numberFormatter(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+
numberFormatter(val) {
46+
const formatter = d3.format('.3n');
47+
return formatter(val);
48+
},
49+
getColor(direction, zScore) {
50+
if (direction) {
51+
// positive is good
52+
if (zScore <= -1) {
53+
return 'danger';
54+
} else if (zScore >= 1) {
55+
return 'success';
56+
}
57+
}
58+
if (zScore <= -1) {
59+
return 'success';
60+
} else if (zScore >= 1) {
61+
return 'danger';
62+
}
63+
return 'primary';
64+
},
65+
},
66+
computed: {
67+
mean_group_abs_mot() {
68+
return d3.mean(this.data, d => d.qc_mot_abs);
69+
},
70+
std_group_abs_mot() {
71+
return d3.deviation(this.data, d => d.qc_mot_abs);
72+
},
73+
individual_abs_mot_z() {
74+
if (this.individual) {
75+
return (this.individual.qc_mot_abs - this.mean_group_abs_mot) / this.std_group_abs_mot;
76+
}
77+
return null;
78+
},
79+
mean_group_rel_mot() {
80+
return d3.mean(this.data, d => d.qc_mot_rel);
81+
},
82+
std_group_rel_mot() {
83+
return d3.deviation(this.data, d => d.qc_mot_rel);
84+
},
85+
individual_rel_mot_z() {
86+
if (this.individual) {
87+
return (this.individual.qc_mot_rel - this.mean_group_rel_mot) / this.std_group_rel_mot;
88+
}
89+
return null;
90+
},
91+
},
92+
};
93+
</script>
94+
95+
<style>
96+
</style>

dmriprepViewer/src/components/Report.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
// load the json
108108
if (!this.$route.query.url && this.$route.name === 'Report') {
109109
this.$router.push('/');
110-
} else {
110+
} else if (this.$route.query.url) {
111111
axios.get(this.$route.query.url).then((resp) => {
112112
this.report = resp.data;
113113
});
@@ -141,8 +141,9 @@ export default {
141141
if (this.$route.query) {
142142
// load the json
143143
if (!this.$route.query.url && this.$route.name === 'Report') {
144-
// this.$router.push('/');
144+
this.$router.push('/');
145145
} else {
146+
console.log('getting axios?', this.$route.query.url);
146147
axios.get(this.$route.query.url).then((resp) => {
147148
this.report = resp.data;
148149
});

0 commit comments

Comments
 (0)