Core
Pipeline¶
treat2p.core.run_treat2p
¶
Run Treat2p processing on Suite2p outputs, optionally in parallel.
Loads Suite2p output arrays (e.g., fluorescence and neuropil traces), applies a pipeline of corrections/modifications (e.g., neuropil factor estimation and/or slow trend correction), optionally generates figures, and optionally saves the results back into the Suite2p folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suite2p_results_path
|
str | Path
|
Path to the Suite2p results
directory (containing plane folders and/or output |
required |
plane
|
int
|
Plane index to process. Defaults to 0. |
0
|
chan
|
Literal[1, 2]
|
Channel number (1-based, as in Suite2p). Use 2 for channel #2. Defaults to 1. |
1
|
rootnames
|
dict
|
Optional mapping to override default Suite2p
file basenames used when loading arrays.
Example: |
{}
|
extension
|
str
|
Input/output file extension (e.g., |
'npy'
|
backend
|
str
|
Joblib parallel backend to use. Defaults to
|
'loky'
|
n_jobs
|
int
|
Number of parallel workers. Use 1 to disable parallel processing. Defaults to 6. |
6
|
run_name
|
str
|
Optional label for this run (used for naming
outputs/figures depending on implementation). Defaults to |
''
|
do_figures
|
bool
|
Whether to generate diagnostic figures. Defaults to True. |
True
|
save_results
|
bool
|
Whether to write modified arrays/results back to disk (Suite2p folder). Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments forwarded to pipeline modules. Common keys include: Neuropil factor / ARDSIP options: neuropil_correction_factor (Optional[float]): If provided, uses this neuropil correction factor and skips ARDSIP estimation. Must be in [0, 1]. Typical values are 0.5 or 0.7. Defaults to None. do_slow_trend_correction (bool): Whether to perform slow-trend neuropil correction. Defaults to True. max_iterations (int): Maximum ARDSIP iterations. Defaults to 10. long_window_length (int): Long sliding window length. Defaults to 30. short_window_length (int): Short sliding window length. Defaults to 3. baseline_percentile (float): Baseline fluorescence percentile. Defaults to 10. convergence_criteria (float): Convergence criterion. Defaults to 0.025. autoregressed_activity_threshold (float): Activity threshold used by autoregression. Defaults to 0.5. initial_neuropil_factor (float): Initial neuropil factor. Defaults to 0.5. downsampling (float): Downsampling factor for baseline computation. 1 means no downsampling; 4 means use 1 sample out of 4. Larger values are faster but less faithful. Defaults to 4. zscoring_mid_percentile (float): Upper percentile used for z-scoring. Defaults to 16. zscoring_low_percentile (float): Lower percentile used for z-scoring. Defaults to 2.3. Slow-trend estimation options: window (int): Window (seconds) for percentile calculation. Defaults to 120. slow_trend_percentile (int): Percentile used for slow-trend calculation. Defaults to 10. fps (int): Acquisition sampling rate (Hz). Defaults to 30. step (int): Step (samples) between percentile computations. Defaults to 10. filter_savgol (bool): Whether to apply a Savitzky-Golay filter to the slow trend. Defaults to True. savgol_window_length (int): Savitzky-Golay window length. Defaults to 50. savgol_polyorder (int): Savitzky-Golay polynomial order. Defaults to 2. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
tuple[dict, dict, dict]: Three dictionaries containing outputs produced by |
dict
|
the pipeline (exact contents depend on enabled modules and implementation). |
Source code in src/treat2p/core.py
14 15 16 17 18 19 20 21 22 23 24 25 26 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 | |
treat2p.core.pipeline
¶
Run the Treat2p correction pipeline for a single ROI.
Applies (optionally) slow-trend correction, neuropil correction, ΔF/F computation, and normalization to the ROI fluorescence trace using Suite2p outputs.
The keyword arguments in kwargs are forwarded to the underlying helper
functions (e.g. ARDSIP neuropil factor estimation and slow-trend
estimation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
F
|
ndarray
|
Fluorescence trace of the ROI/cell (shape: |
required |
Fneu
|
ndarray
|
Neuropil fluorescence trace associated with the ROI
(shape: |
required |
roi_nb
|
int
|
ROI index/identifier (used for bookkeeping/figure naming). |
required |
do_slow_trend_correction
|
bool
|
Whether to perform slow-trend correction (typically on the neuropil and/or corrected signal). Defaults to True. |
True
|
do_delta_f
|
bool
|
Whether to compute ΔF/F. Defaults to True. |
True
|
do_normalization
|
bool
|
Whether to normalize the output trace. Defaults to True. |
True
|
normalization_percentile
|
float | None
|
Percentile parameter used by the normalization step (interpretation depends on the normalization implementation). If None, uses the default behavior of the normalization function. Defaults to None. |
None
|
neuropil_correction_factor
|
float | None
|
If provided, use this value as the neuropil correction factor and skip ARDSIP estimation. Must be between 0 and 1 (typical values: 0.5–0.7). Defaults to None. |
None
|
F0_index
|
int
|
Index (or method selector, depending on implementation) used for baseline (F0) computation. Defaults to 5. |
5
|
F0_span
|
int
|
Span/window length used for baseline (F0) computation. Defaults to 30. |
30
|
figures_root
|
Path | None
|
If provided, save diagnostic figures under this directory. If None, figures are not saved (or are handled by defaults elsewhere). Defaults to None. |
None
|
**kwargs
|
Any
|
Additional parameters forwarded to underlying steps. ARDSIP neuropil factor estimation (e.g. Slow-trend estimation (e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
dict
|
tuple[dict, dict, dict]: Three dictionaries containing intermediate and/or |
dict
|
final outputs produced by the pipeline (contents depend on enabled steps). |
Source code in src/treat2p/core.py
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 | |