timescales.pipe.Pipe
timescales.pipe.Pipe¶
- class timescales.pipe.Pipe(n_seconds, fs, seeds=None)[source]¶
Simulations, PSD/ACF, and fitting pipelines.
- Parameters
- n_secondsfloat
Length of signal, in seconds.
- fsfloat
Sampling rate, in Hertz.
- seeds1d array of int
Random seeds for reproducible simulations.
Methods
__init__
(n_seconds, fs[, seeds])add_step
(step, *args, **kwargs)Add a step to the pipeline.
bin
(bin_size)Bin signal.
fit
(return_attrs, **fit_kwargs)Fit timescale of simulation.
normalize
(sig[, mean, variance])Normalize signal with given mean and variance.
rescale
(sig[, norm_range])Normalize signal from lower to upper.
run
([n_jobs, progress])Run analysis pipeline.
sample
([fs])Sample binary array from probabilties.
simulate
(sim_func, *sim_args[, operator, ...])Simulate aperiodic signal.
transform
(method, **compute_kwargs)Fit timescale of simulation.
- add_step(step, *args, **kwargs)[source]¶
Add a step to the pipeline.
- Parameters
- step{‘simulate’, ‘sample’, ‘transform’, fit’}
Method to run.
- *args
Positional arugments for the specified method.
- **kwargs
Keyword arguemnts for the specified method.
- fit(return_attrs, **fit_kwargs)[source]¶
Fit timescale of simulation.
- Parameters
- return_attrsstr or list of str or {‘knee_freq’, ‘tau’, ‘rsq’}
Model attributes to specifically store. These are attributes of PSD or ACF objects set upon fitting.
- **fit_kwargs
Keyword arguments passed to the fit method of the PSD or ACF objects.
Notes
Assumes fit type based on transform method call.
- static normalize(sig, mean=None, variance=None)[source]¶
Normalize signal with given mean and variance.
- run(n_jobs=- 1, progress=None)[source]¶
Run analysis pipeline.
- Parameters
- n_jobsint
Number of jobs to run in parralel.
- progress{None, ‘tqdm’, ‘tqdm.notebook’}
Specify whether to display a progress bar. Uses ‘tqdm’, if installed.
- sample(fs=None)[source]¶
Sample binary array from probabilties.
- Parameters
- fsint, optional, default: None
Updated sampling rate.
Notes
Assumes the sig attribute is the target probability array.
- simulate(sim_func, *sim_args, operator='add', rescale=None, mean=None, variance=None, **sim_kwargs)[source]¶
Simulate aperiodic signal.
- Parameters
- sim_funcfunc
Simulation function.
- operator{‘add’, ‘mul’, ‘sub’, ‘div’} or {‘+’, ‘*’, ‘-’, ‘/’}
Operator to combine signals.
- rescaletuple of (float, float), optional, default: None
Minimum and maximum y-values of simulation.
- meanfloat, optional, default: None
Mean to normalize to.
- variancefloat, opational, default: None
Variance to normalize to.
- *sim_args
Additonal simulation positional arugments.
- **sim_kwargs
Additional simulation keyword arguments.
Notes
Either rescale or (mean, std) should be passed for each simulation.