diff --git a/cryoet_data_portal_neuroglancer/models/json_generator.py b/cryoet_data_portal_neuroglancer/models/json_generator.py index dbc0580..9c414fb 100644 --- a/cryoet_data_portal_neuroglancer/models/json_generator.py +++ b/cryoet_data_portal_neuroglancer/models/json_generator.py @@ -191,20 +191,24 @@ def generate_json(self) -> dict: class ImageVolumeJSONGenerator(RenderingJSONGenerator): """Generates JSON Neuroglancer config for volume rendering.""" - rendering_depth: int # Ideally, this should be a power of 2 - contrast_limits: tuple[float, float] = (-64, 64) - threedee_contrast_limits: tuple[float, float] = (-64, 64) - is_visible: bool = True + color: str + rendering_depth: int def __post_init__(self): self._type = RenderingTypes.IMAGE def _get_shader(self) -> dict[str, Any]: - shader_builder = ImageShaderBuilder( - contrast_limits=self.contrast_limits, - threedee_contrast_limits=self.threedee_contrast_limits, + shader = ( + f'#uicontrol vec3 color color(default="{self.color}")\n' + f"#uicontrol invlerp toRaw(range=[0, 1], window=[-1, 2])\n" + f"void main() {{\n" + f" emitRGBA(vec4(color * toRaw(getDataValue()), toRaw(getDataValue())));\n" + f"}}" ) - return shader_builder.build_shader() + return { + "shader": shader, + "shaderControls": {"color": self.color}, + } def generate_json(self) -> dict: return { diff --git a/cryoet_data_portal_neuroglancer/state_generator.py b/cryoet_data_portal_neuroglancer/state_generator.py index 124b2e0..6cbe1ea 100644 --- a/cryoet_data_portal_neuroglancer/state_generator.py +++ b/cryoet_data_portal_neuroglancer/state_generator.py @@ -103,14 +103,17 @@ def generate_image_volume_layer( source: str, name: str = None, url: str = None, + color: str = "#FFFFFF", scale: tuple[float, float, float] = (1.0, 1.0, 1.0), is_visible: bool = True, rendering_depth: int = 1024, ) -> dict[str, Any]: source, name, url, _, scale = _setup_creation(source, name, url, scale=scale) + _validate_color(color) return ImageVolumeJSONGenerator( source=source, name=name, + color=color, scale=scale, is_visible=is_visible, rendering_depth=rendering_depth,