@@ -14,29 +14,30 @@ import {
1414} from '@/src/utils/doubleKeyRecord' ;
1515import { Maybe } from '@/src/types' ;
1616import { identity } from '@/src/utils' ;
17+ import { LAYER_PRESET_BY_MODALITY , LAYER_PRESET_DEFAULT } from '@/src/config' ;
1718import { createViewConfigSerializer } from './common' ;
18- import { DEFAULT_PRESET } from '../../vtk/ColorMaps' ;
1919import { ViewConfig } from '../../io/state-file/schema' ;
2020import { LayersConfig } from './types' ;
2121import { LayerID , useLayersStore } from '../datasets-layers' ;
2222import { useDICOMStore } from '../datasets-dicom' ;
2323
24- export const MODALITY_TO_PRESET : Record < string , string > = {
25- PT : '2hot' ,
26- } ;
27-
2824function getPreset ( id : LayerID ) {
2925 const layersStore = useLayersStore ( ) ;
3026 const layer = layersStore . getLayer ( id ) ;
31- if ( layer ) {
32- if ( layer . selection . type === 'dicom' ) {
33- const dicomStore = useDICOMStore ( ) ;
34- const { Modality = undefined } =
35- dicomStore . volumeInfo [ layer . selection . volumeKey ] ;
36- return ( Modality && MODALITY_TO_PRESET [ Modality ] ) || DEFAULT_PRESET ;
37- }
27+ if ( ! layer ) {
28+ throw new Error ( `Layer ${ id } not found` ) ;
29+ }
30+
31+ if ( layer . selection . type === 'dicom' ) {
32+ const dicomStore = useDICOMStore ( ) ;
33+ const { Modality = undefined } =
34+ dicomStore . volumeInfo [ layer . selection . volumeKey ] ;
35+ return (
36+ ( Modality && LAYER_PRESET_BY_MODALITY [ Modality ] ) || LAYER_PRESET_DEFAULT
37+ ) ;
3838 }
39- return DEFAULT_PRESET ;
39+
40+ return LAYER_PRESET_DEFAULT ;
4041}
4142
4243export const defaultLayersConfig = ( ) : LayersConfig => ( {
0 commit comments