Giter Site home page Giter Site logo

Comments (4)

dkobak avatar dkobak commented on May 19, 2024

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.

maristanye avatar maristanye commented on May 19, 2024

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.

dkobak avatar dkobak commented on May 19, 2024

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.

maristanye avatar maristanye commented on May 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.