-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basic raw volumetric data support #35
base: master
Are you sure you want to change the base?
Changes from all commits
b4a760a
5d48750
7eff0fc
1b42902
42ab373
1bfb911
b91e120
93a8ce2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
from __future__ import annotations | ||
|
||
from datetime import datetime, timezone | ||
from typing import Any, Literal, Mapping, Optional, Union | ||
from typing import Any, Literal, Mapping, Optional, TypedDict, Union | ||
from uuid import uuid4 | ||
|
||
from pydantic import BaseModel, Field | ||
|
@@ -29,6 +29,7 @@ | |
"label_from_uri", | ||
"line", | ||
"parse", | ||
"raw_volume", | ||
"representation", | ||
"sphere", | ||
"structure", | ||
|
@@ -37,6 +38,8 @@ | |
"tooltip_from_uri", | ||
"transform", | ||
"transparency", | ||
"volume_representation", | ||
"vs_volume" | ||
] | ||
|
||
|
||
|
@@ -160,9 +163,46 @@ class DownloadParams(BaseModel): | |
url: str = Field(description="URL from which to pull structure data.") | ||
|
||
|
||
ParseFormatT = Literal["mmcif", "bcif", "pdb"] | ||
ParseFormatT = Literal["mmcif", "bcif", "pdb", "map", "vs-density"] | ||
# RawVolumeSourceT = Literal["map", "omezarr", "ometiff_image", "tiff_stack"] | ||
RawVolumeSourceT = Literal["map"] | ||
|
||
ChannelIdsMapping = dict[str, str] | ||
|
||
|
||
class RawVolumeOptionsT(TypedDict): | ||
""" | ||
Specifies the desired voxel size. Overwrites the automatically determined voxel size (e.g., the one based on the map header or its analogue for other formats). | ||
Specifies the mapping of sequential channel IDs to user-defined ones. | ||
""" | ||
voxel_size: float | None | ||
channel_ids_mapping: ChannelIdsMapping | None | ||
|
||
class VSVolumeOptionsT(TypedDict): | ||
""" | ||
Specifies the max points of the volume to be loaded. | ||
Specifies the time frame index the data for which will be loaded. If not provided, the data for all of the available time frame indices will be loaded. | ||
Specifies the channel ID the data for which will be loaded. If not provided, the data for all of the available channel IDs will be loaded. | ||
""" | ||
max_points: int | None | ||
time: int | None | ||
channel_id: str | None | ||
|
||
class RawVolumeParams(BaseModel): | ||
""" | ||
Create a volume from a parsed data resource based on the provided parameters. | ||
""" | ||
|
||
source: RawVolumeSourceT = Field(description="The type of the raw input file with volumetric data.") | ||
options: RawVolumeOptionsT | None = Field(description="Specifies the voxel size and mapping of sequential channel IDs to user-defined channel IDs.") | ||
|
||
class VSVolumeParams(BaseModel): | ||
""" | ||
Create a volume from a parsed data resource based on the provided parameters. | ||
""" | ||
|
||
options: VSVolumeOptionsT | None = Field(description="Optionally specifies the max points, time frame index, and channel ID") | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to keep the param hierarchy flat (without nesting) - it will be much easier to process params in frontend. Also it will allow adding
|
||
class ParseParams(BaseModel): | ||
""" | ||
Parse node, describing how to parse downloaded data. | ||
|
@@ -233,8 +273,9 @@ class ComponentExpression(BaseModel): | |
atom_id: Optional[int] = Field(description="Unique atom identifier (`_atom_site.id`)") | ||
atom_index: Optional[int] = Field(description="0-based atom index in the source file") | ||
|
||
|
||
RepresentationTypeT = Literal["ball_and_stick", "cartoon", "surface"] | ||
# TODO: "slice" | ||
VolumeRepresentationTypeT = Literal["isosurface", "direct_volume", "slice"] | ||
RepresentationTypeT = Literal["ball_and_stick", "cartoon"] | ||
ColorNamesT = Literal[ | ||
"aliceblue", | ||
"antiquewhite", | ||
|
@@ -387,6 +428,14 @@ class ComponentExpression(BaseModel): | |
ColorT = Union[ColorNamesT, str] # str represents hex colors for now | ||
|
||
|
||
# TODO: Segmentation too? | ||
class VolumeRepresentationParams(BaseModel): | ||
""" | ||
Representation node, describing how to represent a volume. | ||
""" | ||
# TODO: add slice | ||
type: VolumeRepresentationTypeT = Field(description="Representation type, i.e. isosurface or direct_volume") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose eventually we will have more params here, e.g. isovalue, slice plane. But if this is just WIP, it's fine to add them later. |
||
|
||
class RepresentationParams(BaseModel): | ||
""" | ||
Representation node, describing how to represent a component. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
selector
makes sense here, as we have no way of applying our current selectors to volumes.At least for now.
In the future we might add different types of selectors, which would apply to volumes.