kimtonyhyun / analysis

2 stars 0 forks source link

Cross-day trace amplitude normalization #228

Closed kimtonyhyun closed 4 years ago

kimtonyhyun commented 7 years ago

From a recent discussion with @ahwillia, it occurred to me that we need to be careful about comparing calcium trace amplitudes across days.

@forea @inanhkn cc @bahanonu Careful normalization of trace amplitudes across days will be critical for any decoding-type analyses or reduced dimensional fittings (e.g. factor decomposition) across days, if they are based on using fluorescence traces (as opposed, say, to event detection).

As an illustrative example, consider the following neuron tracked across two days: m1d12_cell427 where:

For this neuron, note that:

Hence, we have strong confidence that we are indeed tracking the same neuron across the two days.

On the other hand, the amplitude of the neuron is obviously distinguishable on the two days. This difference could then be used to distinguish the day / strategy based on this single neuron. However, what is the correct interpretation of this amplitude difference?

The apparent amplitude difference could come from at least three sources:

  1. Variations in experimental setup between the two sessions: Maybe the LED was a little brighter on Day 12 than 14? Maybe the physical mounting of the Miniscope was slightly different between the two days such that the neuron has a higher amplitude on Day 12?
  2. Numerical artifact arising from processing / cell extraction of the calcium movie: The calcium trace for each day depends on the spatial filter that is used to retrieve the signal from the DFF movie. As the extraction process is performed independently for the two days, it is possible for the filter to have better converged to the neural signal on one day than the other.
  3. The difference in amplitude is biological: The apparent amplitude is different because the neuron was in fact brighter in the brain on Day 12 than on Day 14. In this case, we could argue whether this biological difference has to do with strategy coding, or other mechanisms...

I think we'd all agree that if the amplitude differences arose due to (1) or (2) above, then the difference is artifactual and does not reflect anything biological about the prefrontal cortex or how it potentially underlies rule-guided behavior.

Thus, we need to explicitly confirm whether or not cross-day trace amplitude variations are biological. Or, if we conclude that they are artifactual and that we cannot control for them, then we need to explicitly minimize the effect of amplitude variations across days.

Thoughts? More below...

kimtonyhyun commented 7 years ago

Few additional examples to show that varying trace amplitudes is quite common: m1d12_cell377 m1d12_cell256

Here is a neuron that codes for the initial stimulus (east) on both days. However, the amplitude is slightly -- but consistently -- higher on Day 14. Could that amplitude difference code for the strategies?: m1d12_cell458

The last example shows that it's not always the case that Day 12 amplitudes are larger than Day 14. There are also examples where the latter has higher amplitude: m1d12_cell94

inanhkn commented 7 years ago

Why don't you look into it in an algorithm-independent way? For this, you could select a subset cells with high enough SNR and event rate, extract the high amplitude regions in their found images, and go back to the movie and get the average fluorescence in the movie for these regions. If amplitudes are still different, to investigate whether they are different because of a particular preprocessing step, you can use movies at different steps through the pipeline (from the integer movie to the df/f movie). If everything fails to explain the phenomenon, it might just be biological.

kimtonyhyun commented 7 years ago

As one test of whether amplitude differences across days may arise from cell extraction (CELLMax), I concatenated the c11m1d12 (Day 12) and c11m1d14 (Day 14) movies. I then preprocessed and ran CELLMax on the two days as a single movie. In this case, we know at least that the same exact spatial filter is being applied to both Day 12 and Day 14 sections of the combined movie.

I will refer to the concatenated movie as "Day 1214". Here are some trace comparisons showing matched cells across Day 12 - Day 14 - Day 1214; specifically, these are the examples that I showed previously: m1d1214_cell416 m1d1214_cell360 m1d1214_cell288 m1d1214_cell465 m1d1214_cell6

The above examples show that, while Day 12 and Day 14 traces (extracted independently) show differences in calcium trace amplitudes, the corresponding trace from Day 1214 has a common amplitude across the two days.

However, it isn't the case that having a common filter for the two days always neutralizes the differences in the amplitudes. Examples: m1d1214_cell113 m1d1214_cell240

It's also possible for a neuron that appeared to have the same amplitude in the Day12 - Day14 comparison to show a more exaggerated amplitude difference in Day1214: m1d1214_cell53 m1d1214_cell212 m1d1214_cell319

Even in these cases, I would not readily conclude that these amplitude differences are biological in origin. While we have controlled for cell extraction on the two days, there is also the (likely) possibility that some aspect of the experimental setup may have been different between the two days (e.g. slight positioning differences of the Miniscope) which I still consider artifactual.

You can view a lot more examples here: https://stanford.box.com/s/zixqqg9vi7p3i3nt0pvb8cbmhbn5zbi8

Based on the evidence, my tentative conclusion is that:

Hence, our cross-day analyses need to explicitly disregard scaling differences between traces of different amplitudes across days. Thoughts?

kimtonyhyun commented 7 years ago

Why don't you look into it in an algorithm-independent way? For this, you could select a subset cells with high enough SNR and event rate, extract the high amplitude regions in their found images, and go back to the movie and get the average fluorescence in the movie for these regions. If amplitudes are still different, to investigate whether they are different because of a particular preprocessing step, you can use movies at different steps through the pipeline (from the integer movie to the df/f movie).

I considered this suggestion, and applied the CELLMax-identified filters to a movie early on in the preprocessing pipeline. Specifically, I applied filters to the motion corrected movie (but before spatial normalization and DFF). This is the earliest stage in the pipeline where we can reasonably apply a spatial filter to a movie.

I found that the resulting traces are nearly unrecognizable relative to the DFF counterpart (our usual cell trace). The "motion-corrected" (MC) traces essentially show large baseline fluctuations. The features that ultimately make it into the DFF trace are not readily recognizable in the MC traces.

As an example, I considered the following cell (DFF trace shown): example_dff

Here is the Day 12 / Day 14 transition point with DFF and MC traces: example

(As a sanity check, I went back to inspect this cell in the DFF movie, and it's truly there for sure. After motion correction, the only nontrivial operation -- i.e. beyond offset and scaling -- is spatial normalization. It's remarkable how much effect spatial normalization has on the observability of cells.)

inanhkn commented 7 years ago

To check whether MC traces might have the same amplitude, you could calculate the average local variances for the traces like above, separately for the two days. Comparison of the variances between the two days could give you a good idea regardless of the slow baseline fluctuations. By average local variance, I mean selecting a window size, and calculating moving variance and averaging. My observation from above is that amplitude difference between MC traces look more subtle than that between dff traces.

Is the discrepancy in the amplitude shift among cells (i.e. some going down, some up) there with dff traces? If so, there might be something going wrong with spatial normalization. Afterall, there is no clear science to our normalization method (or any others which divide images with their filtered versions), and it might very well be messing with the amplitude information. Also, discrepancy in amplitude trends among cells could be easily attributed to spatial normalization.

ahwillia commented 7 years ago

There is also the (likely) possibility that some aspect of the experimental setup may have been different between the two days (e.g. slight positioning differences of the Miniscope) which I still consider artifactual.

Can we experimentally test this?

This would help disambiguate whether the effect is due to biological differences from day-to-day or to experimental artifacts.


I'd like to change the focus of this discussion a little bit if that is alright. Correct me if I'm wrong, but cells at different depths in the field of view would be expected to have different measured amplitudes due to light scattering (even if they actually had identical activity).

This suggests to me that - even in the best case scenario of a perfect extraction method - the amplitude of the fluorescence signal is not really that informative to the function of the biological circuit. So rather than focus on making a perfect extraction method (though refinements are always good!), we need to come up with a good/reasonable normalization procedure.

Here are (my) desiderata of a good normalization procedure:

Leaving aside the problem of forcing non-negativity (can we just apply softplus or rectification?) this suggests we do something like this. For each cell on each day:

The idea behind using the logistic function is that we can have a soft threshold on the SNRs we consider to be "real" vs. "noise"

forea commented 7 years ago

This seems reasonable to me.

How do we find "reasonable values" for slope k and midpoint x0?

ahwillia commented 7 years ago

x0=1 and k=10 seem in the right ballpark to me. Top panel is pre-normalization, bottom panel is post-normalization:

image

However, I want to keep playing with this to fix drifting baselines...

image

ahwillia commented 7 years ago

A simpler solution:

image

kimtonyhyun commented 7 years ago

Can we experimentally test this?

We can do this, but we will likely have to procure a new animal. We can put this on a low priority track.

I'd like to change the focus of this discussion a little bit if that is alright. Correct me if I'm wrong, but cells at different depths in the field of view would be expected to have different measured amplitudes due to light scattering (even if they actually had identical activity).

This suggests to me that - even in the best case scenario of a perfect extraction method - the amplitude of the fluorescence signal is not really that informative to the function of the biological circuit. So rather than focus on making a perfect extraction method (though refinements are always good!), we need to come up with a good/reasonable normalization procedure.

Agreed. Unless the above experimental validation shows otherwise (which is probably highly unlikely) we should consider amplitudes to be arbitrary on each session. Even if the experimental validation were to show that amplitudes could be consistent, there's no guarantees with regards to the existing prefrontal data.

So, I agree that the right course of action is to come up with a good and validated normalization procedure.

ahwillia commented 7 years ago

We can put this on a low priority track.

Agreed 👍 😃