diff --git a/api/server/volumes/parcellationmap.py b/api/server/volumes/parcellationmap.py index d7ce085..2a7e05c 100644 --- a/api/server/volumes/parcellationmap.py +++ b/api/server/volumes/parcellationmap.py @@ -23,11 +23,11 @@ @router.get("", response_model=MapModel) @version(*FASTAPI_VERSION) @router_decorator(ROLE, func=get_map) -def get_siibra_map(parcellation_id: str, space_id: str, map_type: MapType, extra_spec: str= "", *, func): +def get_siibra_map(parcellation_id: str, space_id: str, map_type: MapType, name: str= "", *, func): """Get map according to specification""" if func is None: raise HTTPException(500, f"func: None passsed") - return func(parcellation_id, space_id, map_type, extra_spec) + return func(parcellation_id, space_id, map_type, name) @router.get("/resampled_template", response_class=FileResponse, tags=TAGS, description=""" Return a resampled template volume, based on labelled parcellation map. @@ -83,7 +83,7 @@ def get_parcellation_labelled_map(parcellation_id: str, space_id: str, region_id """) @version(*FASTAPI_VERSION) @router_decorator(ROLE, func=statistical_map_nii_gz) -def get_region_statistical_map(parcellation_id: str, region_id: str, space_id: str, extra_spec: str="", *, func): +def get_region_statistical_map(parcellation_id: str, region_id: str, space_id: str, name: str="", *, func): """Get statistical map according to specification""" if func is None: raise HTTPException(500, f"func: None passsed") @@ -92,8 +92,7 @@ def get_region_statistical_map(parcellation_id: str, region_id: str, space_id: s "content-type": "application/octet-stream", "content-disposition": f'attachment; filename="statistical_map.nii.gz"' } - - full_filename, cache_flag = func(parcellation_id=parcellation_id, region_id=region_id, space_id=space_id, extra_spec=extra_spec) + full_filename, cache_flag = func(parcellation_id=parcellation_id, region_id=region_id, space_id=space_id, name=name) if cache_flag: headers[cache_header] = "hit" assert os.path.isfile(full_filename), f"file saved incorrectly" @@ -106,12 +105,12 @@ class StatisticModelInfo(BaseModel): @router.get("/statistical_map.info.json", response_model=StatisticModelInfo, tags=TAGS) @version(*FASTAPI_VERSION) @router_decorator(ROLE, func=statistical_map_info_json) -def get_region_statistical_map_metadata(parcellation_id: str, region_id: str, space_id: str, extra_spec: str="", *, func): +def get_region_statistical_map_metadata(parcellation_id: str, region_id: str, space_id: str, name: str="", *, func): """Get metadata of statistical map according to specification""" if func is None: raise HTTPException(500, f"func: None passsed") - data = func(parcellation_id=parcellation_id, region_id=region_id, space_id=space_id, extra_spec=extra_spec) + data = func(parcellation_id=parcellation_id, region_id=region_id, space_id=space_id, name=name) return StatisticModelInfo(**data) @router.get("/assign", response_model=DataFrameModel, tags=TAGS) diff --git a/new_api/data_handlers/maps.py b/new_api/data_handlers/maps.py index 25599ea..75c6520 100644 --- a/new_api/data_handlers/maps.py +++ b/new_api/data_handlers/maps.py @@ -6,7 +6,7 @@ from new_api.common import get_filename -def cache_region_statistic_map(parcellation_id: str, region_id: str, space_id: str, extra_spec: str= "", *, no_cache=False) -> Tuple[str, bool, str]: +def cache_region_statistic_map(parcellation_id: str, region_id: str, space_id: str, name: str= "", *, no_cache=False) -> Tuple[str, bool, str]: """Retrieve and save regional statistical map (if necessary), and then return the path of the map. Args: @@ -31,7 +31,7 @@ def cache_region_statistic_map(parcellation_id: str, region_id: str, space_id: s error_text = f"Map with parc id '{parcellation_id}', space id '{space_id}'" - maps = siibra.find_maps(parcellation_id, space_id, "statistical", extra_spec) + maps = siibra.find_maps(parcellation_id, space_id, "statistical", name) assert len(maps) > 0, f"{error_text} returns None" if len(maps) > 1: diff --git a/new_api/v3/data_handlers/map/__init__.py b/new_api/v3/data_handlers/map/__init__.py index 8264769..d79a772 100644 --- a/new_api/v3/data_handlers/map/__init__.py +++ b/new_api/v3/data_handlers/map/__init__.py @@ -11,20 +11,20 @@ from new_api.warmup import register_warmup_fn @data_decorator(ROLE) -def assign(parcellation_id: str, space_id: str, point: str, assignment_type: str=Literal["statistical", "labelled"], sigma_mm: float=0., extra_specs: str=""): +def assign(parcellation_id: str, space_id: str, point: str, assignment_type: str=Literal["statistical", "labelled"], sigma_mm: float=0., name: str=""): import siibra from siibra.attributes.locations.point import parse_coordinate, Point coordinate = parse_coordinate(point) point = Point(coordinate=coordinate, space_id=space_id, sigma=sigma_mm) - maps = siibra.find_maps(parcellation_id, space_id, assignment_type, extra_specs) + maps = siibra.find_maps(parcellation_id, space_id, assignment_type, name) if len(maps) == 0: - raise NotFound(f"map with {parcellation_id=!r}, {space_id=!r}, {assignment_type=!r}, {extra_specs=!r} not found") + raise NotFound(f"map with {parcellation_id=!r}, {space_id=!r}, {assignment_type=!r}, {name=!r} not found") mp = maps[0] result = mp.lookup_points(point) return instance_to_model(result, detail=True).dict() @data_decorator(ROLE) -def get_map(parcellation_id: str, space_id: str, maptype: Union[MapType, str], extra_spec: str=""): +def get_map(parcellation_id: str, space_id: str, maptype: Union[MapType, str], name: str=""): """Get a map instance, based on specification Args: @@ -49,20 +49,20 @@ def get_map(parcellation_id: str, space_id: str, maptype: Union[MapType, str], e assert maptype is not None, f"maptype is neither MapType nor str" maptype = maptype.lower() - returned_maps = siibra.find_maps(parcellation_id, space_id, maptype=maptype, extra_spec=extra_spec) + returned_maps = siibra.find_maps(parcellation_id, space_id, maptype=maptype, name=name) if len(returned_maps) == 0: - raise NotFound(f"get_map with spec {parcellation_id=!r}, {space_id=!r}, {maptype=!r}, {extra_spec=!r} found no map.") + raise NotFound(f"get_map with spec {parcellation_id=!r}, {space_id=!r}, {maptype=!r}, {name=!r} found no map.") return instance_to_model(returned_maps[0], detail=True).dict() @data_decorator(ROLE) -def statistical_map_nii_gz(parcellation_id: str, region_id: str, space_id: str, extra_spec: str="", *, no_cache: bool=False): - filename, return_cached, warningtext = cache_region_statistic_map(parcellation_id, region_id, space_id, extra_spec, no_cache=no_cache) +def statistical_map_nii_gz(parcellation_id: str, region_id: str, space_id: str, name: str="", *, no_cache: bool=False): + filename, return_cached, warningtext = cache_region_statistic_map(parcellation_id, region_id, space_id, name, no_cache=no_cache) return filename, return_cached @data_decorator(ROLE) -def statistical_map_info_json(parcellation_id: str, region_id: str, space_id: str, extra_spec: str="", *, no_cache: bool=False): - filename, return_cached, warningtext = cache_region_statistic_map(parcellation_id, region_id, space_id, extra_spec, no_cache=no_cache) +def statistical_map_info_json(parcellation_id: str, region_id: str, space_id: str, name: str="", *, no_cache: bool=False): + filename, return_cached, warningtext = cache_region_statistic_map(parcellation_id, region_id, space_id, name, no_cache=no_cache) import nibabel as nib import numpy as np