Skip to content

Exact zeros in dff traces #577

Open
Open

Description

@alexpiet

@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

Activity

  1. jeromelecoq commented on Jun 12, 2019

    @jeromelecoq
    Contributor
  2. alexpiet commented on Jun 12, 2019

    @alexpiet
    CollaboratorAuthor

    @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

  3. alexpiet commented on Jun 12, 2019

    @alexpiet
    CollaboratorAuthor

    @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.

  4. nickponvert commented on Jan 22, 2020

    @nickponvert
    Contributor

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

  5. alexpiet commented on Jan 22, 2020

    @alexpiet
    CollaboratorAuthor

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

  6. removed their assignment
    on Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions