-
Notifications
You must be signed in to change notification settings - Fork 89
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
Problems understanding how to generate firingRates array (MATLAB) #44
Comments
Dear Eduardo, it's been a while since I worked with Matlab... In Python this would look something like this: import numpy as np
X = np.random.randn(30, 60, 135)
S = np.random.randint(2, size=135)
D = np.random.randint(2, size=135)
firingRates = np.zeros((30, 2, 2, 60, 135)) * np.nan
maxTrialNum = 0
for s in (0, 1):
for d in (0, 1):
trials = (S == s) & (D == d)
firingRates[:, s, t, :, :np.sum(trials)] = X[:, :, trials]
if np.sum(trials) > maxTrialNum:
maxTrialNum = np.sum(trials)
firingRates = firingRates[:, :, :, :, :maxTrialNum] Does this help? |
Dear dkobak, thanks a lot for the help and sorry for the late reply. Yes that was very helpful and I was able to run the analysis. I have one more question. Can I combinedata from different imaging sessions from different neurons in this analysis? An example: Day1: would the resulting firingRates be a 70x2x2x60xmaxTrialNum where some of the values in the 1D (70 neurons =42neurons[day1]+28neurons[day2]) are NaNs depending if it is data from the corresponding session or not? Cheers, |
Yes you can combine data from different sessions. All datasets analyzed in our eLife paper were constructed like that (from recordings obtained over many sessions). You have two arrays, |
yes, thanks, thats what I just figured out. I wrote a MATLAB function to do these steps and generate firingRates and trialNum. Let me know if you are interested. Thanks a lot again, |
Dear Dmitry,
thanks for the code and the elife paper on dPCA. I am trying to get started with it for my data set, however I struggle in understanding how to generate the firingRates matrix (despite looking through the demo)
Lets say I have:
N= 30 neurons;
T= A trial length of 60 data points
maxTrialNum= 135.
So e.g. this is represented as a 3D 30x60x135 matrix already in my data structure.
And then I have two different conditions (S) and two different Decisions (D) in my behaviour which are represented as two different 1D 135x1 arrays (with 0 and 1 for right/left stimuli/decisions).
I struggle wrapping my head around how to produce from this your
firingRates: N x S x D x T x maxTrialNum
data structure to get started with the dPCA (should it end up being a 30x2x2x60x135 array?). I guess my head stops working at 3 dimensions.
Anyhow thanks a lot for the tool and have a nice weekend,
Eduardo
The text was updated successfully, but these errors were encountered: