Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:25:35+00:00 2026-05-24T21:25:35+00:00

Say that I have two conditions, ‘a’ and ‘b’. A neuron fires on average

  • 0

Say that I have two conditions, ‘a’ and ‘b’. A neuron fires on average 40 spikes / second (Hz) in condition ‘a’ and 80 spikes / second in condition ‘b’. The response to condition ‘a’ is presented 20 times and condition ‘b’ is presented 10 times, with each presentation for 1000 ms.

AB <- rbind(
    ldply( 1:20, 
        function(trial) { 
          data.frame( 
              trial=trial, 
              cond=factor('a',c('a','b')), 
              spiketime = runif(40,0,1000))
        }
    ), ldply(21:30, 
        function(trial) {
          data.frame(
              trial=trial, 
              cond=factor('b',c('a','b')), 
              spiketime = runif(80,0,1000))
        }
  )
)

A simple histogram can be plotted with:

qplot(spiketime, data=AB, geom='line',stat='bin',y=..count.., 
      xlim=c(0,1000), colour=cond, binwidth=100,xlab='Milliseconds')

However, this does not average over the presentations, and hence, the values on the y axis are about the same. I would like to plot the spiking rate (spikes/second) along the y-axis, which would show that condition ‘b’ elicits about twice as many spikes per second. The spiking rate does not increase as number of presentations increase, it just becomes less noisy. Is there a way to do this without pre-processing the dataframe AB?

In other words, can I do something along the lines of:

qplot(spiketime, data=AB, geom='line',stat='bin',
      y=..count../num_presentations*1000/binwidth, ylab='Spikes per second',
      xlim=c(0,1000), colour=cond, binwidth=100,xlab='Milliseconds')

where num_presentations would be 20 for condition ‘a’ and 10 for condition ‘b’ and 1000/binwidth would just be a constant to get the unit correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:25:36+00:00Added an answer on May 24, 2026 at 9:25 pm

    Here is a solution:

    AB$ntrial <- ifelse(AB$cond=="a", 20, 10)
    ggplot(AB, aes(spiketime, ntrial=ntrial, colour=cond)) + 
      stat_bin(aes(y=..count../ntrial*1000/100), binwidth=100, geom="line", position="identity") +
      xlim(0,1000) + 
      labs(x='Milliseconds', y="Firing rate [times/s]")
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say that I have two models- Users and Accounts. Each account can have at
Say that I have two tables like those: Employers (id, name, .... , deptId).
Say that I have two figures in matplotlib, with one plot per figure: import
I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as
Let's say we have two objects. Furthermore, let's assume that they really have no
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
Say I have two classes and have a requirement that the primary key property
Lets say I have two tables - Cat and Cat owner that are linked
Let's say I have two tables that look like this: TH TH TH TH
Let's say I have two strings like this: XABY XBAY A simple regex that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.