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

Speed-up BA exvivo labels projection with python #183

Merged
merged 12 commits into from
Sep 1, 2022
Merged

Speed-up BA exvivo labels projection with python #183

merged 12 commits into from
Sep 1, 2022

Conversation

m-reuter
Copy link
Member

@m-reuter m-reuter commented Sep 1, 2022

Replace recon-all -balabels with our own python code (except for the mris_anatomical_stats)

In FreeSurfer BA exvivo (and other labels) are mapped from fsaverage to the current subject within the recon-all -balabels call. This is very slow as each label is mapped independently, requiring a nearest neighbour search. This PR adds python code (needing scikit-learn nearest neighbor search, KDTree) to compute correspondence one time per hemisphere and then map all labels as a batch and directly combine sets of labels into the corresponding annotation, which is far more efficient.

mris_anatomical_stats is not yet ported. It is still called from FreeSurfer to generate stats files for BA_exvivo labels and is the slowest part in the new pipeline (maybe it makes sense to port this in the future).

The whole thing for both hemispheres takes now 33 seconds only! Compared to recon-all -balabels taking 7-8 mins on my machine.

Note, while the label mapping is almost identical to FreeSurfer (at least visually), the merging for the annotation shows some small difference when resolving overlapping labels. Here - when label values agree - we select the label listed later to be the winner. When label values disagree, the one with the larger value wins. This is what FreeSurfer should be doing, but looks like it is not. Stats file, therefore, differ slightly. It is probably caused by noise in small decimal digits in the label values in FreeSurfer.

@m-reuter m-reuter merged commit e21f5d1 into Deep-MI:dev Sep 1, 2022
@m-reuter m-reuter deleted the feature/ba-labels branch September 1, 2022 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant