HelmchenLabSoftware / Cascade

Calibrated inference of spiking from calcium ΔF/F data using deep networks
GNU General Public License v3.0
123 stars 34 forks source link

Problem when generating ground truth for low sampling rate and low noise models #55

Closed PTRRupprecht closed 1 year ago

PTRRupprecht commented 1 year ago

There is a problem in the function calibrated_ground_truth_artificial_noise() in cascade2p\utils.py. This did not affect any function to predict spikes from raw traces but affects for example the script to evaluate model performance when applied to low-frequency (< 5 Hz) models (Demo_benchmark_model.py).

The problem: To generate ground truth for low-sampling rate models (e.g., 3 Hz), the available ground truth recordings at e.g. 30 Hz need to be temporally downsampled. Previously, the noise level was estimated from the original recordings and the noise level of the downsampled recording estimated based on theoretical considerations. It turns out that these considerations (assumption of Gaussian distribution of dF/F values) is not sufficient.

The solution: To address the problem, the noise level of the downsampled recording is now checked upon resampling, and a function based on gradient ascent iteratively corrects the additive noise until the noise level reaches the target value.

PTRRupprecht commented 1 year ago

Is now fixed by correcting the function calibrated_ground_truth_artificial_noise().