diff --git a/src/ui/parcellationRegion/region.base.spec.ts b/src/ui/parcellationRegion/region.base.spec.ts index 0b09bc95d1ec46e3345fcc4f2596b00ba1d09ef1..a89baf7b08a98e0260ab68387055e84579c94188 100644 --- a/src/ui/parcellationRegion/region.base.spec.ts +++ b/src/ui/parcellationRegion/region.base.spec.ts @@ -2,83 +2,9 @@ import { TestBed } from '@angular/core/testing' import { MockStore, provideMockStore } from '@ngrx/store/testing' import { RegionBase, regionInOtherTemplateSelector, getRegionParentParcRefSpace } from './region.base' -const mr1wrong = { - labelIndex: 1, - name: 'mr1', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'fff-bbb' - } - } -} - -const mr0wrong = { - labelIndex: 1, - name: 'mr0', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'aaa-fff' - } - } -} - - -const mr1lh = { - labelIndex: 1, - name: 'mr1 - left hemisphere', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'ccc-bbb' - } - } -} - -const mr1rh = { - labelIndex: 1, - name: 'mr1 - right hemisphere', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'ccc-bbb' - } - } -} - -const mr0lh = { - labelIndex: 1, - name: 'mr0 - left hemisphere', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'aaa-bbb' - } - } -} - -const mr0rh = { - labelIndex: 1, - name: 'mr0 - right hemisphere', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'aaa-bbb' - } - } -} - -const mr1 = { - labelIndex: 1, - name: 'mr1', - fullId: { - kg: { - kgSchema: 'fzj/mock/pr', - kgId: 'ccc-bbb' - } - } -} +/** + * regions + */ const mr0 = { labelIndex: 1, @@ -91,164 +17,427 @@ const mr0 = { } } -// parcellations - -const mp1h = { - name: 'mp1h', - regions: [ mr1lh, mr0lh, mr0rh, mr1rh ] +enum EnumParcRegVersion{ + V1_18 = 'V1_18', + V2_4 = "V2_4" } -const mpWrong = { - name: 'mp1h', - regions: [ mr1wrong, mr0wrong ] -} - -const mp0 = { - name: 'mp0', - regions: [ mr1, mr0 ] -} - -// templates +const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) => { + switch (version) { + case EnumParcRegVersion.V1_18: { + /** + * regions + */ + + const mr1wrong = { + labelIndex: 1, + name: 'mr1', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'fff-bbb' + } + } + } + + const mr0wrong = { + labelIndex: 1, + name: 'mr0', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-fff' + } + } + } -const mt0 = { - name: 'mt0', - fullId: 'fzj/mock/rs/v0.0.0/aaa-bbb', - parcellations: [ mp0 ] -} -const mt1 = { - name: 'mt1', - fullId: 'fzj/mock/rs/v0.0.0/bbb-bbb', - parcellations: [ mp0 ] -} + const mr1lh = { + labelIndex: 1, + name: 'mr1 - left hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + const mr1rh = { + labelIndex: 1, + name: 'mr1 - right hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + const mr0lh = { + labelIndex: 1, + name: 'mr0 - left hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-bbb' + } + } + } + + const mr0rh = { + labelIndex: 1, + name: 'mr0 - right hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-bbb' + } + } + } + + const mr1 = { + labelIndex: 1, + name: 'mr1', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + // parcellations + + const mp1h = { + name: 'mp1h', + regions: [ mr1lh, mr0lh, mr0rh, mr1rh ] + } + + const mpWrong = { + name: 'mp1h', + regions: [ mr1wrong, mr0wrong ] + } + + const mp0 = { + name: 'mp0', + regions: [ mr1, mr0 ] + } + + // templates + + const mt0 = { + name: 'mt0', + fullId: 'fzj/mock/rs/v0.0.0/aaa-bbb', + parcellations: [ mp0 ] + } + + const mt1 = { + name: 'mt1', + fullId: 'fzj/mock/rs/v0.0.0/bbb-bbb', + parcellations: [ mp0 ] + } + + const mt2 = { + name: 'mt2', + fullId: 'fzj/mock/rs/v0.0.0/ccc-bbb', + parcellations: [ mp1h ] + } + + const mt3 = { + name: 'mt3', + fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', + parcellations: [ mp1h ] + } + + const mtWrong = { + name: 'mtWrong', + fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', + parcellations: [ mpWrong ] + } + + const mockFetchedTemplates = [ mt0, mt1, mt2, mt3, mtWrong ] + return { + mockFetchedTemplates, + mt2, + mt0, + mp0, + mt1, + mp1h, + mr0lh, + mt3, + mr0rh + } -const mt2 = { - name: 'mt2', - fullId: 'fzj/mock/rs/v0.0.0/ccc-bbb', - parcellations: [ mp1h ] -} + } + case EnumParcRegVersion.V2_4: { + /** + * regions + */ + + const mr1wrong = { + labelIndex: 1, + name: 'mr1', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'fff-bbb' + } + } + } + + const mr0wrong = { + labelIndex: 1, + name: 'mr0', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-fff' + } + } + } -const mt3 = { - name: 'mt3', - fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', - parcellations: [ mp1h ] -} -const mtWrong = { - name: 'mtWrong', - fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', - parcellations: [ mpWrong ] + const mr1lh = { + labelIndex: 1, + name: 'mr1', + status: 'left hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + const mr1rh = { + labelIndex: 1, + name: 'mr1', + status: 'right hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + const mr0lh = { + labelIndex: 1, + name: 'mr0', + status: 'left hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-bbb' + } + } + } + + const mr0rh = { + labelIndex: 1, + name: 'mr0', + status: 'right hemisphere', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'aaa-bbb' + } + } + } + + const mr1 = { + labelIndex: 1, + name: 'mr1', + fullId: { + kg: { + kgSchema: 'fzj/mock/pr', + kgId: 'ccc-bbb' + } + } + } + + // parcellations + + const mp1h = { + name: 'mp1h', + regions: [ mr1lh, mr0lh, mr0rh, mr1rh ] + } + + const mpWrong = { + name: 'mp1h', + regions: [ mr1wrong, mr0wrong ] + } + + const mp0 = { + name: 'mp0', + regions: [ mr1, mr0 ] + } + + // templates + + const mt0 = { + name: 'mt0', + fullId: 'fzj/mock/rs/v0.0.0/aaa-bbb', + parcellations: [ mp0 ] + } + + const mt1 = { + name: 'mt1', + fullId: 'fzj/mock/rs/v0.0.0/bbb-bbb', + parcellations: [ mp0 ] + } + + const mt2 = { + name: 'mt2', + fullId: 'fzj/mock/rs/v0.0.0/ccc-bbb', + parcellations: [ mp1h ] + } + + const mt3 = { + name: 'mt3', + fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', + parcellations: [ mp1h ] + } + + const mtWrong = { + name: 'mtWrong', + fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb', + parcellations: [ mpWrong ] + } + + const mockFetchedTemplates = [ mt0, mt1, mt2, mt3, mtWrong ] + return { + mockFetchedTemplates, + mt2, + mt0, + mp0, + mt1, + mp1h, + mr0lh, + mt3, + mr0rh + } + } + default: throw new Error(`version needs to be v1.18 or v2.4`) + } } -const mockFetchedTemplates = [ mt0, mt1, mt2, mt3, mtWrong ] - describe('> region.base.ts', () => { describe('> regionInOtherTemplateSelector', () => { - describe('> no hemisphere selected, simulates big brain cyto map', () => { - - let result: any[] - beforeAll(() => { - result = regionInOtherTemplateSelector.projector({ fetchedTemplates: mockFetchedTemplates, templateSelected: mt0 }, { region: mr0 }) - }) + for (const enumKey of Object.keys(EnumParcRegVersion)) { + describe(`> selector version for ${enumKey}`, () => { - it('> length checks out', () => { - expect(result.length).toEqual(5) - }) + const { mockFetchedTemplates, mt2, mt0, mp0, mt1, mp1h, mr0lh, mt3, mr0rh } = getRegionInOtherTemplateSelectorBundle(enumKey as EnumParcRegVersion) - it('> does not contain itself', () => { - expect(result).not.toContain( - jasmine.objectContaining({ - template: mt0, - parcellation: mp0, - region: mr0 + describe('> no hemisphere selected, simulates big brain cyto map', () => { + + let result: any[] + beforeAll(() => { + result = regionInOtherTemplateSelector.projector({ fetchedTemplates: mockFetchedTemplates, templateSelected: mt0 }, { region: mr0 }) }) - ) - }) - - it('> no hemisphere result has no hemisphere meta data', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt1, - parcellation: mp0, - region: mr0 + + it('> length checks out', () => { + expect(result.length).toEqual(5) }) - ) - }) - - it('> hemisphere result has hemisphere metadata # 1', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt2, - parcellation: mp1h, - region: mr0lh, - hemisphere: 'left hemisphere' + + it('> does not contain itself', () => { + expect(result).not.toContain( + jasmine.objectContaining({ + template: mt0, + parcellation: mp0, + region: mr0 + }) + ) }) - ) - }) - it('> hemisphere result has hemisphere metadata # 2', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt3, - parcellation: mp1h, - region: mr0lh, - hemisphere: 'left hemisphere' + + it('> no hemisphere result has no hemisphere meta data', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt1, + parcellation: mp0, + region: mr0 + }) + ) }) - ) - }) - it('> hemisphere result has hemisphere metadata # 3', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt3, - parcellation: mp1h, - region: mr0rh, - hemisphere: 'right hemisphere' + + it('> hemisphere result has hemisphere metadata # 1', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt2, + parcellation: mp1h, + region: mr0lh, + hemisphere: 'left hemisphere' + }) + ) }) - ) - }) - it('> hemisphere result has hemisphere metadata # 4', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt3, - parcellation: mp1h, - region: mr0rh, - hemisphere: 'right hemisphere' + it('> hemisphere result has hemisphere metadata # 2', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt3, + parcellation: mp1h, + region: mr0lh, + hemisphere: 'left hemisphere' + }) + ) }) - ) - }) - }) - - describe('> hemisphere data selected (left hemisphere), simulates julich-brain in mni152', () => { - let result - beforeAll(() => { - result = regionInOtherTemplateSelector.projector({ fetchedTemplates: mockFetchedTemplates, templateSelected: mt2 }, { region: mr0lh }) - }) - - it('> length checks out', () => { - expect(result.length).toEqual(3) - }) - - it('> does not select wrong hemisphere (right hemisphere)', () => { - expect(result).not.toContain( - jasmine.objectContaining({ - template: mt3, - parcellation: mp1h, - region: mr0rh, + it('> hemisphere result has hemisphere metadata # 3', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt3, + parcellation: mp1h, + region: mr0rh, + hemisphere: 'right hemisphere' + }) + ) }) - ) - }) - - it('> select the corresponding hemisphere (left hemisphere), but without hemisphere metadata', () => { - expect(result).toContain( - jasmine.objectContaining({ - template: mt3, - parcellation: mp1h, - region: mr0lh + it('> hemisphere result has hemisphere metadata # 4', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt3, + parcellation: mp1h, + region: mr0rh, + hemisphere: 'right hemisphere' + }) + ) }) - ) + }) + + describe('> hemisphere data selected (left hemisphere), simulates julich-brain in mni152', () => { + let result + beforeAll(() => { + result = regionInOtherTemplateSelector.projector({ fetchedTemplates: mockFetchedTemplates, templateSelected: mt2 }, { region: mr0lh }) + }) + + it('> length checks out', () => { + expect(result.length).toEqual(3) + }) + + it('> does not select wrong hemisphere (right hemisphere)', () => { + expect(result).not.toContain( + jasmine.objectContaining({ + template: mt3, + parcellation: mp1h, + region: mr0rh, + }) + ) + }) + + it('> select the corresponding hemisphere (left hemisphere), but without hemisphere metadata', () => { + expect(result).toContain( + jasmine.objectContaining({ + template: mt3, + parcellation: mp1h, + region: mr0lh + }) + ) + }) + }) + }) - }) - + } + }) describe('> RegionBase', () => {