Skip to content

Commit 359245e

Browse files
author
Teal Hobson-Lowther
committed
_magnitude1.nii[.gz] and _magnitude2.nii[.gz] should have exactly 3 dimensions
1 parent a848c7b commit 359245e

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

tests/headerField.spec.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ const assert = require('assert')
22
const headerFields = require('../validators/headerFields')
33

44
describe('headerFields', () => {
5-
it('should throw an error if _magnitude1 or _magnitude2 files have too many dimensions.', () => {
6-
// each of these headers has one too many dimensions on the 'dim' field.
7-
// the first entry is the total count, and the following three entries are spatial.
5+
it('should throw an error if _magnitude1 or _magnitude2 files do not have exactly dimensions.', () => {
86
const headers = [
7+
// each of these headers has one too many dimensions on the 'dim' field.
98
[
109
{
1110
name: 'sub-01_magnitude1.nii',
@@ -28,10 +27,37 @@ describe('headerFields', () => {
2827
xyzt_units: [5, 1, 1, 1, 1],
2928
},
3029
],
30+
// each of these headers has one too few dimensions on the 'dim' field.
31+
[
32+
{
33+
name: 'sub-02_magnitude1.nii',
34+
relativePath: 'sub-02_magnitude1.nii',
35+
},
36+
{
37+
dim: [3, 1, 1],
38+
pixdim: [4, 1, 1, 1],
39+
xyzt_units: [4, 1, 1, 1],
40+
},
41+
],
42+
[
43+
{
44+
name: 'sub-02_magnitude2.nii',
45+
relativePath: 'sub-02_magnitude2.nii',
46+
},
47+
{
48+
dim: [3, 1, 1],
49+
pixdim: [4, 1, 1, 1],
50+
xyzt_units: [4, 1, 1, 1],
51+
},
52+
],
3153
]
3254
const issues = headerFields(headers)
3355
assert(
34-
issues.length == 2 && issues[0].code == '94' && issues[1].code == '94',
56+
issues.length == 4 &&
57+
issues[0].code == '94' &&
58+
issues[1].code == '94' &&
59+
issues[2].code == '94' &&
60+
issues[3].code == '94',
3561
)
3662
})
3763

@@ -54,7 +80,7 @@ describe('headerFields', () => {
5480
relativePath: 'sub-01_magnitude2.nii',
5581
},
5682
{
57-
dim: [3, 1, 1],
83+
dim: [4, 1, 1, 1],
5884
pixdim: [4, 1, 1, 1],
5985
xyzt_units: [4, 1, 1, 1],
6086
},

utils/issues/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,6 @@ module.exports = {
513513
key: 'MAGNITUDE_FILE_WITH_TOO_MANY_DIMENSIONS',
514514
severity: 'error',
515515
reason:
516-
'_magnitude1.nii[.gz] and _magnitude2.nii[.gz] files must not have more than three dimensions. ',
516+
'_magnitude1.nii[.gz] and _magnitude2.nii[.gz] files must have exactly three dimensions. ',
517517
},
518518
}

validators/headerFields.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ var headerField = function headerField(headers, field) {
9393
} else if (
9494
(file.name.indexOf('magnitude1') > -1 ||
9595
file.name.indexOf('magnitude2') > -1) &&
96-
header[field][0] > 4
96+
header[field][0] !== 4
9797
) {
9898
issues[file.relativePath] = new Issue({
9999
file: file,

0 commit comments

Comments
 (0)