Pipelines API
This section details the high-level entry points for running the analysis workflows.
How to pass arguments: each class exposes run(...). Pass keyword arguments matching the parameters documented below. Typical flows:
- Call
run(line_num=..., project_path=..., data_path=..., **other_kwargs)from Python. - Optionally load per-line defaults from
analysis_parameters.csvwithload_analysis_paramsand merge:run(**{**csv_params, "line_num": n, ...}). - CLI modules (
python -m ace_neuro.pipelines.*) only expose a few flags; they merge CSV + defaults internally — see Getting started section 5a.
Miniscope Pipeline
ace_neuro.pipelines.miniscope.MiniscopePipeline
High-level API for calcium imaging analysis workflows.
Orchestrates the complete miniscope analysis pipeline from raw video through CNMF-E source extraction and post-processing. Designed for non-technical users with sensible defaults.
Attributes:
| Name | Type | Description |
|---|---|---|
miniscope_data_manager |
MiniscopeDataManager
|
Data manager populated after run(). |
preprocessor |
MiniscopePreprocessor
|
MiniscopePreprocessor instance. |
processor |
MiniscopeProcessor
|
MiniscopeProcessor instance. |
postprocessor |
MiniscopePostprocessor
|
MiniscopePostprocessor instance. |
Source code in src/ace_neuro/pipelines/miniscope.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
__init__()
run(line_num, project_path=None, data_path=None, filenames=[], crop=True, crop_coords=None, detrend_method='median', df_over_f=False, secs_window=5, quantile_min=8, df_over_f_method='delta_f_over_sqrt_f', parallel=False, n_processes=12, apply_motion_correction=False, inspect_motion_correction=False, plot_params=False, run_CNMFE=False, save_estimates=True, save_CNMFE_estimates_filename='estimates.hdf5', save_CNMFE_params=False, remove_components_with_gui=True, find_calcium_events=True, derivative_for_estimates='first', event_height=5, compute_miniscope_phase=True, filter_miniscope_data=True, n=2, cut=[0.1, 1.5], ftype='butter', btype='bandpass', inline=False, compute_miniscope_spectrogram=True, window_length=30, window_step=3, freq_lims=[0, 15], time_bandwidth=2, headless=False)
Run the complete miniscope analysis pipeline.
Executes preprocessing (crop, detrend, DF/F), processing (motion correction, CNMF-E), and post-processing (component selection, event detection, spectral analysis) in sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_num
|
int
|
Experiment line number in experiments.csv. |
required |
filenames
|
List[str]
|
List of movie filenames to load (e.g., ['0.avi']). |
[]
|
crop
|
bool
|
If True, crop the movie. |
True
|
crop_coords
|
Optional[Union[List[int], Tuple[int, int, int, int]]]
|
Crop coordinates as (x0, y0, x1, y1) tuple/list. If None, reads from analysis_parameters.csv or opens the GUI. |
None
|
detrend_method
|
Optional[str]
|
'median' or 'linear' for photobleaching correction. |
'median'
|
df_over_f
|
bool
|
If True, compute DF/F normalization. |
False
|
secs_window
|
float
|
Window size for DF/F baseline estimation. |
5
|
quantile_min
|
float
|
Percentile for DF/F baseline. |
8
|
df_over_f_method
|
str
|
'delta_f_over_sqrt_f' or 'delta_f_over_f'. |
'delta_f_over_sqrt_f'
|
parallel
|
bool
|
If True, use multiprocessing. |
False
|
n_processes
|
int
|
Number of parallel processes. |
12
|
apply_motion_correction
|
bool
|
If True, run motion correction. |
False
|
inspect_motion_correction
|
bool
|
If True, show motion diagnostics. |
False
|
plot_params
|
bool
|
If True, display CNMF-E parameter plots. |
False
|
run_CNMFE
|
bool
|
If True, run CNMF-E source extraction. |
False
|
save_estimates
|
bool
|
If True, save CNMF-E results to disk. |
True
|
save_CNMFE_estimates_filename
|
str
|
Filename for estimates. |
'estimates.hdf5'
|
save_CNMFE_params
|
bool
|
If True, save parameters to JSON. |
False
|
remove_components_with_gui
|
bool
|
If True, open component curation GUI. |
True
|
find_calcium_events
|
bool
|
If True, detect calcium transients. |
True
|
derivative_for_estimates
|
str
|
'zeroth', 'first', or 'second'. |
'first'
|
event_height
|
float
|
Threshold for peak detection. |
5
|
compute_miniscope_phase
|
bool
|
If True, compute Hilbert phase. |
True
|
filter_miniscope_data
|
bool
|
If True, apply bandpass filter. |
True
|
n
|
int
|
Filter order. |
2
|
cut
|
List[float]
|
[low, high] cutoff frequencies. |
[0.1, 1.5]
|
ftype
|
str
|
Filter type ('butter'). |
'butter'
|
btype
|
str
|
Band type ('bandpass'). |
'bandpass'
|
inline
|
bool
|
If True, replace data with filtered version. |
False
|
compute_miniscope_spectrogram
|
bool
|
If True, compute spectrogram. |
True
|
window_length
|
float
|
Spectrogram window in seconds. |
30
|
window_step
|
float
|
Spectrogram step in seconds. |
3
|
freq_lims
|
List[float]
|
[low, high] frequency range. |
[0, 15]
|
time_bandwidth
|
float
|
Multitaper time-bandwidth product. |
2
|
headless
|
bool
|
If True, disable all GUI interactions. |
False
|
Source code in src/ace_neuro/pipelines/miniscope.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
Ephys Pipeline
ace_neuro.pipelines.ephys.EphysPipeline
High-level API for electrophysiology data analysis workflows.
Provides simplified methods for loading, filtering, and visualizing Neuralynx ephys data with configurable analysis parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
ephys_data_manager |
EphysDataManager
|
EphysDataManager instance (set after run()). |
Source code in src/ace_neuro/pipelines/ephys.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
__init__()
run(line_num, project_path=None, data_path=None, channel_name='PFCLFPvsCBEEG', remove_artifacts=False, filter_type=None, filter_range=[0.5, 4], compute_phases=False, plot_channel=False, plot_spectrogram=False, plot_phases=False, logging_level='CRITICAL', headless=False)
Run the ephys analysis pipeline for a single channel.
Loads ephys data, optionally filters and computes phases, and generates plots based on the provided parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_num
|
int
|
Experiment line number in experiments.csv. |
required |
project_path
|
Optional[Union[str, Path]]
|
Optional explicit path to project repository. |
None
|
data_path
|
Optional[Union[str, Path]]
|
Optional explicit base path for raw experimental data. |
None
|
channel_name
|
str
|
Name of ephys channel to analyze. |
'PFCLFPvsCBEEG'
|
remove_artifacts
|
bool
|
If True, apply artifact removal. |
False
|
filter_type
|
Optional[str]
|
Filter type ('butter', 'fir') or None to skip. |
None
|
filter_range
|
List[float]
|
[low, high] cutoff frequencies for bandpass. |
[0.5, 4]
|
compute_phases
|
bool
|
If True, compute instantaneous phase via Hilbert. |
False
|
plot_channel
|
bool
|
If True, plot the time-domain signal. |
False
|
plot_spectrogram
|
bool
|
If True, plot the multitaper spectrogram. |
False
|
plot_phases
|
bool
|
If True, plot phase distribution histogram. |
False
|
logging_level
|
Union[str, int]
|
Logging verbosity ('DEBUG', 'INFO', 'CRITICAL'). |
'CRITICAL'
|
headless
|
bool
|
If True, disable GUI and use Agg backend. |
False
|
Source code in src/ace_neuro/pipelines/ephys.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
run_all_channels(line_num, remove_artifacts=False, filter_type=None, filter_range=[0.5, 4], plot_channel=False, plot_spectrogram=False, logging_level='CRITICAL')
Run ephys analysis pipeline for all channels in an experiment.
Iterates through all channels listed in the experiment metadata and performs the analysis workflow on each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_num
|
int
|
Experiment line number in experiments.csv. |
required |
remove_artifacts
|
bool
|
If True, apply artifact removal. |
False
|
filter_type
|
Optional[str]
|
Filter type ('butter', 'fir') or None to skip. |
None
|
filter_range
|
List[float]
|
[low, high] cutoff frequencies for bandpass. |
[0.5, 4]
|
plot_channel
|
bool
|
If True, plot time-domain signals. |
False
|
plot_spectrogram
|
bool
|
If True, plot spectrograms. |
False
|
logging_level
|
Union[str, int]
|
Logging verbosity. |
'CRITICAL'
|
Source code in src/ace_neuro/pipelines/ephys.py
Multimodal Pipeline
ace_neuro.pipelines.multimodal.MultimodalPipeline
Orchestrates ephys + miniscope analysis and multimodal alignment.
After :meth:run, these instance attributes are populated (None if a
stage did not apply):
- :attr:
ephys_pipeline— :class:EphysPipelineinstance used for this run - :attr:
miniscope_pipeline— :class:MiniscopePipelineinstance used - :attr:
t_ca_im— aligned calcium frame times from TTL sync - :attr:
low_confidence_periods— sync quality mask from alignment - :attr:
ephys_idx_all_TTL_events— ephys sample indices for TTL events - :attr:
ephys_idx_ca_events— ephys indices at calcium events (ifca_events) - :attr:
ca_frame_num_of_ephys_idx— per-frame mapping (if TTL indices exist) - :attr:
ca_events_phases_ephys— phase samples for CA events (ephys band) - :attr:
ca_events_phases_miniscope— phase samples for CA events (miniscope) - :attr:
phase_hist_ephys/ :attr:phase_bin_edges_ephys— histogram of ephys phases - :attr:
phase_hist_miniscope/ :attr:phase_bin_edges_miniscope— histogram of miniscope phases
Source code in src/ace_neuro/pipelines/multimodal.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
run(line_num, project_path=None, data_path=None, channel_name='PFCLFPvsCBEEG', remove_artifacts=False, filter_type=None, filter_range=[0.5, 4], plot_channel=False, plot_spectrogram=False, plot_phases=False, logging_level='CRITICAL', miniscope_filenames=[], crop=True, crop_coords=None, detrend_method='median', df_over_f=False, secs_window=5, quantile_min=8, df_over_f_method='delta_f_over_sqrt_f', parallel=False, n_processes=6, apply_motion_correction=True, inspect_motion_correction=True, plot_params=False, run_CNMFE=True, save_estimates=True, save_CNMFE_estimates_filename='estimates.hdf5', save_CNMFE_params=False, remove_components_with_gui=True, find_calcium_events=True, derivative_for_estimates='first', event_height=5, compute_miniscope_phase=True, filter_miniscope_data=True, n=2, cut=[0.1, 1.5], ftype='butter', btype='bandpass', inline=False, compute_miniscope_spectrogram=True, window_length=30, window_step=3, freq_lims=[0, 15], time_bandwidth=23, delete_TTLs=True, fix_TTL_gaps=False, only_experiment_events=True, all_TTL_events=True, ca_events=False, time_range=None, headless=False)
Run the complete multimodal analysis pipeline.
Executes both ephys and miniscope pipelines, synchronizes their timestamps via TTL events, and performs phase-locked calcium event analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_num
|
int
|
Experiment line number in experiments.csv. |
required |
channel_name
|
str
|
Ephys channel name to analyze. |
'PFCLFPvsCBEEG'
|
remove_artifacts
|
bool
|
If True, remove ephys artifacts. |
False
|
filter_type
|
str | None
|
Ephys filter type ('butter', 'fir') or None. |
None
|
filter_range
|
list[float]
|
[low, high] bandpass cutoffs for ephys. |
[0.5, 4]
|
plot_channel
|
bool
|
If True, plot ephys time series. |
False
|
plot_spectrogram
|
bool
|
If True, plot ephys spectrogram. |
False
|
plot_phases
|
bool
|
If True, plot phase histograms. |
False
|
logging_level
|
str
|
Verbosity level. |
'CRITICAL'
|
miniscope_filenames
|
list[str]
|
List of movie files to load. |
[]
|
crop
|
bool
|
If True, crop the movie. |
True
|
crop_coords
|
list[int] | tuple[int, int, int, int] | None
|
Crop coordinates as (x0, y0, x1, y1) tuple/list. If None, reads from analysis_parameters.csv or opens the GUI. |
None
|
detrend_method
|
str
|
'median' or 'linear' detrending. |
'median'
|
df_over_f
|
bool
|
If True, compute DF/F. |
False
|
parallel
|
bool
|
If True, use multiprocessing. |
False
|
n_processes
|
int
|
Number of parallel processes. |
6
|
apply_motion_correction
|
bool
|
If True, correct motion. |
True
|
run_CNMFE
|
bool
|
If True, run source extraction. |
True
|
delete_TTLs
|
bool
|
If True, remove dropped frame TTLs. |
True
|
fix_TTL_gaps
|
bool
|
If True, interpolate missing TTLs. |
False
|
only_experiment_events
|
bool
|
If True, keep only experiment events. |
True
|
all_TTL_events
|
bool
|
If True, process all TTL events. |
True
|
ca_events
|
bool
|
If True, include calcium event analysis. |
False
|
time_range
|
list[float] | None
|
Optional [start, end] time range to analyze. |
None
|
headless
|
bool
|
If True, disable all GUI interactions. |
False
|
Source code in src/ace_neuro/pipelines/multimodal.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |