Correct the pc_features axis order and indexing example - #1408
Merged
Conversation
The dataset reference gave the in-memory shape for the file on disk, and the sorting user guide indexed pc_feature_ind as a one-dimensional array and described a zero-based PC index as the first PC. phylib reads pc_features.npy and transposes its last two axes, so the file holds (n_spikes, n_pcs, n_channels_loc) and pc_feature_ind is indexed by the spike's template. Correct both pages and note the transpose. Fixes cortex-lab#1364
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.
The
pc_features.npydescription is wrong in two different ways on two different pages, which is what prompted the question in the issue about whetherpc_features[123, 1, 5]should bepc_features[123, 0, 5].In
docs/dataset.md, the file table lists the shape as(n_spikes_subset, n_channels_loc, n_pcs). That is the shape phy holds in memory, not the shape on disk.phylib.io.model.TemplateModel._load_featuresreads the array and then appliesdata.transpose((0, 2, 1)), so the file itself stores(n_spikes_subset, n_pcs, n_channels_loc). The neighboring rows of that same table do describe the on-disk layout, so the entry was inconsistent with its own table.In
docs/sorting_user_guide.md, the declared shape[nSpikes, nFeaturesPerChannel, nPCFeatures]is correct, but the worked example is not. It calls axis index 1 the first PC when array indices are zero-based, and it indexespc_feature_indaspc_feature_ind[5]when that array is two-dimensional,[nTemplates, nPCFeatures], and has to be indexed by the spike's own template first. The sentence also referred to a file namedpc_features_ind.npy, which does not exist.I verified the layout by driving phylib's loader directly with a synthetic on-disk array of shape
(7, 3, 4). It comes back as(7, 4, 3),pc_feature_indis asserted to be(n_templates, n_channels_loc), anddisk[2, 1, 3]equalsmemory[2, 3, 1], confirming the transpose and confirming which axis the channel index belongs to. The change corrects the shape in the dataset reference, corrects the worked example and the filename in the user guide, and notes the transpose on both pages so readers moving between the file andmodel.get_features()are not caught out.make doc-checkpasses, including the strict mkdocs build.Fixes #1364