Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] spatial props for bundle atlas not calculated correctly #157

Open
xgui3783 opened this issue Feb 14, 2022 · 2 comments
Open

[bug] spatial props for bundle atlas not calculated correctly #157

xgui3783 opened this issue Feb 14, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@xgui3783
Copy link
Member

as of v0.3a11

the spatial props calculated for regions such as lh_PoCi-PrCu_1 can be misleading, due to the concaved geometry of the probabilistic map:
image002

@xgui3783 xgui3783 added the bug Something isn't working label Feb 14, 2022
@dickscheid
Copy link
Contributor

This is not suprising, since we just compute the mean. The mean is certainly not a very good choice for fibrre bundles - we might choose the closest point to the mean which is inside the structure.

@AhmetNSimsek
Copy link
Collaborator

Alternative suggestion: "Find the pixel with the highest closeness centrality. Closeness centrality is the inverse of the total sum of shortest distances from a node to every other node." (see https://scikit-image.org/docs/stable/auto_examples/applications/plot_pixel_graphs.html)

from time import time
import skimage as ski
import siibra
from nibabel import Nifti1Image
import numpy as np

def calculate_graph_center(img: Nifti1Image):
    mask_arr = np.asanyarray(img.dataobj > 0, dtype='uint8')
    skeleton = ski.morphology.skeletonize(mask_arr )
    g, nodes = ski.graph.pixel_graph(skeleton, connectivity=2)
    px, distances = ski.graph.central_pixel(g, nodes=nodes, shape=skeleton.shape, partition_size=100)
    return np.dot(img.affine, np.concatenate((px, [1])))[:3]

img = siibra.get_region("Superficial fibre bundles", "lh_PoCi-PrCu_1").get_regional_mask("mni 152").fetch()
s = time()
center = calculate_graph_center(img)
print(time() - s)
print(center)

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants