Comments (4)
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?
from dpca.
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:
N= 42 neurons;
T= A trial length of 60 data points
Trials= 48.
->42x60x48
Day2:
N= 28 neurons;
T= A trial length of 60 data points
Trials= 52.
->28x60x52
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,
Eduardo
from dpca.
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, 42 x 60 x 48
and 28 x 60 x 52
. You can rearrange both as I explained earlier, so they will become 42 x 2 x 2 x 60 x maxTrialNum1
and 28 x 2 x 2 x 60 x maxTrialNum2
. To combine, find maxTrialNum = max(maxTrialNum1, maxTrialNum2)
and pad one of the arrays with nans along the 5th dimension so that the arrays become 42 x 2 x 2 x 60 x maxTrialNum
and 28 x 2 x 2 x 60 x maxTrialNum
. Now you can concatenate along the 1st dimension, to get 70 x 2 x 2 x 60 x maxTrialNum
.
from dpca.
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,
Eduardo
from dpca.
Related Issues (20)
- (Python) Inconsistency in _randomized_dpca docstring and transform/inverse_transform HOT 2
- Unable to find vcvarsall.bat HOT 5
- Bug in fit_transform when using dpca.join method HOT 5
- installation using pip HOT 1
- Python significance analysis for multiple task parameters HOT 4
- How to get encoder, decoder matrices HOT 5
- how to use dPCA function HOT 4
- unable to install dPCA on Mac HOT 1
- Two questions of analysing the olfactory task in your elife paper HOT 1
- Problems with array shape when running dPCA in Python HOT 11
- the sum of explained_variance_ratio_ is not 1 in python HOT 4
- How to get noise component?
- Merging components before fitting
- Number of marginalizations seems off HOT 1
- octave run dpca_demo.m in colab
- Getting "Buffer dtype mismatch, expected 'long' but got 'long long'" when doing significance analysis
- Grouping marginalizations in Python
- TypeError: Wrong type for labels. Please either set labels to the number of variables or provide the axis labels as a single string of characters (like "ts" for time and stimulus) HOT 1
- ‘re-balancing’ or not
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dpca.