@freeman-lab path to tuning arrays: '/tier2/ahrens/davis/data/spark/4dpf_gfap_gc6f_tdT_huc_h2b_gc6f_ori_1_20150130_190839/mat/tmp.npz'

code for loading:

```
tmp = np.load(matDirs[curExp] + 'tmp.npz')
betaMat = tmp['arr_0']
statsMat = tmp['arr_1']
tuneMat = tmp['arr_2']
```

ah yes and substitute

`'/tier2/ahrens/davis/data/spark/4dpf_gfap_gc6f_tdT_huc_h2b_gc6f_ori_1_20150130_190839/mat/tmp.npz'`

for

`matDirs[curExp] + 'tmp.npz'`

@freeman-lab any idea how the output of

`series.dims`

could be negative?
calling this on the text data you directed me to returns funny values for dims:

```
imDat = tsc.loadSeries(serDirs[curExp],inputFormat='Text')
imDat.dims
...
Dimensions(values=[(1, 1, 1, -3730, -4403, -3634, -3646, -3999, -4443, -3641, -3523, -2914, -3205, -4161, -3521, -4404, -3483, -3486, -3344, -3628, -3343, -3282, -3180, -3438, -3148, -4133, -3497, -3681, -3452, -3553, -3197, -3150, -3562, -3364, -4025, -3119, -3772,... (many more)
```

it's not binary so you need to specify that manually

as for the values... i think this may be dff after some weird transformation

some rescsaling or something

if you compute the mean of a single plane, is it at all interpretable?

oh yeah, exactly

without the nKeys, the values will be the keys

yeah I'm looking at a single plane now, much much much sharper that what I normally collect

I took the time average

average of dff should be 0?

or maybe it's raw f?

if it's with a percentile, yes

agreed

but yes, much sharper, however these values were computed

yup, that's what i would have expected

ok, cool to know that can still be loaded!

that was the first data set we ever ingested into spark =)

how old was this fish?

misha would know

if you have a png on disk somewhere you should be able to drop it in

but the notebook will be in my notebooks folder titled

`view-series.npb`

k cool

yeah it is striking how much better this looks than what I collect

so this is with two light sheets, so to properly compare to our system you gotta only look at half

but each half has uniform image quality across the volume

i thought it was just the side

dunno, i guess whatever was in the 2013 nat methods paper

@nvladimus do you have data from our scope that look as sharp as the image above? That's an average of 1000 time points from plane 25/41 from the fish used in the Ahrens Keller nature methods paper

@freeman-lab I have Illustrator up and running on my machine at the moment. Want to see if you can open it as well?

sorry, @jwittenbach seems fine!

So I thought I might share some results from a new analysis that are hot off the press:

the idea is to replace the mean activity of each neuron with the mean activity of that neuron as well as it's k nearest neighbors

Here is correlating mean neural activity to mean swimming strength across multiple closed-loop trials of OMR (red = positive correlation, blue = negative correlation, only correlations with absolute value > 0.3 shown)

Now here's the same thing, with the the only difference being the nearest-neighbor replacement mentioned above (k=30)

I'm digging it :smiley_cat:

seems cool! so i understand, every circle represents the correlation between

`x`

and `y`

, where `x`

is the average of that neuron and its k-nearest neighbors and `y`

is the behavior
and this is different from just computing the correlation and then averaging between correlation is non-linear

i.e. the map below is not a blurred version of the map above

Let me think about this...

1: I actually started by replacing each neurons dF/F time series with the average dF/F of it's kNN. Then I averaged over time. But average across neurons and*then* over time (what I did) should be equivalent to averaging over time and then over neurons (what you describe)

1: I actually started by replacing each neurons dF/F time series with the average dF/F of it's kNN. Then I averaged over time. But average across neurons and

ah, you're not correlating, you're just averaging over different blocks

2: Is computing the correlation non-linear? If so, then yes, that makes it different from some form of simple blurring (only defined over neighbors, rather than space)

no, I am correlating

I do what I just described in each trial

and then correlate activity with behavior, using the different trials as the data

I should be more clear:

Step 1: replace each neuron's time series with the average time series of its kNN

Step 2: for each of these new series, average the activity within each trial

Step 3: compute the correlation between that average activity and average swimming strength, across trials

Step 1: replace each neuron's time series with the average time series of its kNN

Step 2: for each of these new series, average the activity within each trial

Step 3: compute the correlation between that average activity and average swimming strength, across trials

ok, so if you just did 1 + 2, it'd be the same as blurring the raw data and computing trial-averaged activity

blurring in space

but i'm pretty sure step 3 is where it matters

correlation is normalized by variance, which is very non-linear

if you beat down the noise by averaging, and then compute correlations, they can be cleaner than if you compute a bunch of noisy correlations and average them

Non-linearity comes from 3 possible sources:

1: it's blurring in "neighbor space" rather than euclidean space

2: computing corr coef is non-linear

3: thresholding before vs after averaging is some kind of non-linear

1: it's blurring in "neighbor space" rather than euclidean space

2: computing corr coef is non-linear

3: thresholding before vs after averaging is some kind of non-linear

you trade spatial acuity (in 'neighbor-space') for SNR via averaging before correlating

and acuity in neighbor-space might preserve the topology better than in euclidean space

though there are advantages to both

cool!

I plan to implement the euclidean version too

so this is actually data from the second half of the initial high-gain training phase in Takashi's experiment

correlating the activity during that phase with the swimming during that phase

Raphe shows up rather clearly

and there's nothing memory-related about this methinks

*negative correlation

seems reasonable to me

did you grab its time series?

Oops, sorry, actually low-gain phase. but still, same idea

Ah nope, not yet

I should do that

I can just pull out the coordinates from this map pretty easily and use Jascha's new functions

Side note: There are a pair of bilateral regions that are also negatively correlated with swimming that this analysis also pulls out fairly strongly. They're super lateral and about at the same ros/caud level as Raphe

@jwittenbach just asked tk about this, he says that he interprets those cells to be neurons in the ventral part of the optic tectum, i.e. neurons involved in vision

During OMR, I guess the stimulus and the swimming are pretty tightly linked. Which would explain why visual cells show up.

Though, during closed loop, the interpretation is a little unclear, since the fish ostensibly swims to cancel the external motion.

yeah it's hard to say as a rule what the fish is seeing during closed loop, although we do save the stimulus velocity to disk...

I guess it's probably unclear during open loop as well, as any efference copy from the motor system might still be sent to the visual system.

@freeman-lab : so it's not entirely clear that this analysis is doing a lot of nonlinear processing

here is what you get if average the neural activity by neighborhood and then calculate the correlation with the swimming (showing only the negative correlations to make it easier to see)

And this is what you get if you compute the correlations first, and then subsequently average over the neighborhoods:

One thing to note is that these colors are scaled to the maximum correlation

The coer coeffs are, on average, smaller when you do the "blurring"

which makes sense

it might be that doing the neighborhood analysis first gets a little "spatial" contrast boost

i.e. you can tell which of the neurons are really contributing to the local signal

which does play a role if you take a threshold after doing one of these analyses

right, my take is that we're not gaining a huge amount here, but very well could for more complex analyses

and clearly we're gaining something

what's the difference in the max?

the max correlation

This is only for the negative correlations, so it matches what you see in those plots

holy smokes

forgot this interprets Markdown

max(corr) = .36; mean(corr) = .07

average then correlate:

max(corr) = 0.61, mean(corr) = .14

ok, so clearly it makes a difference

which is great

means the SNR is doing the right thing

but doesn't dramatically change the spatial structure

though I think one thing it would change would be the results after thresholding

if you compare those two plots

and ask yourself which pieces would remain after thresholding at a certain color

in one case Raphe comes out pretty much by itself

(that case being correlate then average)

but in the other case

(average then correlate)

other pieces would come out at the same "level"