Skip to content

Add MATLAB API compatibility aliases for file, session, and dataset modules#17

Merged
stevevanhooser merged 3 commits into
mainfrom
claude/fix-dataset-download-path-YlOQu
Mar 11, 2026
Merged

Add MATLAB API compatibility aliases for file, session, and dataset modules#17
stevevanhooser merged 3 commits into
mainfrom
claude/fix-dataset-download-path-YlOQu

Conversation

@stevevanhooser

Copy link
Copy Markdown
Contributor

Summary

This PR adds MATLAB-compatible function and class aliases to improve API consistency between the Python and MATLAB implementations of NDI. Users can now call Python functions using the same naming conventions as MATLAB (e.g., ndi.file.navigator() instead of ndi.file.FileNavigator()).

Key Changes

  • File module (ndi.file): Added aliases for MATLAB-style constructors:

    • navigatorFileNavigator
    • navigator_epochdirEpochDirNavigator
    • pfilemirror → pfilemirror function
  • File type module (ndi.file.type): Added alias:

    • mfdaq_epoch_channelMFDAQEpochChannel
  • Session module (ndi.session): Added alias:

    • dirDirSession
  • Dataset module (ndi.dataset):

    • Created new __init__.py with MATLAB-compatible API
    • Added dir alias → Dataset
    • Fixed import paths in _dataset.py (changed relative imports from . to ..)
  • Documentation: Updated MATLAB_MAPPING.md to reflect the new aliases and clarify that both MATLAB-style and Python-style names are supported

  • Cloud orchestration: Fixed downloadDataset() to create target directory as target_folder / cloud_dataset_id, matching MATLAB behavior

Implementation Details

All aliases are implemented as simple assignments (e.g., navigator = FileNavigator) rather than wrapper functions, ensuring zero overhead and maintaining full compatibility with the underlying classes. The aliases are properly exported in __all__ lists for discoverability.

https://claude.ai/code/session_01SPLxWdyCaZ5VH8EUMneuJ3

claude added 3 commits March 11, 2026 19:46
…ndi.session.dir

Three changes to match MATLAB behavior:

1. ndi.cloud.downloadDataset now creates target/{cloudDatasetId} subdirectory,
   matching the MATLAB implementation where the actual download path includes
   the cloud dataset ID.

2. Convert ndi/dataset.py to a package (ndi/dataset/) and expose
   ndi.dataset.dir as an alias for Dataset, so ndi.dataset.dir(path) works
   as a constructor just like in MATLAB.

3. Add ndi.session.dir = DirSession so ndi.session.dir(ref, path) works
   as a constructor matching MATLAB's ndi.session.dir.

https://claude.ai/code/session_01SPLxWdyCaZ5VH8EUMneuJ3
Apply the same porting guide pattern used for ndi.dataset.dir and
ndi.session.dir to the ndi.file namespace:

- ndi.file.navigator(...) -> FileNavigator constructor
- ndi.file.navigator_epochdir(...) -> EpochDirNavigator constructor
- ndi.file.pfilemirror(...) -> pfilemirror function
- ndi.file.type.mfdaq_epoch_channel(...) -> MFDAQEpochChannel constructor

All existing import paths (from ndi.file.navigator import FileNavigator,
etc.) continue to work unchanged.

ndi.common has no MATLAB equivalent namespace so no changes needed.

Updated MATLAB_MAPPING.md to document the new callable aliases.

https://claude.ai/code/session_01SPLxWdyCaZ5VH8EUMneuJ3
…atabaseHierarchy, assertDIDInstalled

Port the full ndi.common MATLAB namespace to Python:

- getLogger(name) - renamed from get_logger to match MATLAB; old name
  kept for backwards compatibility
- getCache() - returns singleton ndi.Cache instance, matching MATLAB's
  persistent cache pattern
- getDatabaseHierarchy() - reads document definitions from ndi_common
  and returns cached type hierarchy dict
- assertDIDInstalled() - raises ImportError if the did package is missing

Also export ndi.common as a submodule from ndi/__init__.py so
ndi.common.X is accessible after `import ndi`.

Updated MATLAB_MAPPING.md with the new ndi.common section.

https://claude.ai/code/session_01SPLxWdyCaZ5VH8EUMneuJ3
@stevevanhooser stevevanhooser merged commit 106d141 into main Mar 11, 2026
4 checks passed
@stevevanhooser stevevanhooser deleted the claude/fix-dataset-download-path-YlOQu branch March 11, 2026 20:41
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.

2 participants