Translate core BML MATLAB toolbox modules to Python#3
Draft
Translate core BML MATLAB toolbox modules to Python#3
Conversation
Create pyproject.toml with numpy/pandas/scipy dependencies, bml/__init__.py importing submodules, and empty tests/__init__.py. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Translate five MATLAB functions to Python: - getopt (bml_getopt.m): config dict lookup with default/empty handling - map_values (bml_map.m): domain-to-codomain element mapping - getidx (bml_getidx.m): find first indices of elements in a collection - readjson (readjson.m): JSON file reader - getFs (bml_getFs.m): sampling frequency estimation from raw time arrays Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Translate four MATLAB functions from the stat/ directory to Python: - robust_std: row-wise robust standard deviation estimation - FDR: Benjamini & Hochberg (1995) false discovery rate - fdr_bh: full BH/BY FDR with adjusted p-values and FCR coverage - permutation_test: permutation test with exact option and Hedges' g Uses numpy and scipy.stats. Follows existing bml Python module style. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Translate MATLAB bml_time2idx.m and bml_idx2time.m to Python. - time2idx: convert times to sample indices using file coordinates - idx2time: convert sample indices to midpoint times (dict or DataFrame) - _matlab_round: MATLAB-compatible rounding (ties away from zero) - _round_significant: round to n significant digits - Inline overlap check for multi-row DataFrame in idx2time - Full numpy vectorization with pandas DataFrame support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: prlabu <10875699+prlabu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Translate BML MATLAB code to Python
Translate core BML MATLAB toolbox modules to Python
Mar 17, 2026
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.
Python translation of the foundational BML MATLAB toolbox modules (
utils,annot,sync,stat) that other modules depend on.Package structure
python/bml/package withpyproject.toml(numpy, pandas, scipy deps)Translated modules
utils.py—getopt,map_values,getidx,readjson,getFs(config parsing, mapping, sampling frequency estimation)annot.py— 12 functions for annotation table manipulation using pandas DataFrames:annot_table,annot_overlap,annot_intersect,annot_filter,annot_consolidate,annot_rename,annot_read/write,annot_read_tsv/write_tsv,annot_rowbind,annot_coveragesync.py—time2idx,idx2time(time↔sample index conversion with skip factor and split-sync DataFrame support)stat.py—robust_std,FDR,fdr_bh,permutation_test(robust statistics, Benjamini-Hochberg FDR, permutation testing with exact mode)Design decisions
df.attrs['description']idcolumn preserved (matches MATLAB convention and domain semantics)round(x, n, 'significant')→ custom_round_significant()helper_matlab_round()helperNot yet translated
signal/,io/,timefreq/,anat/,spksunit/,plot/,argus/— these build on the core modules translated here. Tests not yet added.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.