Skip to content

Commit 78cc9ce

Browse files
authored
Merge pull request #567 from olgn/incorrect-header-dim-indexing
fix magnitude and t1w dimension check
2 parents db97e26 + 88b1120 commit 78cc9ce

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

tests/headerField.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ 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 do not have exactly dimensions.', () => {
5+
it('should throw an error if _magnitude1 or _magnitude2 files do not have exactly 3 dimensions.', () => {
66
const headers = [
77
// each of these headers has one too many dimensions on the 'dim' field.
88
[
@@ -69,9 +69,9 @@ describe('headerFields', () => {
6969
relativePath: 'sub-01_magnitude1.nii',
7070
},
7171
{
72-
dim: [4, 1, 1, 1],
73-
pixdim: [4, 1, 1, 1],
74-
xyzt_units: [4, 1, 1, 1],
72+
dim: [3, 1, 1, 1],
73+
pixdim: [3, 1, 1, 1],
74+
xyzt_units: [3, 1, 1, 1],
7575
},
7676
],
7777
[
@@ -80,9 +80,9 @@ describe('headerFields', () => {
8080
relativePath: 'sub-01_magnitude2.nii',
8181
},
8282
{
83-
dim: [4, 1, 1, 1],
84-
pixdim: [4, 1, 1, 1],
85-
xyzt_units: [4, 1, 1, 1],
83+
dim: [3, 1, 1, 1],
84+
pixdim: [3, 1, 1, 1],
85+
xyzt_units: [3, 1, 1, 1],
8686
},
8787
],
8888
]
@@ -131,8 +131,8 @@ describe('headerFields', () => {
131131
relativePath: 'sub-01_T1w.nii',
132132
},
133133
{
134-
dim: [4, 1, 1, 1],
135-
pixdim: [4, 1, 1, 1],
134+
dim: [3, 1, 1, 1],
135+
pixdim: [3, 1, 1, 1],
136136
xyzt_units: [4, 1, 1, 1],
137137
},
138138
],

validators/headerFields.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ 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].length !== 4
9797
) {
9898
issues[file.relativePath] = new Issue({
9999
file: file,
100100
code: 94,
101101
evidence: 'this magnitude file has more than three dimensions. ',
102102
})
103-
} else if (file.name.indexOf('T1w') > -1 && header[field][0] !== 4) {
103+
} else if (file.name.indexOf('T1w') > -1 && header[field].length !== 4) {
104104
issues[file.relativePath] = new Issue({
105105
file: file,
106106
code: 95,

0 commit comments

Comments
 (0)