From 546d4d38834c9c0b30f97f90491d2a1594650d7d Mon Sep 17 00:00:00 2001 From: Xiao Gui Date: Tue, 20 Aug 2024 19:03:30 +0200 Subject: [PATCH] fix ambiguous statistical map --- .github/workflows/calc_upload_sparseindex.yaml | 8 +++++++- .github/workflows/check-trigger-sparseindex.yaml | 1 + _ci/check_sparse_index.py | 8 +++++++- _ci/create_sparse_index.py | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/calc_upload_sparseindex.yaml b/.github/workflows/calc_upload_sparseindex.yaml index cd4db9ed..9f4547f2 100644 --- a/.github/workflows/calc_upload_sparseindex.yaml +++ b/.github/workflows/calc_upload_sparseindex.yaml @@ -11,6 +11,10 @@ on: type: string description: "" required: true + mapname: + type: string + description: "" + required: true secrets: client-id: required: true @@ -35,7 +39,9 @@ jobs: python _ci/create_sparse_index.py \ ${{ inputs.parcellation_id }} \ ${{ inputs.space_id }} \ - ${{ inputs.filename }} + ${{ inputs.filename }} \ + statistical \ + ${{ inputs.mapname }} - uses: actions/upload-artifact@v4 with: name: ${{ inputs.filename }} diff --git a/.github/workflows/check-trigger-sparseindex.yaml b/.github/workflows/check-trigger-sparseindex.yaml index 2c03b4c4..a68deee6 100644 --- a/.github/workflows/check-trigger-sparseindex.yaml +++ b/.github/workflows/check-trigger-sparseindex.yaml @@ -23,6 +23,7 @@ jobs: parcellation_id: ${{ matrix.parcellation_id }} space_id: ${{ matrix.space_id }} filename: ${{ matrix.filename }} + mapname: ${{ matrix.mapname }} secrets: client-id: ${{ secrets.EBRAINS_OIDC_SIIBRA_CI_CLIENT_ID }} client-secret: ${{ secrets.EBRAINS_OIDC_SIIBRA_CI_CLIENT_SECRET }} diff --git a/_ci/check_sparse_index.py b/_ci/check_sparse_index.py index 866b6a9c..937a571a 100644 --- a/_ci/check_sparse_index.py +++ b/_ci/check_sparse_index.py @@ -14,6 +14,11 @@ def main(): map_obj = json.loads(f.read_text()) parcellation_id = map_obj.get("parcellation_id") space_id = map_obj.get("space_id") + name_attrs = [attr + for attr in map_obj.get("attributes", []) + if attr.get("@type") == "siibra/attr/desc/name/v0.1"] + assert len(name_attrs) == 1, f"{str(f)} has more than 1 name attr" + name = name_attrs[0]["value"] for attr in map_obj.get("attributes", []): if attr.get("format") == "sparseindex": url = attr.get("url") @@ -25,7 +30,8 @@ def main(): include.append({ "parcellation_id": parcellation_id, "space_id": space_id, - "filename": filename.name + "filename": filename.name, + "mapname": name, }) print(json.dumps(print_result)) return diff --git a/_ci/create_sparse_index.py b/_ci/create_sparse_index.py index ffcc30f1..d1d0cfda 100644 --- a/_ci/create_sparse_index.py +++ b/_ci/create_sparse_index.py @@ -3,8 +3,8 @@ from siibra.atlases.sparsemap import SparseIndex from tqdm import tqdm -def create_sparse_index(parc_id: str, space_id: str, filename: str, maptype: str="statistical"): - mp = siibra.get_map(parc_id, space_id, maptype) +def create_sparse_index(parc_id: str, space_id: str, filename: str, maptype: str="statistical", extra_spec: str=""): + mp = siibra.get_map(parc_id, space_id, maptype, extra_spec) spi = SparseIndex(filename, mode="w")