mobiedantic 0.3.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mobiedantic/__init__.py CHANGED
@@ -4,7 +4,15 @@ import json
4
4
  from pathlib import Path
5
5
 
6
6
  from mobiedantic.generated import Dataset as DatasetSchema
7
- from mobiedantic.generated import ImageDisplay, ImageDisplay1, MergedGrid, Name, Source
7
+ from mobiedantic.generated import (
8
+ ImageDisplay,
9
+ ImageDisplay1,
10
+ MergedGrid,
11
+ Name,
12
+ Source,
13
+ RegionDisplay,
14
+ RegionDisplay1,
15
+ )
8
16
  from mobiedantic.generated import Project as ProjectSchema
9
17
 
10
18
 
@@ -40,7 +48,7 @@ class Dataset:
40
48
  raise ValueError(message)
41
49
  with open(dataset_path) as dataset_file:
42
50
  data = json.loads(dataset_file.read())
43
- self.model = DatasetSchema(**data)
51
+ self.set_model(DatasetSchema(**data))
44
52
 
45
53
  def set_model(self, model: DatasetSchema):
46
54
  self.model = model
@@ -143,11 +151,37 @@ class Dataset:
143
151
  )
144
152
  )
145
153
 
146
- # @classmethod
147
- # def create(cls, path: Path, *, is2d: bool) -> "Dataset":
148
- # empty_schema = DatasetSchema(
149
- # is2D=is2d,
150
- # )
154
+ def add_region_view(
155
+ self,
156
+ name: str,
157
+ map_of_sources: dict[str, list[str]],
158
+ *,
159
+ view_name: str = 'default',
160
+ ) -> None:
161
+ # create table with single column 'region_id' containing source_names, and save as .tsv inside "tables/<name>" inside dataset folder
162
+ table = 'region_id\t\n'
163
+ for source_name in map_of_sources:
164
+ table += f'{source_name}\t\n'
165
+ tables_folder = self.path / 'tables' / name
166
+ tables_folder.mkdir(parents=True, exist_ok=True)
167
+ table_path = tables_folder / 'default.tsv'
168
+ with open(table_path, 'w') as table_file:
169
+ table_file.write(table)
170
+ # add table source to dataset
171
+ self.model.sources[name] = Source(
172
+ {'regions': {'tableData': {'tsv': {'relativePath': f'tables/{name}'}}}}
173
+ )
174
+ self.model.views[view_name].sourceDisplays.append(
175
+ RegionDisplay(
176
+ regionDisplay=RegionDisplay1(
177
+ name=name,
178
+ sources=map_of_sources,
179
+ tableSource=name,
180
+ lut='glasbey',
181
+ opacity=0.5,
182
+ )
183
+ )
184
+ )
151
185
 
152
186
 
153
187
  class Project:
mobiedantic/generated.py CHANGED
@@ -5,7 +5,7 @@
5
5
  from __future__ import annotations
6
6
 
7
7
  from enum import Enum
8
- from typing import Dict, List, Optional, Union
8
+ from typing import Annotated, Dict, List, Optional, Union
9
9
 
10
10
  from pydantic import (
11
11
  BaseModel,
@@ -1280,6 +1280,6 @@ class Project(BaseModel):
1280
1280
  references: Optional[List[str]] = Field(
1281
1281
  None, description='Publication or other references for this project'
1282
1282
  )
1283
- specVersion: constr(pattern=r'0\.3\.\d+') = Field(
1283
+ specVersion: Annotated[str, constr(pattern=r'0\.3\.\d+')] = Field(
1284
1284
  ..., description='The MoBIE spec version of this project.'
1285
1285
  )
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: mobiedantic
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Project-URL: Documentation, https://github.com/fmi-faim/mobiedantic#readme
5
5
  Project-URL: Issues, https://github.com/fmi-faim/mobiedantic/issues
6
6
  Project-URL: Source, https://github.com/fmi-faim/mobiedantic
@@ -14,12 +14,11 @@ Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
17
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
18
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
19
20
  Requires-Python: >=3.8
20
21
  Requires-Dist: pydantic
21
- Provides-Extra: hatch
22
- Requires-Dist: hatch-conda<0.6,>=0.5.2; extra == 'hatch'
23
22
  Description-Content-Type: text/markdown
24
23
 
25
24
  # mobiedantic
@@ -0,0 +1,6 @@
1
+ mobiedantic/__init__.py,sha256=ok0K4e0IinDNNJyGTp2W5wYMwvkqOuUtOU1gncQNhsw,7910
2
+ mobiedantic/generated.py,sha256=kVdqOvkxJhUgff2dm0LiIVmRvRrmlFJgOfzF8Na7sEA,42215
3
+ mobiedantic-0.4.1.dist-info/METADATA,sha256=YCIKVPRUNMFrcEoPcbNazD8cOLsvCBTGnapjZr7ejZo,1502
4
+ mobiedantic-0.4.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ mobiedantic-0.4.1.dist-info/licenses/LICENSE.txt,sha256=Y-HLxetc9ng1nbl4Vpgg7MlEckBFenmRo16hXHxn7tw,1538
6
+ mobiedantic-0.4.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +0,0 @@
1
- mobiedantic/__init__.py,sha256=yAnWVfm-SzSK2PpJqgwOqWDMZYEaF0Hk-jN2tn-qA8A,6802
2
- mobiedantic/generated.py,sha256=-JO7uJvjE0hpYcXeJrOKiMCayoSWN72vTHh95-I-E5g,42188
3
- mobiedantic-0.3.0.dist-info/METADATA,sha256=Y0MWYGmWVhLWdwxqI4vjpTZmN6wSQmMjvxz9MDEUtOg,1530
4
- mobiedantic-0.3.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
5
- mobiedantic-0.3.0.dist-info/licenses/LICENSE.txt,sha256=Y-HLxetc9ng1nbl4Vpgg7MlEckBFenmRo16hXHxn7tw,1538
6
- mobiedantic-0.3.0.dist-info/RECORD,,