Announcing the new Datavyu v1.3.6 with enhanced features and transcription support!

Hello There,

I have altered the data export script in the tutorials (http://datavyu.org/user-guide/api/tutorials/export-data-using-scripts.html) for my own needs however there are some additional things that I want to achieve with an initial export and I am sure that other members have found a way to accomplish it. I have looked around on the internet but I am still wondering if there is a simple line(s) of code that I can add so that the columns of my data set have titles of my choosing?

In addition to coding the onset and offset of particular events, I am also coding where (and for how long) a participant is looking at specific locations during these events. Is there a template or instructions for how to export quick summaries of both the frequency (count) and average time spent looking at a particular location during an event?

In general, the code from the tutorial exports data in "long format" which is useful, but I would like to easily convert this to a "wide format" that contains summary statistics for each participant (but will start with a single participant to make sure that the script is operating correctly).

If it is helpful, I can send my spreadsheet and ruby code that I have written, although I am not seeing how to place an attachment here...

Any help is greatly appreciated!

asked 26 Jun '15, 13:19

bfterrizzi's gravatar image

bfterrizzi
16114
accept rate: 0%


Hi,

The easiest way to add headings is to simply put in a write command to your output file. For example, you could create your heading string using:

heading = "Heading1\tHeading2\Heading3\n"

Then write this out to your output file variable (named out_file in the tutorial) using

out_file.write(heading)

Note that "\t" adds a tab between each heading and the "\n" at the end terminates the line.

As for the "wide format", the Ruby API does not currently provide builtin functions for directly calculating summary statistics. It's definitely possible to use a script to print in the format you specify — however, this requires that you write the operations for calculating the summary statistics. Please see the API reference for reading data from Datavyu columns and cells : link to API reference page

For example, if you have a column called looks with a single code location which can have values a, b, or c then the following code will calculate the frequencies and duration for each location code:


colLooks = getVariable('looks')

# initialize frequencies for each code to 0
frequencies = {
  "a" =>  0,
  "b" =>  0,
  "c" =>  0
}

# initialize durations for each code to 0
durations = {
  "a" =>  0,
  "b" =>  0,
  "c" =>  0
}

# Go through list of cells to accumulate freq. and dur.
for cell in colLooks.cells
  frequencies[cell.location] += 1
  durations[cell.location] += (cell.offset-cell.onset)
end

You can then print the look frequency for location a with out_file.write(frequencies["a"])

Alternatively, if you are able to export the data already (e.g. using the nested cells approach in the exporting tutorial) you can import the data into statistics software (our lab uses SPSS and R) to compute the summaries more easily.

permanent link

answered 26 Jun '15, 16:45

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
381126
accept rate: 11%

Thank You,

Having these steps explained was very helpful!

permanent link

answered 28 Jun '15, 10:53

bfterrizzi's gravatar image

bfterrizzi
16114
accept rate: 0%

Hi!

I have datavyu spreadsheet with one code, which could be 1-6. I tried to adjust this script to get summary statistics, but I get the following script error:

NoMethodError: undefined method `location' for #<rcell:0x1c1c50a> method_missing at org/jruby/RubyBasicObject.java:1535 method_missing at file:/C:/Users/..../Datavyu/app/datavyu-1.3.4-jfx.jar!/Datavyu_API.rb:313 (root) at <script>:43 each at org/jruby/RubyArray.java:1613 (root) at <script>:42

See line 42 of \soliscom.uu.nl\uu\Users....\My Documents\Desktop\launcher.rb: for cell in col.cells See line 43 of \soliscom.uu.nl\uu\Users....\My Documents\Desktop\launcher.rb: frequencies[cell.location] += 1

require 'Datavyu_API.rb'
out_file = File.expand_path("~/Desktop/DataOutput.txt")
out = File.new(out_file,'w')
col = getColumn("code")
frequencies = {
  "1" =>  0,
  "2" =>  0,
  "3" =>  0,
  "4" =>  0,
  "5" =>  0,
  "6" =>  0
}
durations = {
"1" =>   0,
  "2" =>  0,
  "3" =>  0,
  "4" =>  0,
  "5" =>  0,
  "6" =>  0
}
for cell in col.cells
  frequencies[cell.location] += 1
  durations[cell.location] += (cell.offset-cell.onset)
end
out_file.write(durations["4"])
end
permanent link

answered 20 Jul, 10:10

sanne's gravatar image

sanne
11223
accept rate: 0%

You need to change the cell.location to reflect the name of the code in your spreadsheet. In the example I provided above, the name of the code was "location". So if your code is called "score", cell.location needs to be changed to cell.score

(20 Jul, 11:45) 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:

×46
×24
×11
×10
×10

question asked: 26 Jun '15, 13:19

question was seen: 6,460 times

last updated: 20 Jul, 11:45

powered by OSQA