Skip to content

Commit

Permalink
Merge pull request #124 from brainlife/enh/fmap_metadata
Browse files Browse the repository at this point in the history
[ENH] Begin addressing missing fmap info
  • Loading branch information
dlevitas authored Jun 4, 2024
2 parents 788521f + e320c32 commit 7d7b0d2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions ui/src/libUnsafe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,44 @@ export function fmapQA($root: IEzbids) {
//case #4: Multiple phase encoding direction ("pepolar")
let fmapPepolar = section.filter((o) => o._type === 'fmap/epi');

fmapPepolar.forEach((fmap) => {
let sidecar = JSON.parse(fmap.items[0].sidecar_json);
if (!sidecar.hasOwnProperty('PhaseEncodingDirection')) {
let axis = '';
if (sidecar.hasOwnProperty('PhaseEncodingAxis')) {
axis = sidecar.PhaseEncodingAxis;
}

let orientation = fmap.analysisResults.orientation;
if (orientation !== undefined) {
let direction = fmap._entities.direction;

let idx = 1; // Can we assume A-P phase encoding plane? Seems like the most common.
if (axis === 'i') {
idx = 0;
} else if (axis === 'j') {
idx = 1;
} else if (axis === 'k') {
idx = 2;
}

let letter = orientation[idx];

let ped = '';
if (letter === direction[0]) {
ped = axis + '-';
} else {
ped = axis;
}

if (ped !== '') {
sidecar['PhaseEncodingDirection'] = ped;
fmap.items[0].sidecar_json = JSON.stringify(sidecar, null, 2);
}
}
}
});

/*
In addition to the fmap cases listed above, other field maps exist.
For list of these [quantitative MRI] field maps, see
Expand Down Expand Up @@ -913,6 +951,12 @@ export function validateEntities(level: string, info: any) {
`ezBIDS detects that the direction should be ${info.PED}, not ${entities[k]}. Please verify before continuing`
);
}

if (!['LR', 'RL', 'AP', 'PA', 'IS', 'SI'].includes(entities[k].toUpperCase())) {
info.validationErrors.push(
`The direction entity you have specified in not allowed. Must be one of the following: LR, RL, AP, PA, IS, or SI.`
);
}
}
} else if (k === 'part') {
// Only mag, phase, real, or imag allowed
Expand Down

0 comments on commit 7d7b0d2

Please sign in to comment.