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

Commit 847bb66

Browse files
committed
enh: updated the viewer to show all the reports in the bucket
1 parent b8802b6 commit 847bb66

File tree

10 files changed

+194
-17
lines changed

10 files changed

+194
-17
lines changed

dmriprep/run.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,10 @@ def get_dmriprep_pe_workflow():
370370
applytopup = prep.get_node('peb_correction.unwarp')
371371
applytopup.inputs.checksize = True
372372

373-
eddy_quad = pe.Node(fsl.EddyQuad(verbose=True), name="eddy_quad")
374-
get_path = lambda x: x.split('.nii.gz')[0]
373+
eddy.inputs.checksize = True
374+
375+
eddy_quad = pe.Node(fsl.EddyQuad(verbose=True, checksize=True), name="eddy_quad")
376+
get_path = lambda x: x.split('.nii.gz')[0].split('_fix')[0]
375377
wf.connect(prep, ('fsl_eddy.out_corrected', get_path), eddy_quad, "base_name")
376378
wf.connect(inputspec, 'bval_file', eddy_quad, 'bval_file')
377379
wf.connect(prep, 'Rotate_Bvec.out_file', eddy_quad, 'bvec_file')
@@ -439,7 +441,12 @@ def num_outliers(scan, outliers):
439441

440442
if 0 < threshold < 1:
441443
img = nib.load(dwi_file)
442-
threshold *= img.header.get_n_slices()
444+
try:
445+
threshold *= img.header.get_n_slices()
446+
except nib.spatialimages.HeaderDataError:
447+
print('WARNING. We are not sure which dimension has the '
448+
'slices in this image. So we are using the 3rd dim.', img.shape)
449+
threshold *= img.shape[2]
443450

444451
drop_scans = np.array([
445452
s for s in scans
@@ -742,7 +749,7 @@ def binarize_aparc(aparc_aseg):
742749
wf.connect(eddy_quad, 'out_qc_json', datasink, "dmriprep.qc.@eddyquad_json")
743750
wf.connect(eddy_quad, 'out_qc_pdf', datasink, "dmriprep.qc.@eddyquad_pdf")
744751
wf.connect(eddy_quad, 'out_avg_b_png', datasink, "dmriprep.qc.@eddyquad_bpng")
745-
wf.connect(eddy_quad, 'out_avg_b0_png', datasink, "dmriprep.qc.@eddyquad_b0png")
752+
wf.connect(eddy_quad, 'out_avg_b0_pe_png', datasink, "dmriprep.qc.@eddyquad_b0png")
746753
wf.connect(eddy_quad, 'out_cnr_png', datasink, "dmriprep.qc.@eddyquad_cnr")
747754
wf.connect(eddy_quad, 'out_vdm_png', datasink, "dmriprep.qc.@eddyquad_vdm")
748755
wf.connect(eddy_quad, 'out_residuals', datasink, 'dmriprep.qc.@eddyquad_resid')

dmriprepViewer/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dmriprepViewer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"bootstrap-vue": "^2.0.0-rc.11",
1919
"brainsprite.js": "git+https://[email protected]/SIMEXP/brainsprite.js.git",
2020
"d3": "^5.7.0",
21+
"lodash": "^4.17.11",
2122
"vue": "^2.5.2",
2223
"vue-router": "^3.0.1",
2324
"vue-slider-component": "^2.7.7"
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<template>
2+
<div class="bucket">
3+
<div class="row">
4+
<div class="col-md-3">
5+
<div class="container">
6+
<h3>{{bucket}} ({{manifestEntries.length}})</h3>
7+
<b-nav vertical pills class="w-100">
8+
<!-- <b-nav-item active>Active</b-nav-item> -->
9+
<b-nav-item v-for="(subject, index) in manifestEntries"
10+
:key="subject" :active="index === currentReportIdx"
11+
@click="currentReportIdx = index">
12+
{{subject.split('/')[0]}}
13+
</b-nav-item>
14+
</b-nav>
15+
</div>
16+
</div>
17+
<div class="col-md-9">
18+
<h1 v-if="manifestEntries.length">
19+
{{manifestEntries[currentReportIdx].split('/')[0]}}
20+
</h1>
21+
<div v-if="ready">
22+
<report
23+
:reportProp="currentReport"
24+
/>
25+
</div>
26+
<div v-else>
27+
loading...
28+
</div>
29+
</div>
30+
</div>
31+
</div>
32+
</template>
33+
34+
<script>
35+
import axios from 'axios';
36+
import _ from 'lodash';
37+
import Report from './Report';
38+
39+
export default {
40+
name: 'bucket',
41+
data() {
42+
return {
43+
manifestEntries: [],
44+
currentReportIdx: 0,
45+
currentReport: {},
46+
ready: false,
47+
};
48+
},
49+
components: {
50+
Report,
51+
},
52+
methods: {
53+
/**
54+
* XML parser for pubmed query returns.
55+
*/
56+
xmlParser(input) {
57+
const parser = new DOMParser();
58+
const xmlDoc = parser.parseFromString(input, 'text/xml');
59+
return xmlDoc;
60+
},
61+
/**
62+
*
63+
*/
64+
parseS3(data) {
65+
const xml = this.xmlParser(data);
66+
const keys = xml.getElementsByTagName('Key');
67+
const continuation = xml.getElementsByTagName('NextContinuationToken');
68+
const isTruncated = xml.getElementsByTagName('IsTruncated')[0].innerHTML;
69+
if (isTruncated === 'true') {
70+
this.continuation = encodeURIComponent(continuation[0].innerHTML);
71+
} else {
72+
this.continuation = null;
73+
}
74+
const allKeys = _.map(keys, k => k.innerHTML);
75+
const reportsFiltered = _.filter(allKeys, k => k.endsWith('_report.json'));// _.map(allKeys, k => k.split('/')[0]);
76+
const keysFixed = _.uniq(reportsFiltered);
77+
return keysFixed;
78+
},
79+
/**
80+
* if there is a continuation token..
81+
*/
82+
S3Continuation(token) {
83+
let url = `https://s3-us-west-2.amazonaws.com/${this.bucket}/?list-type=2&`;
84+
// url += `prefix=${this.config.manifestS3.prefix}/&max-keys=100000`;
85+
url += '&max-keys=100000';
86+
// url += `&delimiter=${this.config.manifestS3.delimiter}`;
87+
url += `&continuation-token=${token}`;
88+
if (!token) {
89+
return 0;
90+
}
91+
return axios.get(url).then((resp) => {
92+
const keysFixed2 = this.parseS3(resp.data);
93+
this.manifestEntries = _.uniq(this.manifestEntries.concat(keysFixed2));
94+
if (this.continuation) {
95+
this.S3Continuation(this.continuation);
96+
}
97+
});
98+
},
99+
/**
100+
* get a list of files that are in a bucket of an S3
101+
* with a prefix and a delimiter (usually, a .)
102+
* TODO: make the keys firebase safe!!
103+
*/
104+
getS3Manifest() {
105+
let url = `https://s3-us-west-2.amazonaws.com/${this.bucket}/?list-type=2&`;
106+
url += '&max-keys=100000';
107+
// url += `prefix=${this.config.manifestS3.prefix}
108+
// /&max-keys=${this.config.manifestS3.max_keys}`;
109+
// url += `&delimiter=${this.config.manifestS3.delimiter}`;
110+
// console.log(url);
111+
return axios.get(url).then((resp) => {
112+
const keysFixed = this.parseS3(resp.data);
113+
this.manifestEntries = _.uniq(this.manifestEntries.concat(keysFixed));
114+
if (this.continuation) {
115+
this.S3Continuation(this.continuation);
116+
}
117+
});
118+
},
119+
updateReport() {
120+
this.ready = false;
121+
axios.get(`https://s3-us-west-2.amazonaws.com/${this.bucket}/${this.manifestEntries[this.currentReportIdx]}`)
122+
.then((resp) => {
123+
this.currentReport = resp.data;
124+
this.ready = true;
125+
});
126+
},
127+
},
128+
computed: {
129+
bucket() {
130+
return this.$route.params.bucket;
131+
},
132+
},
133+
watch: {
134+
bucket() {
135+
this.getS3Manifest();
136+
},
137+
currentReportIdx() {
138+
this.updateReport();
139+
},
140+
},
141+
mounted() {
142+
this.getS3Manifest().then(this.updateReport);
143+
},
144+
};
145+
</script>
146+
147+
<style>
148+
149+
</style>

dmriprepViewer/src/components/HelloWorld.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
</b-input-group-append>
1818
</b-input-group>
1919

20+
<p class="lead mt-3">OR point to an S3 bucket</p>
21+
<b-input-group size="md" class="mb-3" prepend="Bucket">
22+
<b-form-input v-model="bucket" />
23+
<b-input-group-append>
24+
<b-btn size="md" text="Button"
25+
variant="primary"
26+
@click="s3">Go</b-btn>
27+
</b-input-group-append>
28+
</b-input-group>
29+
2030
<report v-if="report.b0" :reportProp="report"></report>
2131
</b-container>
2232
</template>
@@ -44,16 +54,19 @@ export default {
4454
time: 0,
4555
spriteSlice: 0,
4656
url: null,
57+
bucket: null,
4758
};
4859
},
4960
methods: {
5061
get_mid_slice() {
5162
return Math.floor(this.report.b0.num_slices / 2);
5263
},
5364
navigate() {
54-
console.log(this.url);
5565
this.$router.push({ path: '/report', query: { url: this.url } });
5666
},
67+
s3() {
68+
this.$router.push({ path: `/bucket/${this.bucket}` });
69+
},
5770
},
5871
watch: {
5972
file() {

dmriprepViewer/src/components/Report.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default {
106106
if (this.$route.query) {
107107
// load the json
108108
if (!this.$route.query.url) {
109-
this.$router.push('/');
109+
// this.$router.push('/');
110110
} else {
111111
axios.get(this.$route.query.url).then((resp) => {
112112
this.report = resp.data;
@@ -140,8 +140,9 @@ export default {
140140
$route() {
141141
if (this.$route.query) {
142142
// load the json
143+
console.log(this.$route.name);
143144
if (!this.$route.query.url) {
144-
this.$router.push('/');
145+
// this.$router.push('/');
145146
} else {
146147
axios.get(this.$route.query.url).then((resp) => {
147148
this.report = resp.data;

dmriprepViewer/src/router/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue';
22
import Router from 'vue-router';
33
import HelloWorld from '@/components/HelloWorld';
44
import Report from '@/components/Report';
5+
import Bucket from '@/components/Bucket';
56

67
Vue.use(Router);
78

@@ -17,5 +18,10 @@ export default new Router({
1718
name: 'Report',
1819
component: Report,
1920
},
21+
{
22+
path: '/bucket/:bucket',
23+
name: 'Bucket',
24+
component: Bucket,
25+
},
2026
],
2127
});

docker/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
- pandas
1212
- tqdm
1313
- pip:
14-
- "--editable=git+https://github.com/akeshavan/nipype@a9520619057120478f0fb9d6fa719c2da32ec4e7#egg=nipype"
14+
- "--editable=git+https://github.com/akeshavan/nipype@fcb90bea6ed5f0e47b1d216ba04352b4038ad13d#egg=nipype"
1515
- "--editable=git+https://git.fmrib.ox.ac.uk/matteob/eddy_qc_release@57bb11da6a634c4195593fbc439ba9f8998157b0#egg=eddy_qc"
1616
- bids
1717
- duecredit

kubernetes/docker/build_tag_push.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
2-
docker build -t dmriprep:kube3 -f dockerfile-dmriprep-kube .
3-
docker tag dmriprep:kube3 gcr.io/dmriprep/dmriprep:kube3
4-
docker push gcr.io/dmriprep/dmriprep:kube3
2+
docker build -t dmriprep:kube4 -f dockerfile-dmriprep-kube .
3+
docker tag dmriprep:kube4 gcr.io/dmriprep/dmriprep:kube4
4+
docker push gcr.io/dmriprep/dmriprep:kube4

kubernetes/run_dmriprep.yml.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ spec:
77
spec:
88
containers:
99
- name: dmriprep-subject
10-
image: gcr.io/dmriprep/dmriprep:kube3
10+
image: gcr.io/dmriprep/dmriprep:kube4
1111
command: ["/neurodocker/startup.sh", "./dmriprep_all.sh", "{{subject}}", "{{access_key}}", "{{secret_key}}"]
1212
resources:
1313
requests:
14-
memory: "6G"
15-
cpu: "1"
14+
memory: "12G"
15+
cpu: "2"
1616
restartPolicy: Never
1717
backoffLimit: 1

0 commit comments

Comments
 (0)