Repository navigation
Drop the Statistics and Machine Learning Toolbox from module code - #4
Open
ehennestad wants to merge 2 commits into
Open
ehennestad wants to merge 2 commits into
ehennestad wants to merge 2 commits into
Conversation
…e code FluFinder's binarisation used the deprecated nanmedian/nanmax/nanmin, component picking used linkage/cluster, the pixel correlation image used corr and the ROI dF/F statistics used skewness, all from the Statistics and Machine Learning Toolbox although the manifest lists it as optional. Each is replaced by base MATLAB: - nanmedian(x) -> median(x, 'omitnan'); nanmin/nanmax -> min/max, which ignore NaN as well. - linkage/cluster -> flufinder.utility.findLargestCentroidCluster, a single-linkage grouping within the same 3-pixel cutoff that keeps the largest group; the warning toggles for the linkage tree go with it. - corr -> the centred dot product for the correlation and the regularised incomplete beta function for the right-tailed p-value. - skewness(x, 1, 1) -> the biased third-moment definition. The manifest entry stays optional because the EXTRACT integration still needs the toolbox. prctile, which the review took for a toolbox function, is base MATLAB. Tests: PixelCorrelationImageTest and RoiStatsTest compare the replacements with the toolbox functions when those are installed; FluFinderDetectionTest covers the centroid-cluster fallback and the new helper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Contributor
…toolbox need dffprops documented dffprops(dff, name1, ...) but parsed the names as name-value pairs, so a lone name was ignored and every field was computed, including the noise level that needs pwelch. Both call forms now select fields, and requesting a noise-based field without the Signal Processing Toolbox raises a clear error instead of an undefined function. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Batch R3 from the module review, stacked on #3: the module's own code no longer needs the Statistics and Machine Learning Toolbox, which the manifest has always listed as optional.
What the review got wrong
The review assumed
prctileneeds the toolbox. In R2024bwhich prctileresolves undertoolbox/matlab, so the dF/F baselines were never the problem. A whole-module scan that resolves every called function to its toolbox found exactly four Statistics Toolbox uses in module code, all replaced here.Replacements
nanmedian/nanmax/nanmin(deprecated, 16 sites in FluFinder's binarisation and pixel measurements) becomemedian(x, 'omitnan'),maxandmin, which ignore NaN the same way.linkage/clusterin the two component pickers becomeflufinder.utility.findLargestCentroidCluster: single-linkage grouping of centroids within the same 3-pixel cutoff, keeping the largest group, with ties resolved to the group holding the lowest-numbered point. The old code agglomerated by centroid distance with that cutoff, so results can differ only for chains of centroids that span more than the cutoff end to end. Thestats:linkagewarning toggles go with it.corringetPixelCorrelationImagebecomes the centred dot product for the correlation and the regularised incomplete beta function for the right-tailed p-value; an undefined correlation (constant pixel) yields NaN ascorrdid. Callers only use the correlation image.skewness(x, 1, 1)indffpropsbecomes its biased third-moment definition.Tests
PixelCorrelationImageTestandRoiStatsTestcheck the replacements against a synthetic stack and, when the toolbox is installed, againstcorrandskewnessthemselves (agreement within 1e-5 and 1e-12).FluFinderDetectionTestgains a case where two overlapping cells force the centroid-cluster fallback and four unit tests for the helper. The manifest is unchanged: the toolbox stays optional for the EXTRACT integration.Noted for later
Signal Processing is the next toolbox the manifest under-declares:
dffpropscallspwelchandsnrunguarded, so every ROI statistics computation needs it, while the manifest describes it as used by "some motion correction and signal extraction workflows".🤖 Generated with Claude Code