refactor: methods to aid in segmentation and evaluation of results, in-house mescore#57
Merged
FlynnOConnell merged 100 commits intomasterfrom Jan 14, 2025
Merged
refactor: methods to aid in segmentation and evaluation of results, in-house mescore#57FlynnOConnell merged 100 commits intomasterfrom
FlynnOConnell merged 100 commits intomasterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds some functionality to aid in processing segmentation results for larger files.
vectorize,unvectorizearrays to efficiently convert to/from[n-pixels, Time]--summarycli flag to give quick metrics for number of accepted / rejected / total, searches a path recursively to gather all pickled results files and summarize each--summary_plotsboolean flag to generate a semi-performant picture of the spatial components--run_slurmpython cli, same functionality as this mbo utilities cnmf_grid_search.shmesmerize-core(requires new install stepsparams_from_metadata()very helpfulgnb= 3ops->paramsYou could theoretically run
--summary ~/data/will search through every directory inside that path, up to 3 subdirectories deep, and get every successful cnmf run to summarize.5 batch runs spread across multiple batch runs (uuid column omitted):
This is very fast because we don't need to move our currently
[n_pixels x time]formatted data into a format we can plot. (this is what the newly added vectorizer class/methods do).--summary_plotsnow needs to reshape every one of the neurons.This was measured at ~
200 components/second. Don't use this flag for a "quick" summary, it's more useful to be used after runs on the cluster.Nicely print params for all cnmf items recursively searched through the given directory:

Final summary.csv report:

HPC Grid Search

Each grid search outputs a single
batch.picklefile. This is transferred locally in a directory with$SLURM_JOB_ID:Summary of Accepted/Rejected Components
This is just a reshaped version of the spatial footprints for accepted/rejected neurons

Using max of spatial footprint
Taking the maximum value of each component before any reshaping has been the most computationally performant way to show users contours. We can use
idx_componentsto modify the colors.Displaying the maximum value is instant, locating the center coordinate can be parallelized. With a 32 core CPU this takes a minute per ~40,000 contours:
Calculating neuron center coordinates: 100%|██████████| 38100/38100 [00:50<00:00, 749.90it/s]