Skip to content

Commit

Permalink
Add B0FieldIdentifier/Source (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Apr 4, 2023
1 parent 28feeee commit 4035500
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 38 deletions.
60 changes: 60 additions & 0 deletions handler/convert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions handler/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ async.forEachOf(info.objects, (o, idx, next_o)=>{
handleItem(item, suffix+".nii.gz", derivatives);
break;
case "json":
//handle B0FieldIdentifier and B0FieldSource if present
if(o.B0FieldIdentifier.length) {
if(o.B0FieldIdentifier.length > 1) {
item.sidecar.B0FieldIdentifier = Object.values(o.B0FieldIdentifier)
}else{
item.sidecar.B0FieldIdentifier = o.B0FieldIdentifier[0]
}
}
if(o.B0FieldSource.length) {
if(o.B0FieldSource.length > 1) {
item.sidecar.B0FieldSource = Object.values(o.B0FieldSource)
}else{
item.sidecar.B0FieldSource = o.B0FieldSource[0]
}
}
handleItem(item, suffix+".json", derivatives);
break;
default:
Expand Down Expand Up @@ -232,6 +247,21 @@ async.forEachOf(info.objects, (o, idx, next_o)=>{
handleItem(item, suffix+".nii.gz");
break;
case "json":
//handle B0FieldIdentifier and B0FieldSource if present
if(o.B0FieldIdentifier.length) {
if(o.B0FieldIdentifier.length > 1) {
item.sidecar.B0FieldIdentifier = Object.values(o.B0FieldIdentifier)
}else{
item.sidecar.B0FieldIdentifier = o.B0FieldIdentifier[0]
}
}
if(o.B0FieldSource.length) {
if(o.B0FieldSource.length > 1) {
item.sidecar.B0FieldSource = Object.values(o.B0FieldSource)
}else{
item.sidecar.B0FieldSource = o.B0FieldSource[0]
}
}
item.sidecar.TaskName = o._entities.task;
handleItem(item, suffix+".json");
break;
Expand Down Expand Up @@ -259,6 +289,22 @@ async.forEachOf(info.objects, (o, idx, next_o)=>{
handleItem(item, suffix+".nii.gz");
break;
case "json":
//handle B0FieldIdentifier and B0FieldSource if present
if(o.B0FieldIdentifier.length) {
if(o.B0FieldIdentifier.length > 1) {
item.sidecar.B0FieldIdentifier = Object.values(o.B0FieldIdentifier)
}else{
item.sidecar.B0FieldIdentifier = o.B0FieldIdentifier[0]
}
console.log(item.sidecar.B0FieldIdentifier)
}
if(o.B0FieldSource.length) {
if(o.B0FieldSource.length > 1) {
item.sidecar.B0FieldSource = Object.values(o.B0FieldSource)
}else{
item.sidecar.B0FieldSource = o.B0FieldSource[0]
}
}
//handle IntendedFor
if(o.IntendedFor) {
item.sidecar.IntendedFor = [];
Expand Down Expand Up @@ -315,6 +361,21 @@ async.forEachOf(info.objects, (o, idx, next_o)=>{
handleItem(item, "dwi.bval");
break;
case "json":
//handle B0FieldIdentifier and B0FieldSource if present
if(o.B0FieldIdentifier.length) {
if(o.B0FieldIdentifier.length > 1) {
item.sidecar.B0FieldIdentifier = Object.values(o.B0FieldIdentifier)
}else{
item.sidecar.B0FieldIdentifier = o.B0FieldIdentifier[0]
}
}
if(o.B0FieldSource.length) {
if(o.B0FieldSource.length > 1) {
item.sidecar.B0FieldSource = Object.values(o.B0FieldSource)
}else{
item.sidecar.B0FieldSource = o.B0FieldSource[0]
}
}
handleItem(item, "dwi.json");
break;
default:
Expand Down
27 changes: 24 additions & 3 deletions ui/src/Objects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,28 @@
</el-select>
</el-form-item>
<p style="margin-left: 200px;">
<small>* IntendedFor information is used to specify which image this fieldmap is intended for. This is important information recommended by BIDS specification.</small>
<small>* IntendedFor information is used to specify which image this fieldmap is intended for. This is recommended information according to the BIDS specification.</small>
</p>
</div>

<div v-if="so._type && !so._type.includes('exclude')" class="border-top">
<br>
<el-form-item label="B0FieldIdentifier">
<el-select v-model="so.B0FieldIdentifier" multiple filterable allow-create default-first-option
placeholder="Enter text string" size="small" style="width: 100%" @change="update(so)">
</el-select>
</el-form-item>
<p style="margin-left: 200px;">
<small>* Optional/Recommended: If this sequence will be used for fieldmap correction, enter a text string of your choice. A good formatting suggestion is the "datatype_suffix[index]" format (e.g., <b>fmap_epi0</b>, <b>fmap_phasediff1</b>, etc). If another sequence will be used with this one for fieldmap correction, use the exact same text string there as well. Leave field blank if unclear.</small>
</p>
<br>
<el-form-item label="B0FieldSource">
<el-select v-model="so.B0FieldSource" multiple filterable allow-create default-first-option
placeholder="Enter text string" size="small" style="width: 100%" @change="update(so)">
</el-select>
</el-form-item>
<p style="margin-left: 200px;">
<small>* Optional/Recommended: If this sequence will be used for fieldmap correction, enter a text string of your choice. A good formatting suggestion is the "datatype_suffix" format (e.g., fmap_epi, fmap_phasediff). If another sequence will be used with this one for fieldmap correction, use the exact same text string there as well. Leave field blank if unclear.</small>
</p>
</div>

Expand Down Expand Up @@ -199,7 +220,7 @@ import datatype from './components/datatype.vue'
import { IObject, Session, OrganizedSession, OrganizedSubject } from './store'
import { prettyBytes } from './filters'
import { deepEqual, validateEntities } from './libUnsafe'
import { deepEqual, validate_Entities_B0FieldIdentifier_B0FieldSource } from './libUnsafe'
// @ts-ignore
import { Splitpanes, Pane } from 'splitpanes'
Expand Down Expand Up @@ -381,7 +402,7 @@ export default defineComponent({
if(this.isExcluded(o)) return;
o.validationErrors = validateEntities(o.entities);
o.validationErrors = validate_Entities_B0FieldIdentifier_B0FieldSource(o.entities, o.B0FieldIdentifier, o.B0FieldSource);
if(o._type.startsWith("func/")) {
const series = this.ezbids.series[o.series_idx];
Expand Down
36 changes: 19 additions & 17 deletions ui/src/SeriesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,31 @@
</el-option>
</el-select>
<p style="margin-top: 0">
<small>* Select Series that this field map should be applied to. This is important information required by BIDS specification.</small>
<small>* Optional/Recommended: select Series that this field map should be applied to. Helpful is planning on using BIDS-apps for processing (e.g., fMRIPrep).</small>
</p>
</el-form-item>
</div>

<div v-if="ss.type && (ss.type.includes('fmap/') || ss.type.includes('func/sbref') || ss.type.includes('dwi/dwi') || ss.type.includes('dwi/sbref') || ss.type.includes('func/bold'))">
<el-form-item label="B0FieldIdentifier">
<el-select v-model="ss.B0FieldIdentifier" required multiple filterable
placeholder="Please select Series" size="small"
<div v-if="ss.type && !ss.type.includes('exclude')">
<el-form-item label="B0FieldIdentifier" prop="B0FieldIdentifier">
<el-select v-model="ss.B0FieldIdentifier" multiple filterable allow-create default-first-option
placeholder="Enter text string" size="small"
@change="validateAll()" style="width: 80%">
<el-option v-for="(series, idx) in ezbids.series/*.filter(s=>s.type != 'exclude')*/" :key="idx"
:label="'(#'+idx.toString()+') '+series.type" :value="idx">
(#{{idx.toString()}}) {{series.type}}
</el-option>
</el-select>
<p style="margin-top: 0">
<small>Optional: select Series that this field map should be applied to.</small>
<small>* Optional/Recommended: If this sequence will be used for fieldmap/distortion correction, enter a text string of your choice. A good formatting suggestion is the "datatype_suffix[index]" format (e.g., <b>fmap_epi0</b>, <b>fmap_phasediff1</b>, etc). If another sequence will be used with this one for fieldmap/distortion correction, use the exact same text string there as well. Leave field blank if unclear.</small>
</p>
</el-form-item>
</div>


<el-form-item label="B0FieldSource" prop="B0FieldSource">
<el-select v-model="ss.B0FieldSource" multiple filterable allow-create default-first-option
placeholder="Enter text string" size="small"
@change="validateAll()" style="width: 80%">
</el-select>
<p style="margin-top: 0">
<small>* Optional/Recommended: If fieldmap/distortion correction will be applied to this image, enter the identical text string from the B0FieldIdentifier field of the sequence(s) used to create the fieldmap/distortion estimation. Leave field blank if unclear.</small>
</p>
</el-form-item>
</div>

<div v-if="ss.type">
<el-form-item v-for="(v, entity) in getSomeEntities(ss.type)" :key="entity"
Expand Down Expand Up @@ -170,7 +173,7 @@ import { prettyBytes } from './filters'
import { Series, IObject } from './store'
import { validateEntities } from './libUnsafe'
import { validate_Entities_B0FieldIdentifier_B0FieldSource } from './libUnsafe'
// @ts-ignore
import { Splitpanes, Pane } from 'splitpanes'
Expand Down Expand Up @@ -228,9 +231,8 @@ export default defineComponent({
s.validationErrors = [];
s.validationWarnings = [];
if(s.type != "exclude") {
s.validationErrors = validateEntities(s.entities);
s.validationErrors = validate_Entities_B0FieldIdentifier_B0FieldSource(s.entities, s.B0FieldIdentifier, s.B0FieldSource);
}
//let user know if multiple series have same datatype and entity labels
Expand Down
Loading

0 comments on commit 4035500

Please sign in to comment.