Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exact zeros in dff traces #577

Open
alexpiet opened this issue Jun 12, 2019 · 5 comments
Open

Exact zeros in dff traces #577

alexpiet opened this issue Jun 12, 2019 · 5 comments

Comments

@alexpiet
Copy link
Collaborator

alexpiet commented Jun 12, 2019

@matchings @jeromelecoq
I've noticed something odd, and I'm not sure if its a bug, but I can't think of a reason why it might be true. Some sessions have df/f values that are exactly equal to zero. These values do not happen at the start or end of the session, and are randomly intermixed. Its extremely odd to me that the values could be exactly 0.

import numpy as np
from visual_behavior.ophys.io.convert_level_1_to_level_2 import convert_level_1_to_level_2
from visual_behavior.ophys.dataset.visual_behavior_ophys_dataset import VisualBehaviorOphysDataset
from visual_behavior.ophys.response_analysis.response_analysis import ResponseAnalysis
experiment_id = 787498309
cache_dir = r'/allen/programs/braintv/workgroups/nc-ophys/visual_behavior/visual_behavior_production_analysis'
dataset = VisualBehaviorOphysDataset(experiment_id, cache_dir=cache_dir)
dff = dataset.dff_traces
np.sum(dff == 0)
413594
float(np.sum(dff == 0))/np.prod(np.shape(dff))
0.009877768012380826
np.sum((dff[0:-1] == 0) & (dff[1:] == 0))
4170
float(np.sum((dff[0:-1] == 0) & (dff[1:] == 0)))/np.prod(np.shape(dff))
9.959112707541222e-05
0.00987*0.00987
9.741690000000001e-05

This last check demonstrates that the exact 0s are randomly intermixed

@jeromelecoq
Copy link
Contributor

jeromelecoq commented Jun 12, 2019 via email

@alexpiet
Copy link
Collaborator Author

alexpiet commented Jun 12, 2019

@jeromelecoq I'm not sure if this is what you meant, but the motion correction values in the ophys dataset object do not have NaNs.

np.sum(pd.isnull(dataset.motion_correction.x_corr))
0
np.sum(pd.isnull(dataset.motion_correction.y_corr))
0

@alexpiet
Copy link
Collaborator Author

@jeromelecoq and I just talked in person, and we also checked that the x_corr and y_corr values are not exact 0s. Jerome suspects the exact 0s in df/f originate in the segmentation algorithm which at some point, to prevent numerical instabilities rounds numbers close to zero to exactly 0. If so, that is probably OK, but I just want to make sure that is the source of the exact 0s instead of something unexpected.

@nickponvert
Copy link
Contributor

@alexpiet can we close this? Should we submit a ticket to technology to verify that this is the cause of this behavior?

@alexpiet
Copy link
Collaborator Author

I think we should submit a ticket to technology to verify the source of this behavior

@alexpiet alexpiet removed their assignment Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants