Hello,

I am using a MacBook Pro (Mid 2010), Mac OS 10.12 Sierra and the 1.3.4 Datavyu version. I need to code within single trials frequencies of different behaviors and latencies to perform choices. My output should be an excel file containing raws corresponding to trials and columns corresponding to frequencies (of behaviors) and durations (latencies) for each trial. Can anyone help me setting the spreadsheet and writing the script to export the data?

Many thanks

Roberta

asked 22 Oct '16, 06:04

Ransie's gravatar image

Ransie
11113
accept rate: 0%

edited 22 Oct '16, 07:12


Hello again,

I am very new to ruby, so I am having troubles in exporting my nested files. The problem is that every trial has to be divided in two interval times in which I have to code the frequencies of different behaviors. Moreover, the duration of these intervals has to be measured in seconds. Since I will have to analyze data with Statistics, my output should be like that:

Trial Duration1 Behavior1 Behavior2 Duration2 Behavior1 Behavior2

Can anyone please help setting the spreadsheet and writing the scrip to export the files in that format? How can I obtain a multiple nest with the for... in?

Many thanks,

Roberta

permanent link

answered 23 Oct '16, 05:04

Ransie's gravatar image

Ransie
11113
accept rate: 0%

I used the following script to obtain the durations:

beforechoice = getColumn("beforechoice")
   durations = {"d" => 0}
   for bccell in beforechoice.cells
   durations[bccell.dur]= (bccell.offset-bccell.onset)
    print(durations["d"])
    print "\n"

It works, but I am having troubles in exporting the data. I am using this script:

 id = getColumn("id")
  trial = getColumn("trial")
  beforechoice = getColumn("beforechoice")
  behavior = getColumn("behavior")


for idcell in id.cells
      for tcell in trial.cells
         for bccell in beforechoice.cells
           for becell in behavior.cells

            if becell.onset >= bccell.onset && becell.offset <= bccell.offset


               out.write(idcell.soggetto + "\t" + idcell.condizione + "\t" + idcell.sessione + "\t" + tcell.number + "\t" + ??? + "\t" + becell.scr + "\t" + becell.uw + "\n")
             end
end
      end
     end
  end

I would like to put the durations in place of ???. Can anyone help? Thanks

permanent link

answered 23 Oct '16, 09:02

Ransie's gravatar image

Ransie
11113
accept rate: 0%

Are these separate scripts? Can you try placing the code for printing after the code for calculating the duration and replace ??? with durations[bccell.dur]?

(25 Oct '16, 18:55) Shohan Hasan ♦♦ Shohan%20Hasan's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×2

question asked: 22 Oct '16, 06:04

question was seen: 412 times

last updated: 25 Oct '16, 18:55

Related questions

powered by OSQA