neuralib.calimg.spikes.cascade
Cascade
Cascade translates calcium imaging ΔF/F traces into spiking probabilities or discrete spikes
- typeddict neuralib.calimg.spikes.cascade.CascadeModelConfig[source]
typing.TypedDict.- Optional Keys:
model_name (
str) – Name of the modelsampling_rate (
int) – Sampling rate in Hztraining_datasets (
list[str]) – Dataset of ground truth data (in folder ‘Ground_truth’)placeholder_1 (
int) – protect formattingnoise_levels (
list[int]) – Noise levels for training (integers, normally 1-9)placeholder_2 (
int) – protect formattingsmoothing (
float) – Standard deviation of Gaussian smoothing in time (sec)causal_kernel (
int) – Smoothing kernel is symmetric in time (0) or is causal (1)windowsize (
int) – Windowsize in timepointsbefore_frac (
float) – Fraction of timepoints before prediction point (0-1)filter_sizes (
list[int]) – Filter sizes for each convolutional layerfilter_numbers (
list[int]) – Filter numbers for each convolutional layerdense_expansion (
int) – For dense layerloss_function (
str) – gradient-descent loss functionoptimizer (
str) – Adagradnr_of_epochs (
int) – Number of training epochs per modelensemble_size (
int) – Number of models trained for one noise levelbatch_size (
int) – Batch sizetraining_finished (
Literal['Yes','No','Running']) – Yes / No / Runningverbose (
int) – level of status messages (0: minimal, 1: standard, 2: most, 3: all)
- neuralib.calimg.spikes.cascade.cascade_predict(dff, model_type, *, threshold=0, padding=0, verbose=True, chunks_mode_limit=10, cache_dir=None)[source]
Spike prediction using Cascade pretrained model
- Parameters:
dff (np.ndarray) – dF/F activity to be predicted. Array[float, [N, F]|F]
model_type (CASCADE_MODEL_TYPE) –
MODEL_TYPEthreshold (int | bool) – Allowed values: 0, 1 or False. 0: All negative values are set to 0. 1 or True: Threshold signal to set every signal which is smaller than the expected signal size of an action potential to zero (with dilated mask) False: No thresholding. The result can contain negative values as well
padding (float) – Value which is inserted for datapoints, where no prediction can be made (because of window around timepoint of prediction). Default value: np.nan, another recommended value would be 0 which circumvents some problems with following analysis.
verbose (bool) – Verbose of model information
chunks_mode_limit (float) – Decrease the number if memory issue dealing with large input arrays.
cache_dir (PathLike | None) – Cache directory for saving the model. If None, then used default under ~/.cache/neuralib
- Returns:
Spiking probability as predicted by the model. Array[float, [N, F]|F]
- Return type:
np.ndarray
- class neuralib.calimg.spikes.cascade.CascadeSpikePrediction[source]
- __init__(dff, model_type, *, threshold=0, padding=0, verbose=True, chunks_mode_limit=10, cache_dir=None)[source]
- Parameters:
dff (np.ndarray) – dF/F activity to be predicted. Array[float, [N, F]|F]
model_type (CASCADE_MODEL_TYPE) –
MODEL_TYPEthreshold (int | bool) – Allowed values: 0, 1 or False. 0: All negative values are set to 0. 1 or True: Threshold signal to set every signal which is smaller than the expected signal size of an action potential to zero (with dilated mask) False: No thresholding. The result can contain negative values as well
padding (float) – Value which is inserted for datapoints, where no prediction can be made (because of window around timepoint of prediction). Default value: np.nan, another recommended value would be 0 which circumvents some problems with following analysis.
verbose (bool) – Verbose of model information
chunks_mode_limit (float) – Decrease the number if memory issue dealing with large input arrays.
cache_dir (PathLike | None) – Cache directory for saving the model. If None, then used default under ~/.cache/neuralib
- property available_model_yaml: Path
All models link/info yaml
- get_available_models()[source]
Get all the available in
available_model_yaml- Return type:
list[Literal[‘Global_EXC_1Hz_smoothing500ms’, ‘Global_EXC_1Hz_smoothing1000ms’, ‘Zebrafish_1Hz_smoothing1000ms’, ‘Global_EXC_2Hz_smoothing300ms’, ‘Global_EXC_2Hz_smoothing500ms’, ‘Global_EXC_2Hz_smoothing1000ms’, ‘Global_EXC_2.5Hz_smoothing400ms_high_noise’, ‘Global_EXC_3Hz_smoothing400ms’, ‘Global_EXC_3Hz_smoothing400ms_high_noise’, ‘Global_EXC_3Hz_smoothing400ms_causalkernel’, ‘Global_EXC_4.25Hz_smoothing300ms’, ‘Global_EXC_4.25Hz_smoothing300ms_high_noise’, ‘Global_EXC_4.25Hz_smoothing300ms_causalkernel’, ‘Global_EXC_5Hz_smoothing200ms’, ‘Global_EXC_5Hz_smoothing200ms_causalkernel’, ‘Global_EXC_6Hz_smoothing200ms’, ‘Global_EXC_6Hz_smoothing200ms_causalkernel’, ‘Global_EXC_7Hz_smoothing200ms’, ‘Global_EXC_7Hz_smoothing200ms_causalkernel’, ‘Global_EXC_7.5Hz_smoothing200ms_high_noise’, ‘Global_EXC_7.5Hz_smoothing200ms’, ‘Global_EXC_7.5Hz_smoothing200ms_causalkernel’, ‘OGB_zf_pDp_7.5Hz_smoothing200ms’, ‘OGB_zf_pDp_7.5Hz_smoothing200ms_causalkernel’, ‘Global_EXC_10Hz_smoothing50ms’, ‘Global_EXC_10Hz_smoothing50ms_causalkernel’, ‘Global_EXC_10Hz_smoothing100ms’, ‘Global_EXC_10Hz_smoothing100ms_causalkernel’, ‘Global_EXC_10Hz_smoothing200ms’, ‘Global_EXC_10Hz_smoothing200ms_causalkernel’, ‘Global_EXC_12.5Hz_smoothing100ms’, ‘Global_EXC_12.5Hz_smoothing100ms_causalkernel’, ‘Global_EXC_12.5Hz_smoothing200ms’, ‘Global_EXC_12.5Hz_smoothing200ms_causalkernel’, ‘Global_EXC_15Hz_smoothing50ms’, ‘Global_EXC_15Hz_smoothing50ms_causalkernel’, ‘Global_EXC_15Hz_smoothing100ms_high_noise’, ‘Global_EXC_15Hz_smoothing100ms’, ‘Global_EXC_15Hz_smoothing100ms_causalkernel’, ‘Global_EXC_15Hz_smoothing200ms’, ‘Global_EXC_15Hz_smoothing200ms_causalkernel’, ‘Global_INH_15Hz_smoothing100ms’, ‘Global_EXC_17.5Hz_smoothing100ms’, ‘Global_EXC_17.5Hz_smoothing100ms_causalkernel’, ‘Global_EXC_17.5Hz_smoothing200ms’, ‘Global_EXC_17.5Hz_smoothing200ms_causalkernel’, ‘Global_EXC_20Hz_smoothing100ms’, ‘Global_EXC_20Hz_smoothing100ms_causalkernel’, ‘Global_EXC_20Hz_smoothing200ms’, ‘Global_EXC_20Hz_smoothing200ms_causalkernel’, ‘Global_EXC_25Hz_smoothing100ms’, ‘Global_EXC_25Hz_smoothing100ms_causalkernel’, ‘Global_EXC_25Hz_smoothing50ms’, ‘Global_EXC_25Hz_smoothing50ms_causalkernel’, ‘Global_EXC_30Hz_smoothing25ms’, ‘Global_EXC_30Hz_smoothing25ms_causalkernel’, ‘Global_EXC_30Hz_smoothing50ms’, ‘Global_EXC_30Hz_smoothing50ms_high_noise’, ‘Global_EXC_30Hz_smoothing50ms_causalkernel’, ‘Global_EXC_30Hz_smoothing100ms’, ‘Global_EXC_30Hz_smoothing100ms_causalkernel’, ‘Global_EXC_30Hz_smoothing200ms’, ‘Global_EXC_30Hz_smoothing100ms_causalkernel_high_noise’, ‘Global_EXC_30Hz_smoothing100ms_high_noise’, ‘Global_EXC_30Hz_smoothing200ms_causalkernel_high_noise’, ‘Global_EXC_40Hz_smoothing25ms_causalkernel’, ‘Global_EXC_40Hz_smoothing25ms’, ‘Global_EXC_40Hz_smoothing25ms_high_noise’, ‘Global_EXC_40Hz_smoothing50ms’, ‘Global_EXC_40Hz_smoothing50ms_high_noise’, ‘Global_EXC_40Hz_smoothing50ms_causalkernel’, ‘Global_INH_30Hz_smoothing50ms’, ‘Global_INH_30Hz_smoothing100ms’, ‘Global_EXC_30Hz_smoothing50ms_asymmetric_window_1_frame’, ‘Global_EXC_30Hz_smoothing50ms_asymmetric_window_2_frames’, ‘Global_EXC_30Hz_smoothing50ms_asymmetric_window_4_frames’, ‘Global_EXC_30Hz_smoothing50ms_asymmetric_window_6_frames’, ‘Global_EXC_30Hz_smoothing50ms_asymmetric_window_8_frames’, ‘GCaMP6f_mouse_30Hz_smoothing200ms’, ‘Spinal_cord_excitatory_30Hz_smoothing50ms’, ‘Spinal_cord_inhibitory_30Hz_smoothing50ms’, ‘Spinal_cord_excitatory_3Hz_smoothing400ms_high_noise’, ‘Spinal_cord_inhibitory_3Hz_smoothing400ms_high_noise’, ‘Spinal_cord_excitatory_2.5Hz_smoothing400ms’, ‘Spinal_cord_inhibitory_2.5Hz_smoothing400ms’, ‘GC8_EXC_5Hz_smoothing400ms_high_noise’, ‘GC8_EXC_5Hz_smoothing800ms_high_noise’, ‘GC8_EXC_7.5Hz_smoothing100ms_high_noise’, ‘GC8_EXC_7.5Hz_smoothing200ms_high_noise’, ‘GC8_EXC_10Hz_smoothing150ms_high_noise’, ‘GC8_EXC_10Hz_smoothing75ms_high_noise’, ‘GC8_EXC_15Hz_smoothing100ms_high_noise’, ‘GC8_EXC_15Hz_smoothing50ms_high_noise’, ‘GC8_EXC_30Hz_smoothing25ms_high_noise’, ‘GC8_EXC_30Hz_smoothing50ms_high_noise’, ‘GC8_EXC_40Hz_smoothing15ms_high_noise’, ‘GC8_EXC_40Hz_smoothing30ms_high_noise’]]
- property model_link: str
Link of specified model
- property model_dir: Path
Directory of specified model
- property config_file
Config filepath of specified model