Skip to content

Commit

Permalink
feat(segmentation): Add polymorph segmentation and representation con…
Browse files Browse the repository at this point in the history
…version capabilities (#844)

* Add wasm conversion contour 2 surface

* Adding more converters

* remove circle json

* remove contour json

* remove surfaces json

* edit the polyseg contour example

* polyseg contour

* edits

* Update dependencies and import statements

* Fix wasm loading issue and initialize polySeg
instance

* update

* Fix camera clipping range and add surface actor to
element

* Fix camera clipping range reset issue

* Add polySegManager for controlling polymorphic segmentations

* Refactor labelmap to surface conversion in PolySegManager

* Refactor segmentation conversion and surface display

* Add segment index dropdown to toolbar

* fix surface segmentation to include multiple geometries

* Refactor surface conversion in PolySegManager

* Refactor segmentation-related functions and add new features

* Remove defaultOptions from viewport configuration

* Update Viewport and SegmentationStateManager

* Add background color support to viewports

* Remove unused code for manual labelmap segmentation tools

* Refactor surface representation update in PolySegManager

* Add 3D anatomy toggle button and set initial visibility to false

* Add info section and update instructions in PolySegWasmVolumeLabelmapToSurface example

* Update DICOM web URL in code

* Update labelmap validation and polySeg conversion

* Fix segmentation handling and add warning message

* Add getSegmentAtWorldPoint utility function

* Add isPointInsidePolyline function for 2D and 3D points

* Refactor addSegmentationRepresentation function and RepresentationPublicInputOptions

* Fix segmentationRepresentationUID assignment

* Fix segmentIndex conversion issue and update annotation rendering

* Fix SurfaceData initialization in surfaceDisplay.ts

* Refactor surface and labelmap rendering functions

* Refactor PolySegManager to support both volume and stack viewports

* Add ISurface interface to Surface class and update references***

***Update data type in IGeometry interface to use ISurface interface***

***Add setPoints and setPolys methods to ISurface interface***

***Update updateSurfaceRepresentation method in PolySegManager class to use ISurface interface methods

* Refactor render function in surfaceDisplay.ts

* Increase radius for 3D viewport and pass additional parameters to computeAndAddLabelmapRepresentation

* Refactor polySegManager.ts file

* Add VTK contour support and refactor contour display logic

* Refactor mergePoints.ts to remove duplicate points and update point references in lines array

* Merge duplicate point logic in getDeduplicatedVTKPolyDataPoints

* Add cachedStats to ProbeTool and add contour annotation to contourDisplay

* Add new tools and functionality for segmentation

* Update SegmentationRepresentations in PolySegManager

* Add lodash.get and hull.js dependencies, fix null check in AnnotationTool, and optimize drawLoop function

* Update user authentication logic

* moving towards web workers

* Update user authentication logic to use bcrypt hashing algorithm

* refactoring

* refactoring contour to surface

* update yarn lock

* moved the label map to surface to worker

* rename

* start of labelmap to worker

* Refactor code to improve performance and readability

* Refactor code to improve performance and readability

* Refactor variable names and improve code readability

* Refactor code to improve performance and readability

* Fix bug in login functionality

* more on surface to labelmap

* move to Map for surface rendering

* fix surface representation

* add stack labelmap to surface example

* update

* enhance stack to volume segmentation conversion

* add stack seg to surface

* proper implemntation of contour to labelmap for stack

* surface rendering on stack viewport

* fix surface from contour

* first api fix push

* remaining

* add example info page

* applied self review comments

* remainign

* remainign

* demo

* Add Surface class and update polySeg options

* add manipulation tools

* Fix rendering issue and add new utility function for 3D polyline

* more updates

* Refactor segmentation-related code and fix error handling

* Add PolySegConversionOptions type

* wip

* Fix stack index in setStack method

* api

* try to precache surface intersections

* Refactor clippingPlaneWorker.js and surfaceRendering/index.ts

* update

* Removed one debugger and fixed a NPE

* update

* Add manipulation bindings and mock contour segmentation

* Fix contour segmentation behavior and add utility functions

* Add triggerAnnotationRenderForToolGroupIds utility function

* Add mock contour segmentation for volume and stack viewports

* Add getViewportImageIds utility function

* api

* Update contour segmentation radius and terminate web worker by name

* Fix compute job limit bug and terminate workers properly

* Remove unused enum and add new enum for worker types

* Add event listener for caching progress

* update

* Add getSegmentationIdRepresentations function to segmentationState.ts and update hoverTimeout in SegmentSelectTool.ts

* Refactor segmentation utilities and tools

* Update search radius for border detection

* Refactor addManipulationBindings function to accept options object

* update review

---------

Co-authored-by: rodrigobasilio2022 <[email protected]>
  • Loading branch information
sedghi and rodrigobasilio2022 authored Feb 7, 2024
1 parent 881872f commit ac21d9f
Show file tree
Hide file tree
Showing 172 changed files with 7,697 additions and 536,617 deletions.
113 changes: 98 additions & 15 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ number
// @public (undocumented)
function applyPreset(actor: VolumeActor, preset: ViewportPreset): void;

// @public (undocumented)
const backgroundColors: {
slicer3D: number[];
};

// @public (undocumented)
export abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
constructor(props: ViewportInput);
Expand Down Expand Up @@ -278,7 +283,8 @@ declare namespace CONSTANTS {
RENDERING_DEFAULTS,
mprCameraValues as MPR_CAMERA_VALUES,
EPSILON,
presets as VIEWPORT_PRESETS
presets as VIEWPORT_PRESETS,
backgroundColors as BACKGROUND_COLORS
}
}
export { CONSTANTS }
Expand Down Expand Up @@ -603,7 +609,7 @@ function createAndCacheDerivedSegmentationImage(referencedImageId: string, optio
function createAndCacheDerivedSegmentationImages(referencedImageIds: Array<string>, options?: DerivedImageOptions): DerivedImages;

// @public (undocumented)
function createAndCacheDerivedSegmentationVolume(referencedVolumeId: string, options: DerivedVolumeOptions): Promise<IImageVolume>;
function createAndCacheDerivedSegmentationVolume(referencedVolumeId: string, options?: DerivedVolumeOptions): Promise<IImageVolume>;

// @public (undocumented)
function createAndCacheDerivedVolume(referencedVolumeId: string, options: DerivedVolumeOptions): Promise<IImageVolume>;
Expand Down Expand Up @@ -632,6 +638,9 @@ function createInt16SharedArray(length: number): Int16Array;
// @public (undocumented)
function createLinearRGBTransferFunction(voiRange: VOIRange): vtkColorTransferFunction;

// @public (undocumented)
function createLocalSegmentationVolume(options: LocalVolumeOptions, volumeId: string, preventCache?: boolean): Promise<IImageVolume>;

// @public (undocumented)
function createLocalVolume(options: LocalVolumeOptions, volumeId: string, preventCache?: boolean): IImageVolume;

Expand Down Expand Up @@ -808,7 +817,9 @@ export enum EVENTS {
// (undocumented)
VOLUME_SCROLL_OUT_OF_BOUNDS = "CORNERSTONE_VOLUME_SCROLL_OUT_OF_BOUNDS",
// (undocumented)
VOLUME_VIEWPORT_NEW_VOLUME = "CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME"
VOLUME_VIEWPORT_NEW_VOLUME = "CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",
// (undocumented)
WEB_WORKER_PROGRESS = "CORNERSTONE_WEB_WORKER_PROGRESS"
}

// @public (undocumented)
Expand Down Expand Up @@ -994,6 +1005,9 @@ function getUnknownVolumeLoaderSchema(): string;
// @public (undocumented)
function getViewportImageCornersInWorld(viewport: IStackViewport | IVolumeViewport): Point3[];

// @public (undocumented)
function getViewportImageIds(viewport: IViewport): string[];

// @public (undocumented)
function getViewportModality(viewport: IViewport, volumeId?: string): string;

Expand Down Expand Up @@ -1221,7 +1235,7 @@ interface IEnabledElement {
// @public (undocumented)
interface IGeometry {
// (undocumented)
data: IContourSet | Surface;
data: IContourSet | ISurface;
// (undocumented)
id: string;
// (undocumented)
Expand Down Expand Up @@ -1437,7 +1451,7 @@ interface IImageVolume {
// (undocumented)
convertToImageSlicesAndCache(): string[];
// (undocumented)
decache?: () => void;
decache?: (completelyRemove?: boolean) => void;
// (undocumented)
destroy(): void;
// (undocumented)
Expand Down Expand Up @@ -1467,6 +1481,8 @@ interface IImageVolume {
// (undocumented)
metadata: Metadata;
// (undocumented)
modified(): void;
// (undocumented)
numVoxels: number;
// (undocumented)
origin: Point3;
Expand Down Expand Up @@ -1762,6 +1778,8 @@ export class ImageVolume implements IImageVolume {
// (undocumented)
metadata: Metadata;
// (undocumented)
modified(): void;
// (undocumented)
protected numFrames: number;
// (undocumented)
numVoxels: number;
Expand Down Expand Up @@ -2029,6 +2047,30 @@ interface IStreamingVolumeProperties {
};
}

// @public (undocumented)
interface ISurface {
// (undocumented)
readonly frameOfReferenceUID: string;
// (undocumented)
getColor(): Point3;
// (undocumented)
getPoints(): number[];
// (undocumented)
getPolys(): number[];
// (undocumented)
getSizeInBytes(): number;
// (undocumented)
readonly id: string;
// (undocumented)
setColor(color: Point3): void;
// (undocumented)
setPoints(points: number[]): void;
// (undocumented)
setPolys(polys: number[]): void;
// (undocumented)
readonly sizeInBytes: number;
}

// @public (undocumented)
function isValidVolume(imageIds: string[]): boolean;

Expand Down Expand Up @@ -3027,6 +3069,33 @@ type StreamingRetrieveOptions = BaseRetrieveOptions & {
streaming: boolean;
};

// @public (undocumented)
export class Surface implements ISurface {
constructor(props: SurfaceProps);
// (undocumented)
readonly frameOfReferenceUID: string;
// (undocumented)
getColor(): RGB;
// (undocumented)
getPoints(): number[];
// (undocumented)
getPolys(): number[];
// (undocumented)
getSizeInBytes(): number;
// (undocumented)
_getSizeInBytes(): number;
// (undocumented)
readonly id: string;
// (undocumented)
setColor(color: RGB): void;
// (undocumented)
setPoints(points: number[]): void;
// (undocumented)
setPolys(polys: number[]): void;
// (undocumented)
readonly sizeInBytes: number;
}

// @public (undocumented)
type SurfaceData = {
points: number[];
Expand Down Expand Up @@ -3183,6 +3252,7 @@ declare namespace Types {
IContour,
PublicSurfaceData,
SurfaceData,
ISurface,
RGB,
ColormapPublic,
ColormapRegistration,
Expand Down Expand Up @@ -3287,7 +3357,8 @@ declare namespace utilities {
convertVolumeToStackViewport,
cacheUtils,
roundNumber,
roundToPrecision
roundToPrecision,
getViewportImageIds
}
}
export { utilities }
Expand Down Expand Up @@ -3494,6 +3565,8 @@ export class Viewport implements IViewport {
// (undocumented)
getCanvas(): HTMLCanvasElement;
// (undocumented)
getClippingPlanesForActor(actorEntry?: ActorEntry): vtkPlane[];
// (undocumented)
_getCorners(bounds: Array<number>): Array<number>[];
// (undocumented)
getCurrentImageIdIndex(): number;
Expand Down Expand Up @@ -3541,12 +3614,8 @@ export class Viewport implements IViewport {
// (undocumented)
_isInBounds(point: Point3, bounds: number[]): boolean;
// (undocumented)
protected newActorAdded: boolean;
// (undocumented)
options: ViewportInputOptions;
// (undocumented)
protected posProcessNewActors(): void;
// (undocumented)
_removeActor(actorUID: string): void;
// (undocumented)
removeActors(actorUIDs: Array<string>): void;
Expand Down Expand Up @@ -3771,7 +3840,8 @@ declare namespace volumeLoader {
getVolumeLoaderSchemes,
registerUnknownVolumeLoader,
getUnknownVolumeLoaderSchema,
createAndCacheDerivedSegmentationVolume
createAndCacheDerivedSegmentationVolume,
createLocalSegmentationVolume
}
}
export { volumeLoader }
Expand Down Expand Up @@ -3841,13 +3911,28 @@ export class VolumeViewport extends BaseVolumeViewport {
// (undocumented)
getNumberOfSlices: () => number;
// (undocumented)
getSliceIndex: () => number;
// (undocumented)
getSlicePlaneCoordinates: () => Array<{
sliceIndex: number;
point: Point3;
}>;
// (undocumented)
getSlicesClippingPlanes(): Array<{
sliceIndex: number;
planes: Array<{
normal: Point3;
origin: Point3;
}>;
}>;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean, resetRotation?: boolean): boolean;
// (undocumented)
resetProperties(volumeId?: string): void;
// (undocumented)
setBlendMode(blendMode: BlendModes, filterActorUIDs?: any[], immediate?: boolean): void;
// (undocumented)
setOrientation(orientation: OrientationAxis, immediate?: boolean): void;
setOrientation(orientation: OrientationAxis | OrientationVectors, immediate?: boolean): void;
// (undocumented)
setSlabThickness(slabThickness: number, filterActorUIDs?: any[]): void;
// (undocumented)
Expand All @@ -3864,8 +3949,6 @@ export class VolumeViewport3D extends BaseVolumeViewport {
// (undocumented)
getRotation: () => number;
// (undocumented)
posProcessNewActors(): void;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean): boolean;
// (undocumented)
resetProperties(volumeId?: string): void;
Expand Down Expand Up @@ -3936,7 +4019,7 @@ class VoxelManager<T> {
// (undocumented)
setAtIJK: (i: number, j: number, k: number, v: any) => void;
// (undocumented)
setAtIJKPoint: ([i, j, k]: [any, any, any], v: any) => void;
setAtIJKPoint: ([i, j, k]: Point3, v: any) => void;
// (undocumented)
setAtIndex: (index: any, v: any) => void;
// (undocumented)
Expand Down
Loading

0 comments on commit ac21d9f

Please sign in to comment.