Multimodal API
Alignment and cross-modal analysis between Miniscope calcium imaging and electrophysiology.
How to pass arguments: same pattern as other pipelines — use MultimodalPipeline.run(...) with keyword arguments; see Getting started section 5a and Pipelines.
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 | |
Alignment utilities
ace_neuro.multimodal.miniscope_ephys_alignment_utils.sync_neuralynx_miniscope_timestamps(channel, miniscope_dm, ephys_dm, delete_TTLs=True, fix_TTL_gaps=False, only_experiment_events=True)
Synchronize Neuralynx and miniscope timestamps.
This is a legacy wrapper. It delegates to the new MiniscopeDataManager sync_timestamps architecture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
Channel
|
Channel object containing ephys events. |
required |
miniscope_dm
|
MiniscopeDataManager
|
MiniscopeDataManager with frame info and analysis params. |
required |
ephys_dm
|
EphysDataManager
|
EphysDataManager to extract TTLs from. |
required |
delete_TTLs
|
bool
|
If True, remove TTLs for dropped frames from analysis_params. |
True
|
fix_TTL_gaps
|
bool
|
If True, interpolate missing TTL events. |
False
|
only_experiment_events
|
bool
|
If True, remove TTL events from event list. |
True
|
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray, Channel, MiniscopeDataManager]
|
Tuple of (tCaIm, low_confidence_periods, channel, miniscope_dm) |
Source code in src/ace_neuro/multimodal/miniscope_ephys_alignment_utils.py
ace_neuro.multimodal.miniscope_ephys_alignment_utils.find_ephys_idx_of_TTL_events(tCaIm, channel, frame_rate, ca_events_idx=None, all_TTL_events=True)
Finds the index of a calcium event in the Neuralynx timespace. If the miniscope class method to find the timing of calcium events has not been run yet, it runs that first. CHANNEL is the ephys channel with which to compare the timing of the ephys samples to the calcium event timing.
Source code in src/ace_neuro/multimodal/miniscope_ephys_alignment_utils.py
ace_neuro.multimodal.miniscope_ephys_alignment_utils.find_ca_movie_frame_num_of_ephys_idx(channel, ephys_idx_all_TTL_events)
Method to create an array the same size as obj.ephys[channel], where each element is the frame number of the corresponding calcium movie frame.