You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi neuromaps team,
I am currently working with BrainSMASH to create null maps for both surface and volumetric data and had a look into your code. I realized that your solution for generating distance matrices for volumetric parcellations is unnecessary slow. I came up with a much faster solution and wanted to share it with you. I hope, you don't mind that I did not implement it directly in neuromaps and put up a pull request. I also changed some variable names in the code snippets for my own convenience.
Iterates parcels and calculates the mean pairwise distance between all voxels in each parcel, only for the upper right triangle of the matrix, then mirrors the triangle to the lower left of the matrix (~ 14 seconds):
(< .5 sec) calculate distances between centroid coordinates of each parcel. That should actually not make much difference regarding spatial properties of the distance matrix, allthough I didn't test that. Obviously, we'll now have a zero diagonal.
Sorry for the super late reply. Just want to say that this is awesome and thanks so much for sharing your improvement. We will work on getting it implemented! Please leave the issue open so I don't forget 😉
Description of issue
Hi neuromaps team,
I am currently working with BrainSMASH to create null maps for both surface and volumetric data and had a look into your code. I realized that your solution for generating distance matrices for volumetric parcellations is unnecessary slow. I came up with a much faster solution and wanted to share it with you. I hope, you don't mind that I did not implement it directly in neuromaps and put up a pull request. I also changed some variable names in the code snippets for my own convenience.
Data preparation:
Your solution
(13 - 14 minutes with a 116parcels-2mm-resolution-parcellation on my M1 Pro Mac):
Output:
My solution
Iterates parcels and calculates the mean pairwise distance between all voxels in each parcel, only for the upper right triangle of the matrix, then mirrors the triangle to the lower left of the matrix (~ 14 seconds):
Output ( (completely equal to your code):
Much faster alternative
(< .5 sec) calculate distances between centroid coordinates of each parcel. That should actually not make much difference regarding spatial properties of the distance matrix, allthough I didn't test that. Obviously, we'll now have a zero diagonal.
Output:
Feel free to incorporate the code snippet if you like! :)
Best,
Leon
Code of Conduct
neuromaps
Code of ConductThe text was updated successfully, but these errors were encountered: