Skip to content
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

extend pydantic model #163

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions siibra/core/parcellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ..openminds.base import ConfigBaseModel

from datetime import date
from typing import List, Set, Union
from typing import List, Optional, Set, Union
from memoization import cached
from difflib import SequenceMatcher
from pydantic import Field
Expand All @@ -47,6 +47,7 @@ class SiibraParcellationModel(ConfigBaseModel):
id: str = Field(..., alias="@id")
type: str = Field(SIIBRA_PARCELLATION_MODEL_TYPE, const=True, alias="@type")
name: str
modality: Optional[str]
datasets: List[DatasetJsonModel]
brain_atlas_versions: List[BrainAtlasVersionModel] = Field(..., alias="brainAtlasVersions")

Expand Down Expand Up @@ -525,7 +526,7 @@ def _from_json(cls, obj):
return result

def get_brain_atlas_version_id(self, space: Space) -> str:
return f"{self.id}/{space.to_model().id}"
return f"{self.id}/{space.model_id}"

def get_brain_atlas_version_name(self, space: Space) -> str:
return f"{self.name} in {space.to_model().full_name}"
Expand All @@ -539,6 +540,7 @@ def to_model(self, **kwargs) -> SiibraParcellationModel:
id=self.model_id,
type=SIIBRA_PARCELLATION_MODEL_TYPE,
name=self.name,
modality=self.modality,
datasets=[ds.to_model() for ds in self.datasets if isinstance(ds, OriginDescription) or isinstance(ds, EbrainsDataset)],
brain_atlas_versions=[BrainAtlasVersionModel(
id=self.get_brain_atlas_version_id(spc),
Expand Down
1 change: 1 addition & 0 deletions siibra/features/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

class ConnectivityMatrixDataModel(ConfigBaseModel):
id: str = Field(..., alias="@id")
type: str = Field("siibra/connectivity", const=True)
name: str
parcellations: List[Dict[str, str]]
matrix: Optional[NpArrayDataModel]
Expand Down
2 changes: 1 addition & 1 deletion test/features/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
def test_conn_to_model(conn_feat):
model = None
try:
model = conn_feat.to_model()
model = conn_feat.to_model(detail=True)
except Exception as err:
pytest.xfail(str(err))
if model:
Expand Down