-
Notifications
You must be signed in to change notification settings - Fork 61
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 #673 from PaulHax/overlapping-seg
feat(segmentGroups): support overlapping segments in SEG files
- Loading branch information
Showing
9 changed files
with
226 additions
and
63 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData'; | ||
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray'; | ||
import vtkImageExtractComponentsFilter from '../imageExtractComponentsFilter'; | ||
|
||
describe('vtkImageExtractComponentsFilter', () => { | ||
it('should extract specified components', () => { | ||
// Create an image data with known scalar components | ||
const imageData = vtkImageData.newInstance(); | ||
imageData.setDimensions([2, 2, 1]); | ||
|
||
// Create scalar data with 3 components per voxel | ||
const scalars = vtkDataArray.newInstance({ | ||
numberOfComponents: 3, | ||
values: new Uint8Array([ | ||
// Voxel 0 | ||
10, 20, 30, | ||
// Voxel 1 | ||
40, 50, 60, | ||
// Voxel 2 | ||
70, 80, 90, | ||
// Voxel 3 | ||
100, 110, 120, | ||
]), | ||
}); | ||
|
||
imageData.getPointData().setScalars(scalars); | ||
|
||
// Create the filter and set components to extract | ||
const extractComponentsFilter = | ||
vtkImageExtractComponentsFilter.newInstance(); | ||
extractComponentsFilter.setComponents([0, 2]); // Extract components 0 and 2 | ||
extractComponentsFilter.setInputData(imageData); | ||
extractComponentsFilter.update(); | ||
|
||
const outputData = extractComponentsFilter.getOutputData(); | ||
const outputScalars = outputData.getPointData().getScalars(); | ||
const outputValues = outputScalars.getData(); | ||
|
||
// Expected output | ||
const expectedValues = new Uint8Array([ | ||
// Voxel 0 | ||
10, 30, | ||
// Voxel 1 | ||
40, 60, | ||
// Voxel 2 | ||
70, 90, | ||
// Voxel 3 | ||
100, 120, | ||
]); | ||
|
||
// Check if output matches expected values | ||
expect(outputScalars.getNumberOfComponents()).toBe(2); | ||
expect(outputValues).toEqual(expectedValues); | ||
}); | ||
}); |
Oops, something went wrong.