Skip to content

Normalization per trial? #3

@davidgwyrick

Description

@davidgwyrick

Hello @DishengTang again! So I was revisiting this code for another project I'm working on and noticed that you calculate the normalization for each neuron pair per trial. In calculate_ccg_pair_single_trial() you divide by the triangle function and the firing_rates for that trial, but in the original formulation by Xiaoxuan Jia and in your own paper methods, the CCG between a pair of neurons is defined using the average firing rate. I don't think these are equivalent given how you're adding the CCG values across trials.

You could calculate the normalization for each pair in calculate_mean_ccg_corrected() after all the trials have been processed like this:

	# Compute firing rates for normalization
	firing_rates = np.mean(np.sum(spikeTrain,axis=2),axis=1)/ (T * self.time_bin)

	#Normalize by firing rates and triangle function
	normalization = (T - np.arange(self.window + 1)) * self.time_bin * np.sqrt(np.outer(firing_rates, firing_rates))[:, :, None]
	ccgs = np.divide(ccgs,normalization, where=normalization!=0,out=np.full(ccgs.shape,np.nan)) 
	ccg_jittered = np.divide(ccg_jittered,normalization, where=normalization!=0,out=np.full(ccg_jittered.shape,np.nan))

So in calculate_ccg_pair_single_trial() just comment out the per trial normalization.

	px, py = padded_st1[ind_A, :], padded_st2[ind_B, :]
	shifted = as_strided(px[self.window:], shape=(self.window + 1, T + self.window),
									strides=(-px.strides[0], px.strides[0]))
	return (shifted @ py)  # / ((T - np.arange(self.window + 1)) * self.time_bin * np.sqrt(firing_rates[ind_A] * firing_rates[ind_B]))

Let me know what you think. Maybe @myhannahchoi & @jiaxx can weigh in too.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions