From 463c0009ea86297bb39d367c158f9810bc616153 Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Wed, 9 Jun 2021 11:12:12 +0200
Subject: [PATCH] bugfix: only show renderable parc

---
 src/util/pureConstant.service.ts | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/util/pureConstant.service.ts b/src/util/pureConstant.service.ts
index e49835760..f72a05d61 100644
--- a/src/util/pureConstant.service.ts
+++ b/src/util/pureConstant.service.ts
@@ -231,7 +231,24 @@ Raise/track issues at github repo: <a target = "_blank" href = "${this.repoUrl}"
       parcs$,
     ]).pipe(
       map(([ templateSpaces, parcellations ]) => {
-        return { templateSpaces, parcellations }
+        /**
+         * select only parcellations that contain renderable volume(s)
+         */
+        const filteredParcellations = parcellations.filter(p => {
+          for (const spaceKey in p.volumeSrc) {
+            for (const hemisphereKey in p.volumeSrc[spaceKey]) {
+              if (p.volumeSrc[spaceKey][hemisphereKey].some(vol => vol.volume_type === 'neuroglancer/precomputed')) return true
+              if (p.volumeSrc[spaceKey][hemisphereKey].some(vol => vol.volume_type === 'neuroglancer/precompmesh')) return true
+              if (p.volumeSrc[spaceKey][hemisphereKey].some(vol => vol.volume_type === 'threesurfer/gii')) return true
+              if (p.volumeSrc[spaceKey][hemisphereKey].some(vol => vol.volume_type === 'threesurfer/gii-label')) return true
+            }
+          }
+          return false
+        })
+        return {
+          templateSpaces,
+          parcellations: filteredParcellations
+        }
       }),
       shareReplay(1)
     )
-- 
GitLab