Skip to content

Commit 344c78a

Browse files
authored
Merge pull request #52 from FZJ-INM1-BDA/hotfix_spatialPropOriginDs
hotfix: regional spatial prop
2 parents 55b251c + fc7ec2b commit 344c78a

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

app/service/request_utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def _create_region_json_object(region, space_id=None, atlas=None, detail=False):
5858
region_json['availableIn'] = get_available_spaces_for_region(region)
5959

6060
if detail:
61+
region_json['_dataset_specs'] = [{
62+
'name': ds.name,
63+
'description': ds.description,
64+
'urls': ds.urls
65+
} for ds in region.datasets if type(ds) == siibra.features.ebrains.EbrainsDataset]
6166
region_json['hasRegionalMap'] = region.has_regional_map(
6267
siibra.spaces[space_id],
6368
siibra.commons.MapType.CONTINUOUS) if space_id is not None else None
@@ -138,7 +143,13 @@ def get_region_props(space_id, atlas, region) -> list:
138143
space = atlas.get_space(space_id)
139144
try:
140145
logger.info(f'Getting region props for: {region}')
141-
result_props = region.spatialprops(space, force=True)
146+
result_props = region.spatial_props(space)
147+
result_props = {
148+
'components': [{
149+
'centroid': list(c['centroid']),
150+
'volume': c['volume']
151+
}for c in result_props['components']]
152+
}
142153
except:
143154
logger.info(f'Could not get region properties for region: {region} and space: {space}')
144155
result_props = []

test/core/test_parcellation_api.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,31 @@ def test_get_one_region_for_parcellation_without_extra_data(self):
8181

8282

8383
def test_get_one_region_for_parcellation_with_extra_data(self):
84-
response = client.get('/v1_0/atlases/{}/parcellations/{}/regions/{}?space_id={}'.format(ATLAS_ID.replace('/', '%2F'), PARCELLATION_ID, REGION_BASAL, SPACE_ID))
84+
response = client.get('/v1_0/atlases/{}/parcellations/{}/regions/{}?space_id={}'.format(
85+
ATLAS_ID.replace('/', '%2F'),
86+
PARCELLATION_ID,
87+
HOC1_LEFT_REGION_NAME,
88+
SPACE_ID))
8589
result_content = json.loads(response.content)
8690
assert response.status_code == 200
8791

88-
assert result_content['name'] == REGION_BASAL
92+
assert result_content['name'] == HOC1_LEFT_REGION_NAME
93+
94+
# spatial props
95+
props_components = result_content.get('props', {}).get('components', [])
96+
assert type(props_components) == list
97+
assert len(props_components) > 0
98+
99+
assert type(props_components[0].get('centroid')) == list
100+
assert len(props_components[0].get('centroid')) == 3
101+
assert all([type(v) == float for v in props_components[0].get('centroid')])
102+
assert type(props_components[0].get('volume')) == float
103+
104+
# _dataset_specs
105+
_dataset_specs = result_content.get('_dataset_specs')
106+
assert _dataset_specs is not None
107+
assert type(_dataset_specs) == list
108+
assert len(_dataset_specs) > 0
89109
# Add Assertion for extra data
90110

91111

0 commit comments

Comments
 (0)