-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from bids-standard/bep031_review_updates
Bep031 review updates
- Loading branch information
Showing
21 changed files
with
319 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
bids-validator/utils/files/generateMergedSidecarDictWithPath.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
bids-validator/validators/microscopy/__tests__/checkJSONAndField.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { assert } from 'chai' | ||
import checkJSONAndField from '../checkJSONAndField' | ||
|
||
describe('checkJSONAndField()', () => { | ||
const emptyJsonContentsDict = { | ||
'test.json': {}, | ||
} | ||
it('returns no issues with empty arguments', () => { | ||
const issues = checkJSONAndField({}, {}) | ||
expect(issues.length).toBe(0) | ||
}) | ||
|
||
it('returns issue 225 with no json for ome files', () => { | ||
const files = { | ||
ome: [{ relativePath: 'test.ome.tif' }], | ||
} | ||
const issues = checkJSONAndField(files, emptyJsonContentsDict) | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(225) | ||
}) | ||
|
||
it('returns issue 225 with no json for tif files', () => { | ||
const files = { | ||
tif: [{ relativePath: 'test.tif' }], | ||
} | ||
const issues = checkJSONAndField(files, emptyJsonContentsDict) | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(225) | ||
}) | ||
|
||
it('returns issue 225 with no json for png files', () => { | ||
const files = { | ||
png: [{ relativePath: 'test.png' }], | ||
} | ||
const issues = checkJSONAndField(files, emptyJsonContentsDict) | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(225) | ||
}) | ||
|
||
it('returns warning 223 if chunk entity present but missing metadata', () => { | ||
const files = { | ||
ome: [{ relativePath: '/test_chunk-01.ome.tif' }], | ||
} | ||
const jsonContentsDict = { | ||
'/test_chunk-01.json': { testKey: 'testValue' }, | ||
} | ||
const issues = checkJSONAndField(files, jsonContentsDict) | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(223) | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
bids-validator/validators/microscopy/__tests__/checkSample.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import checkSamples from '../checkSamples' | ||
describe('checkSamples()', () => { | ||
it('returns issue 214 when no samples.tsv is present', () => { | ||
const fileList = { | ||
'0': { relativePath: '/test.tsv' }, | ||
} | ||
const issues = checkSamples(fileList) | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(214) | ||
}) | ||
|
||
it('doesnt return issue 214 when samples.tsv is present', () => { | ||
const fileList = { | ||
'0': { relativePath: '/samples.tsv' }, | ||
} | ||
const issues = checkSamples(fileList) | ||
expect(issues.length).toBe(0) | ||
}) | ||
}) |
Binary file not shown.
Binary file added
BIN
+2.61 KB
bids-validator/validators/microscopy/__tests__/data/invalid_id.ome.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
99 changes: 99 additions & 0 deletions
99
bids-validator/validators/microscopy/__tests__/validate.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import path from 'path' | ||
|
||
import readDir from '../../../utils/files/readDir' | ||
import validate from '../validate' | ||
|
||
const dataDir = path.join(__dirname, '/data') | ||
|
||
const jsonContent = { | ||
Manufacturer: 'Miltenyi Biotec', | ||
ManufacturersModelName: 'UltraMicroscope II', | ||
BodyPart: 'CSPINE', | ||
SampleEnvironment: 'ex vivo', | ||
SampleFixation: '4% paraformaldehyde, 2% glutaraldehyde', | ||
SampleStaining: 'Luxol fast blue', | ||
PixelSize: [1, 1, 1], | ||
PixelSizeUnits: 'um', | ||
Immersion: 'Oil', | ||
NumericalAperture: 1.4, | ||
Magnification: 40, | ||
ChunkTransformationMatrix: [ | ||
[1, 0, 0, 0], | ||
[0, 2, 0, 0], | ||
[0, 0, 1, 0], | ||
[0, 0, 0, 1], | ||
], | ||
ChunkTransformationMatrixAxis: ['X', 'Y', 'Z'], | ||
} | ||
|
||
describe('validate', () => { | ||
it('returns error 227 with extension/id mismatch', () => { | ||
const fileName = 'btif_id.ome.tif' | ||
const files = [ | ||
{ | ||
name: fileName, | ||
relativePath: `/bids-validator/validators/microscopy/__tests__/data/${fileName}`, | ||
path: path.join(dataDir, fileName), | ||
}, | ||
] | ||
|
||
expect.assertions(3) | ||
return validate(files, {}).then(issues => { | ||
expect(issues.length).toBe(2) | ||
expect(issues[0].code).toBe(227) | ||
expect(issues[1].code).toBe(226) | ||
}) | ||
}) | ||
|
||
it('returns error 227 with incorrect id in magic number', () => { | ||
const fileName = 'invalid_id.ome.tif' | ||
const files = [ | ||
{ | ||
name: fileName, | ||
relativePath: `/bids-validator/validators/microscopy/__tests__/data/${fileName}`, | ||
path: path.join(dataDir, fileName), | ||
}, | ||
] | ||
expect.assertions(2) | ||
return validate(files, {}).then(issues => { | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(227) | ||
}) | ||
}) | ||
|
||
it('returns error 227 with tif id and btf extension', () => { | ||
const fileName = 'tif_id.ome.btf' | ||
const files = [ | ||
{ | ||
name: fileName, | ||
relativePath: `/bids-validator/validators/microscopy/__tests__/data/${fileName}`, | ||
path: path.join(dataDir, fileName), | ||
}, | ||
] | ||
|
||
expect.assertions(2) | ||
return validate(files, {}).then(issues => { | ||
expect(issues.length).toBe(1) | ||
expect(issues[0].code).toBe(227) | ||
}) | ||
}) | ||
|
||
it('validates with valid data', () => { | ||
const fileName = 'valid.ome.tif' | ||
const relativePath = `/bids-validator/validators/microscopy/__tests__/data/${fileName}` | ||
const files = [ | ||
{ | ||
name: fileName, | ||
relativePath: relativePath, | ||
path: path.join(dataDir, fileName), | ||
}, | ||
] | ||
const jsonContentDict = {} | ||
jsonContentDict[relativePath.replace('.ome.tif', '.json')] = jsonContent | ||
|
||
expect.assertions(1) | ||
return validate(files, jsonContentDict).then(issues => { | ||
expect(issues.length).toBe(0) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.