Skip to content

Commit

Permalink
[FIX] show excluded sequence errors (if they exist)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Levitas committed Sep 5, 2023
1 parent d12a58d commit 3c0adad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 52 deletions.
51 changes: 9 additions & 42 deletions ui/src/Objects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
<span v-if="o_sub.sub != ''" class="hierarchy">
<i class="el-icon-user-solid" style="margin-right: 2px;"/>
<small>sub-</small><b>{{o_sub.sub}}</b>
<!-- &nbsp;
<el-form-item label="Volume Threshold" prop="Volume Threshold">
<el-input v-model="ezbids.funcBoldVoumeThreshold"
placeholder="Specify a volume threshold for all 4D dataset sequences" size="small"
@change="setVolumeThreshold(ezbids._organized)" style="width: 100%">
</el-input>
<p style="margin-top: 0">
<small>* Recommended/Optional: You can specify a volume threshold where any sequences in this series will be set to "exclude" if they don't reach the threshold. Useful in instances where a sequence needed to be restated. If no threshold is specified, ezBIDS will default to the expected number of volumes collected in a 1-min period.</small>
</p>
</el-form-item> -->
&nbsp;
<el-checkbox :value="o_sub.exclude" @change="excludeSubject(o_sub.sub.toString(), $event)">
<small>Exclude this subject</small>
Expand Down Expand Up @@ -48,7 +38,7 @@
<!--show validation error(s) as "error"-->
<el-badge v-if="o.validationErrors.length > 0" type="danger"
:value="o.validationErrors.length" style="margin-left: 5px;"/>

<!--show validation warning(s) as "warning"-->
<el-badge v-if="o.validationWarnings.length > 0" type="warning"
:value="o.validationWarnings.length" style="margin-left: 5px;"/>
Expand All @@ -57,6 +47,11 @@
<el-badge v-if="o._type != 'exclude' && o.analysisResults && o.analysisResults.errors && o.analysisResults.errors.length > 0" type="warning"
:value="o.analysisResults.errors.length" style="margin-left: 5px"/>
</span>
<span v-if="isExcluded(o)">
<!--show validation error(s) as "error"-->
<el-badge v-if="o.validationErrors.length > 0" type="danger"
:value="o.validationErrors.length" style="margin-left: 5px;"/>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -233,14 +228,15 @@
import { defineComponent } from 'vue'
import datatype from './components/datatype.vue'
import { IObject, Session, OrganizedSession, OrganizedSubject, volumeThresholdNum } from './store'
import { IObject, Session, OrganizedSession, OrganizedSubject } from './store'
import { prettyBytes } from './filters'
import { deepEqual, setRun, setIntendedFor, align_entities, validateEntities, validate_B0FieldIdentifier_B0FieldSource } from './libUnsafe'
// @ts-ignore
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
import { objectToString } from '@vue/shared'
interface Section {
[key: string]: IObject[];
Expand All @@ -256,7 +252,6 @@
return {
so: null as IObject|null, //selected object
sess: null as OrganizedSession|null, //selected session for IntendedFor handling
// volumeThreshold: 0 as volumeThreshold,
}
},
Expand Down Expand Up @@ -306,34 +301,6 @@
this.$emit("mapObjects");
this.validateAll();
},
// setVolumeThreshold(root:OrganizedSubject) {
// /*
// Determine volume threshold for all func/bold acquisitions in dataset and set
// to exclude if the number of volumes does not meet the volume threshold. Threshold
// calculated based on the expected number of volumes collected in a 1-minute time frame,
// with the formula (60-sec / tr), where tr == RepetitionTime
// */
// root.sess.forEach(sessGroup=>{
// sessGroup.objects.forEach(o=>{
// //update analysisResults.warnings in case user went back to Series and adjusted things
// if(["func/bold", "func/cbv", "dwi/dwi"].includes(o._type)) {
// let tr = o.items[0].sidecar.RepetitionTime
// let numVolumes = o.analysisResults.NumVolumes
// let numVolumes1min = Math.floor(60 / tr)
// if(numVolumes <= numVolumes1min) {
// o.exclude = true
// o.analysisResults.warnings = [`This 4D sequence contains ${numVolumes} volumes, which is \
// less than the threshold value of ${numVolumes1min} volumes, calculated by the expected number of \
// volumes in a 1 min time frame. This acquisition will thus be excluded from BIDS conversion unless \
// unexcluded. Please modify if incorrect.`]
// }
// }
// });
// });
// this.$emit("mapObjects");
// this.validateAll();
// },
isExcluded(o: IObject) {
if(o.exclude) return true;
Expand Down Expand Up @@ -443,7 +410,7 @@
o.validationErrors = [];
o.validationWarnings = [];
setRun(this.ezbids)
// setRun(this.ezbids)
setIntendedFor(this.ezbids)
Expand Down
20 changes: 10 additions & 10 deletions ui/src/libUnsafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export function setVolumeThreshold($root) {
*/
$root.objects.forEach(o=>{
//update analysisResults.warnings in case user went back to Series and adjusted things
if(o._type == "func/bold") {
if(o._type === "func/bold") {
let tr = o.items[0].sidecar.RepetitionTime
let numVolumes = o.analysisResults.NumVolumes
let numVolumes1min = Math.floor(60 / tr)
// let numVolumes1min = 5
if(numVolumes <= numVolumes1min) {
o.exclude = true
o._exclude = true
o.analysisResults.warnings = [`This func/bold sequence contains ${numVolumes} volumes, which is \
less than the threshold value of ${numVolumes1min} volumes, calculated by the expected number of \
volumes in a 1 min time frame. This acquisition will thus be excluded from BIDS conversion unless \
Expand Down Expand Up @@ -136,12 +136,12 @@ export function funcQA($root) {
}

// #2
if(o._type === "func/bold" && !o.exclude && (!o._entities.mag || o._entities.mag == "mag")) {
if(o._type === "func/bold" && !o.exclude && (!o._entities.mag || o._entities.mag === "mag")) {
let boldEntities = o._entities
let boldPED = o.items[0].sidecar.PhaseEncodingDirection
let badSBRef = $root.objects.filter(e=>e._type === "func/sbref" && deepEqual(e._entities, boldEntities) &&
e.items[0].sidecar.PhaseEncodingDirection != boldPED).map(e=>e.idx)
badSBRef.forEach(bad=> {
badSBRef.forEach(bad=>{
// $root.objects[bad].exclude = true
$root.objects[bad].analysisResults.warnings = [`Functional sbref has a different PhaseEncodingDirection than its corresponding functional bold (#${o.series_idx}). This is likely a data error, therefore this sbref should be excluded from BIDS conversion.`]
})
Expand Down Expand Up @@ -327,9 +327,7 @@ export function setRun($root) {
// Set run entity label if not already specified at Series level

// Loop through subjects

$root._organized.forEach(subGroup=>{

// Loop through sessions
subGroup.sess.forEach(sesGroup=>{
// Determine series_idx values
Expand All @@ -341,8 +339,10 @@ export function setRun($root) {
let run = 1
if(seriesObjects.length > 1) {
seriesObjects.forEach(obj=>{
obj.entities.run = run.toString()
run++
if (!obj.exclude) {
obj.entities.run = run.toString()
run++
}
});
}
});
Expand Down Expand Up @@ -506,7 +506,7 @@ export function setIntendedFor($root) {
Object.assign(obj, {IntendedFor: []})
let correspindingSeriesIntendedFor = $root.series[obj.series_idx].IntendedFor
correspindingSeriesIntendedFor.forEach(i=>{
let IntendedForIDs = section.filter(o=>o.series_idx === i && o._type != "func/events").map(o=>o.idx)
let IntendedForIDs = section.filter(o=>o.series_idx === i && o._type !== "func/events").map(o=>o.idx)
obj.IntendedFor = obj.IntendedFor.concat(IntendedForIDs)
});
}
Expand Down Expand Up @@ -713,7 +713,7 @@ export function validateEntities(level, info) {
}
} else if (["run", "echo", "flip", "inv", "split", "chunk"].includes(k)) {
if (entities[k] && entities[k] !== "") {
if (isNaN(parseInt(entities[k]))) {
if(!/^[0-9]*$/.test(entities[k])) {
info.validationErrors.push("The "+k+" entity can only contain an integer/numeric value.")
}
}
Expand Down

0 comments on commit 3c0adad

Please sign in to comment.