|
5 | 5 |
|
6 | 6 | This repository contains tools for computing electrophysiology features and performing region inference from neural recordings.
|
7 | 7 |
|
8 |
| -## Installation |
| 8 | +## Documentation |
9 | 9 |
|
10 |
| -> **Note**: It is recommended to create and use a separate virtual environment before installation. |
| 10 | +For detailed documentation, installation instructions, usage examples, and API reference, please visit our comprehensive documentation: |
| 11 | + |
| 12 | +**[📚 View Full Documentation](docs/source/index.rst)** |
| 13 | + |
| 14 | +## Quick Installation |
11 | 15 |
|
12 |
| -1. Clone the repository and navigate to the directory: |
13 | 16 | ```bash
|
14 | 17 | git clone https://github.com/int-brain-lab/ibleatools.git
|
15 | 18 | cd ibleatools
|
16 |
| -``` |
17 |
| - |
18 |
| -2. Install the package in editable mode: |
19 |
| -```bash |
20 | 19 | pip install -e .
|
21 | 20 | ```
|
22 | 21 |
|
23 |
| -## Main Functions |
24 |
| - |
25 |
| -The package provides functions for electrophysiology analysis: |
26 |
| - |
27 |
| -### 1. Feature Computation from Probe ID (`compute_features_from_pid`) |
28 |
| - |
29 |
| -This function computes various electrophysiological features from raw neural recordings using data from the IBL database with a probe ID (pid). |
30 |
| - |
31 |
| -Basic usage: |
32 |
| -```python |
33 |
| -from one.api import ONE |
34 |
| -from ephysatlas.feature_computation import compute_features_from_pid |
35 |
| - |
36 |
| -# Using IBL database |
37 |
| -one = ONE() # Initialize ONE client |
38 |
| -df_features = compute_features_from_pid( |
39 |
| - pid="your_probe_id", |
40 |
| - t_start=300.0, # Start time in seconds |
41 |
| - duration=3.0, # Duration in seconds |
42 |
| - one=one |
43 |
| -) |
44 |
| -``` |
45 |
| - |
46 |
| -The function returns a pandas DataFrame containing various electrophysiological features, which are also saved in Parquet format for efficient storage and retrieval. |
47 |
| - |
48 |
| -### 2. Feature Computation from Files (`compute_features_from_file`) |
49 |
| - |
50 |
| -This function computes various electrophysiological features from local .cbin files (AP and LF band data). |
51 |
| - |
52 |
| -Basic usage: |
53 |
| -```python |
54 |
| -from ephysatlas.feature_computation import compute_features_from_file |
55 |
| - |
56 |
| -# Using local files |
57 |
| -df_features = compute_features_from_file( |
58 |
| - ap_file="path/to/ap.cbin", |
59 |
| - lf_file="path/to/lf.cbin", |
60 |
| - t_start=300.0, |
61 |
| - duration=3.0 |
62 |
| -) |
63 |
| -``` |
64 |
| - |
65 |
| -### 3. Legacy Function (`compute_features`) - DEPRECATED |
66 |
| - |
67 |
| -> **Note**: The `compute_features` function is deprecated and will be removed in a future version. Please use `compute_features_from_pid` or `compute_features_from_file` instead. |
68 |
| -
|
69 |
| -This function was the original interface for computing electrophysiological features. It can work with either: |
70 |
| -- Data from the IBL database using a probe ID (pid) |
71 |
| -- Local .cbin files (AP and LF band data) |
72 |
| - |
73 |
| -Basic usage: |
74 |
| -```python |
75 |
| -from one.api import ONE |
76 |
| -from ephysatlas.feature_computation import compute_features |
77 |
| - |
78 |
| -# Using IBL database |
79 |
| -one = ONE() # Initialize ONE client |
80 |
| -df_features = compute_features( |
81 |
| - pid="your_probe_id", |
82 |
| - t_start=300.0, # Start time in seconds |
83 |
| - duration=3.0, # Duration in seconds |
84 |
| - one=one |
85 |
| -) |
86 |
| - |
87 |
| -# Using local files |
88 |
| -df_features = compute_features( |
89 |
| - ap_file="path/to/ap.cbin", |
90 |
| - lf_file="path/to/lf.cbin", |
91 |
| - t_start=300.0, |
92 |
| - duration=3.0 |
93 |
| -) |
94 |
| -``` |
95 |
| - |
96 |
| -The function returns a pandas DataFrame containing various electrophysiological features, which are also saved in Parquet format for efficient storage and retrieval. |
97 |
| - |
98 |
| -> **Note**: Due to a known issue in PyTorch ([#132372](https://github.com/pytorch/pytorch/issues/132372)), you might encounter a SEGFAULT when running the feature computation. To resolve this, you can either: |
99 |
| -> 1. Import torch at the start of your script: |
100 |
| -> ```python |
101 |
| -> import torch # Add this at the beginning of your script |
102 |
| -> ``` |
103 |
| -> 2. Set the `DYLD_LIBRARY_PATH` environment variable to point to your virtual environment's torch library: |
104 |
| -> ```bash |
105 |
| -> export DYLD_LIBRARY_PATH=/path/to/your/venv/lib/python3.x/site-packages/torch/lib |
106 |
| -> ``` |
107 |
| -
|
108 |
| -> **Important**: This package (`ephysatlas`) is different from the `ephys_atlas` package (with underscore) from the [paper-ephys-atlas](https://github.com/int-brain-lab/paper-ephys-atlas) repository. |
109 |
| -
|
110 |
| -### 4. Region Inference (`infer_regions`) |
111 |
| -
|
112 |
| -This function uses pre-trained models to infer brain regions from the computed features. It performs inference across multiple model folds and returns both the predicted regions and their probabilities. |
113 |
| -
|
114 |
| -Basic usage: |
115 |
| -
|
116 |
| -```python |
117 |
| -from ephysatlas.regionclassifier.region_inference import infer_regions |
118 |
| -
|
119 |
| -# Perform region inference |
120 |
| -predicted_probas, predicted_region = infer_regions( |
121 |
| - df_inference=df_features, # DataFrame from compute_features |
122 |
| - path_model="path/to/model" # Path to the model directory |
123 |
| -) |
124 |
| -``` |
125 |
| -
|
126 |
| -The function returns: |
127 |
| -- `predicted_probas`: Array of shape (n_folds, n_channels, n_regions) containing region probabilities |
128 |
| -- `predicted_region`: Array of shape (n_folds, n_channels) containing predicted region indices |
129 |
| - |
130 |
| -## Usage through CLI |
131 |
| - |
132 |
| -The CLI interface is through `main.py`, which can be run using a configuration file: |
133 |
| - |
134 |
| -```bash |
135 |
| -python main.py --config config.yaml |
136 |
| -``` |
137 |
| - |
138 |
| -Using CLI one can do both feature computations and region inference by specifying it in the configuration. |
139 |
| - |
140 |
| -> **Note**: The CLI currently uses the deprecated `compute_features` function internally. This will be updated in a future version to use the new `compute_features_from_pid` and `compute_features_from_file` functions. |
141 |
| -
|
142 |
| -### Configuration File |
143 |
| - |
144 |
| -The configuration is managed through a YAML file. To avoid committing local changes, the actual configuration file (`config.yaml`) is ignored by git. Instead, a template file (`config_template.yaml`) is provided. To use the tool: |
145 |
| - |
146 |
| -1. Copy the template file to create your local configuration: |
147 |
| -```bash |
148 |
| -cp config_template.yaml config.yaml |
149 |
| -``` |
150 |
| - |
151 |
| -2. Edit `config.yaml` with your specific settings: |
152 |
| -```yaml |
153 |
| -# Required parameters |
154 |
| -pid: "5246af08-0730-40f7-83de-29b5d62b9b6d" # Probe ID |
155 |
| -t_start: 300.0 # Start time in seconds |
156 |
| -duration: 3.0 # Duration in seconds |
157 |
| - |
158 |
| -# Operation mode |
159 |
| -mode: "both" # Options: 'features', 'inference', or 'both' |
160 |
| - |
161 |
| -# Optional parameters |
162 |
| -output_dir: "/path/to/output_dir" # Path to output directory |
163 |
| -model_path: "/path/to/model" # Path to the model directory for region inference |
164 |
| -``` |
165 |
| -
|
166 |
| -#### Configuration Parameters |
167 |
| -
|
168 |
| -- **Required Parameters**: |
169 |
| - - `pid`: Probe ID for the recording |
170 |
| - - `t_start`: Start time in seconds |
171 |
| - - `duration`: Duration of the analysis in seconds |
172 |
| - |
173 |
| -- **Operation Mode**: |
174 |
| - - `mode`: Specifies which operations to perform |
175 |
| - - `features`: Only compute features |
176 |
| - - `inference`: Only perform region inference |
177 |
| - - `both`: Perform both feature computation and region inference |
178 |
| - |
179 |
| -- **Optional Parameters**: |
180 |
| - - `output_dir`: Path to output directory for saving results |
181 |
| - - `model_path`: Path to the model directory for region inference. If not provided, a default path will be used |
182 |
| - |
183 |
| -## Output |
| 22 | +## Contributing |
184 | 23 |
|
185 |
| -- Features are saved in Parquet format for efficient storage |
186 |
| -- Region inference results include predicted regions and their probabilities |
| 24 | +Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to contribute to this project. |
0 commit comments