-
Notifications
You must be signed in to change notification settings - Fork 22
docs: add NumPy-style docstrings for ReadTheDocs #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
55a7561
e76a773
9851e7c
63bd81d
4ecd8fc
e2d9715
5dd156d
cdc4cab
38f68b8
8c7c3c1
da06202
028147e
edf157b
852f600
ccc361b
92fbd14
41f5d6c
5a278fd
45e19ef
4a24327
acbcb20
3654d80
d44017d
0491519
79bed6c
9019d34
d34fbee
97d194b
26aa980
8d093e7
6dd5782
0c2576e
2ef1499
9c86b1e
313bd9b
3a00795
427654c
25b60fe
3975057
138f058
d1eaffa
0be8971
326b050
ee749f8
8242d84
b4a6058
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,3 +163,5 @@ cython_debug/ | |
|
|
||
| *.sif | ||
| *.bak | ||
|
|
||
| docs/source/generated/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,98 @@ | ||
| # Experanto | ||
|
|
||
| Experanto is a Python package designed for interpolating recordings and stimuli in neuroscience experiments. It enables users to load single or multiple experiments and create efficient dataloaders for machine learning applications. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Unified Experiment Interface**: Load and query multi-modal neuroscience data (neural responses, eye tracking, treadmill, visual stimuli) through a single `Experiment` class | ||
| - **Flexible Interpolation**: Interpolate data at arbitrary time points with support for linear and nearest-neighbor methods | ||
| - **Multi-Session Support**: Combine data from multiple recording sessions into a single dataloader | ||
| - **Configurable Preprocessing**: YAML-based configuration for sampling rates, normalization, transforms, and filtering | ||
| - **PyTorch Integration**: Native PyTorch `Dataset` and `DataLoader` implementations optimized for training | ||
|
|
||
| ## Docs | ||
| [](https://experanto.readthedocs.io/) | ||
|
|
||
| ## Installation | ||
| To install Experanto, clone locally and run: | ||
|
|
||
| ```bash | ||
| pip install -e /path_to/experanto | ||
| git clone https://github.com/sensorium-competition/experanto.git | ||
| cd experanto | ||
| pip install -e . | ||
| ``` | ||
|
|
||
| To replicate the `generate_sample` example, install: | ||
| ### Note | ||
|
|
||
| To replicate the `generate_sample` example, use the following command (see [allen_exporter](https://github.com/sensorium-competition/allen-exporter)): | ||
|
|
||
| ```bash | ||
| pip install -e /path_to/allen_exporter | ||
| pip install -e /path/to/allen_exporter | ||
| ``` | ||
| (Repository: [allen_exporter](https://github.com/sensorium-competition/allen-exporter)) | ||
|
|
||
| To replicate the `sensorium_example`, also install the following with their dependencies: | ||
| To replicate the `sensorium_example` (see [sensorium_2023](https://github.com/ecker-lab/sensorium_2023)), install neuralpredictors (see [neuralpredictors](https://github.com/sinzlab/neuralpredictors)) as well: | ||
|
|
||
| ```bash | ||
| pip install -e /path_to/neuralpredictors | ||
| pip install -e /path/to/neuralpredictors | ||
| pip install -e /path/to/sensorium_2023 | ||
| ``` | ||
| (Repository: [neuralpredictors](https://github.com/sinzlab/neuralpredictors)) | ||
|
|
||
| ```bash | ||
| pip install -e /path_to/sensorium_2023 | ||
| ## Quick Start | ||
|
|
||
| ### Loading an Experiment | ||
|
|
||
| ```python | ||
| from experanto.experiment import Experiment | ||
|
|
||
| # Load a single experiment | ||
| exp = Experiment("/path/to/experiment") | ||
|
|
||
| # Query data at specific time points | ||
| import numpy as np | ||
| times = np.linspace(0, 10, 100) # 100 time points over 10 seconds | ||
|
|
||
| # Get interpolated data and a boolean mask with valid time points from all devices | ||
| data, valid = exp.interpolate(times) | ||
|
|
||
| # Or from a specific device | ||
| responses, valid = exp.interpolate(times, device="responses") | ||
| ``` | ||
|
|
||
| ### Configuration | ||
|
|
||
| Experanto uses YAML configuration files. See `configs/default.yaml` for all options: | ||
|
|
||
| ```yaml | ||
| dataset: | ||
| modality_config: | ||
| responses: | ||
| sampling_rate: 8 | ||
| chunk_size: 16 | ||
| transforms: | ||
| normalization: "standardize" | ||
| screen: | ||
| sampling_rate: 30 | ||
| chunk_size: 60 | ||
| transforms: | ||
| normalization: "normalize" | ||
|
|
||
| dataloader: | ||
| batch_size: 16 | ||
| num_workers: 2 | ||
| ``` | ||
| (Repository: [sensorium_2023](https://github.com/ecker-lab/sensorium_2023)) | ||
| Ensure you replace `/path_to/` with the actual path to the cloned repositories. | ||
| ## Documentation | ||
| Full documentation is available at [Read the Docs](https://experanto.readthedocs.io/). | ||
| - [Installation Guide](https://experanto.readthedocs.io/en/latest/concepts/installation.html) | ||
| - [Getting Started](https://experanto.readthedocs.io/en/latest/concepts/getting_started.html) | ||
| - [API Reference](https://experanto.readthedocs.io/en/latest/api.html) | ||
| - [Configuration Options](https://experanto.readthedocs.io/en/latest/configuration.html) | ||
| ## Contributing | ||
| Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/sensorium-competition/experanto). | ||
| ## License | ||
| This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| {{ fullname | escape | underline}} | ||
|
|
||
| .. currentmodule:: {{ module }} | ||
|
|
||
| .. autoclass:: {{ objname }} | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: | ||
| :inherited-members: | ||
|
|
||
| {% block methods %} | ||
| {% if methods %} | ||
| .. rubric:: Methods | ||
|
|
||
| .. autosummary:: | ||
| {% for item in methods %} | ||
| ~{{ name }}.{{ item }} | ||
| {%- endfor %} | ||
| {% endif %} | ||
| {% endblock %} | ||
|
|
||
| {% block attributes %} | ||
| {% if attributes %} | ||
| .. rubric:: Attributes | ||
|
|
||
| .. autosummary:: | ||
| {% for item in attributes %} | ||
| ~{{ name }}.{{ item }} | ||
| {%- endfor %} | ||
| {% endif %} | ||
| {% endblock %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| Classes and functions | ||
| ===================== | ||
|
|
||
| This section documents all public classes and functions in Experanto. | ||
|
|
||
| Core Classes | ||
| ------------ | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :template: custom-class-template.rst | ||
| :nosignatures: | ||
|
|
||
| experanto.experiment.Experiment | ||
| experanto.datasets.ChunkDataset | ||
|
|
||
| Interpolators | ||
| ------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :template: custom-class-template.rst | ||
| :nosignatures: | ||
|
|
||
| experanto.interpolators.Interpolator | ||
| experanto.interpolators.SequenceInterpolator | ||
| experanto.interpolators.PhaseShiftedSequenceInterpolator | ||
| experanto.interpolators.ScreenInterpolator | ||
| experanto.interpolators.TimeIntervalInterpolator | ||
| experanto.interpolators.ScreenTrial | ||
| experanto.interpolators.ImageTrial | ||
| experanto.interpolators.VideoTrial | ||
| experanto.interpolators.BlankTrial | ||
| experanto.interpolators.InvalidTrial | ||
|
|
||
| Time Intervals | ||
| -------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :template: custom-class-template.rst | ||
| :nosignatures: | ||
|
|
||
| experanto.intervals.TimeInterval | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :nosignatures: | ||
|
|
||
| experanto.intervals.uniquefy_interval_array | ||
| experanto.intervals.find_intersection_between_two_interval_arrays | ||
| experanto.intervals.find_intersection_across_arrays_of_intervals | ||
| experanto.intervals.find_union_across_arrays_of_intervals | ||
| experanto.intervals.find_complement_of_interval_array | ||
| experanto.intervals.get_stats_for_valid_interval | ||
|
|
||
| Dataloaders | ||
| ----------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :nosignatures: | ||
|
|
||
| experanto.dataloaders.get_multisession_dataloader | ||
| experanto.dataloaders.get_multisession_concat_dataloader | ||
|
|
||
| Utilities | ||
| --------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :template: custom-class-template.rst | ||
| :nosignatures: | ||
|
|
||
| experanto.utils.LongCycler | ||
| experanto.utils.ShortCycler | ||
| experanto.utils.FastSessionDataLoader | ||
| experanto.utils.MultiEpochsDataLoader | ||
| experanto.utils.SessionConcatDataset | ||
| experanto.utils.SessionBatchSampler | ||
| experanto.utils.SessionSpecificSampler | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :nosignatures: | ||
|
|
||
| experanto.utils.add_behavior_as_channels | ||
|
|
||
| Filters | ||
| ------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: generated | ||
| :nosignatures: | ||
|
|
||
| experanto.filters.common_filters.nan_filter | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,3 +114,67 @@ You can change parameters programmatically: | |
| cfg.dataset.modality_config.screen.include_blanks = True | ||
| cfg.dataset.modality_config.screen.valid_condition = {"tier": "train"} | ||
| cfg.dataloader.num_workers = 8 | ||
|
|
||
|
|
||
| Configuration options | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Dataset options | ||
| """"""""""""""" | ||
|
|
||
| ``global_sampling_rate`` | ||
| Override sampling rate for all modalities. Set to ``null`` to use per-modality rates. | ||
|
Comment on lines
+125
to
+126
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why null and not None in these examples? |
||
|
|
||
| ``global_chunk_size`` | ||
| Override chunk size for all modalities. Set to ``null`` to use per-modality sizes. | ||
|
|
||
| ``add_behavior_as_channels`` | ||
| If ``True``, concatenate behavioral data (e.g., eye tracker, treadmill) as | ||
| additional channels to the screen data. | ||
|
|
||
| ``replace_nans_with_means`` | ||
| If ``True``, replace NaN values with the mean of non-NaN values. | ||
|
|
||
| ``cache_data`` | ||
| If ``True``, cache interpolated data in memory for faster access. | ||
|
|
||
| ``out_keys`` | ||
| List of modality keys to include in the output dictionary. | ||
|
|
||
| ``normalize_timestamps`` | ||
| If ``True``, normalize timestamps to start from 0. | ||
|
|
||
| Modality options | ||
| """""""""""""""" | ||
|
|
||
| Each modality (e.g., screen, responses, eye_tracker, treadmill) supports: | ||
|
|
||
| ``keep_nans`` | ||
| Whether to keep NaN values in the output. | ||
|
|
||
| ``sampling_rate`` | ||
| Sampling rate in Hz for this modality. | ||
|
|
||
| ``chunk_size`` | ||
| Number of samples per chunk. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure myself, but maybe "data points" or "time steps" is better than "samples" here. |
||
|
|
||
| ``offset`` | ||
| Time offset in seconds relative to the screen timestamps. | ||
|
|
||
| ``transforms`` | ||
| Dictionary of transforms to apply. Supports ``"normalize"`` (0-1 scaling) | ||
| and ``"standardize"`` (z-score normalization). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually supports also custom transforms, defined as dicts containing key |
||
|
|
||
| ``interpolation`` | ||
| Interpolation settings including ``interpolation_mode`` (``"linear"`` or | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe mention that this is only for Sequence interpolators |
||
| ``"nearest_neighbor"``). | ||
|
|
||
| ``filters`` | ||
| Dictionary of filter functions to apply to the data. | ||
|
|
||
| Dataloader options | ||
| """""""""""""""""" | ||
|
|
||
| All standard ``torch.utils.data.DataLoader`` options are supported. See the | ||
| `PyTorch DataLoader documentation <https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader>`_ | ||
| for the full list of available parameters. | ||
Uh oh!
There was an error while loading. Please reload this page.