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

We're trying to create a script that automatically creates trial off-sets of the same duration (always 30 sec) from the trial on-sets we have already coded. We've come up with a pretty rudimentary variation on a script from the Datavyu pre-conference to SRCD, but we can't seem to figure out how to make it handle all 10 trials on our sample video. Eventually we'd like it to be flexible enough to handle any number of trials. This is probably painfully simple and we are just missing it - please help! Anyhow here is our non-functional script (Trial = column of on-set codes):

verbose = 1

time_to_add = 30

begin

time_to_add_ms = time_to_add * 1000

puts "Starting script..." if verbose > 0

puts "Getting cells" Trial_var = getColumn("Trial") first_cell = Trial_var.cells[0] second_cell = Trial_var.cells[-8] third_cell = Trial_var.cells[-7] fourth_cell = Trial_var.cells[-6] fifth_cell = Trial_var.cells[-5] sixth_cell = Trial_var.cell[-4] seventh_cell = Trial_var.cell[-3] eighth_cell = Trial_var.cell[-2] last_cell = Trial_var.cells[-1]

puts "Changing cells" first_cell.change_arg("offset", first_cell.onset + time_to_add_ms) second_cell.change_arg("offset", second_cell.onset + time_to_add_ms) third_cell.change_arg("offset", third_cell.onset + time_to_add_ms) fourth_cell.change_arg("offset", fourth_cell.onset + time_to_add_ms) fifth_cell.change_arg("offset", fifth_cell.onset + time_to_add_ms) sixth_cell.change_arg("offset", sixth_cell.onset + time_to_add_ms) seventh_cell.change_arg("offset", seventh_cell.onset + time_to_add_ms) eighth_cell.change_arg("offset", eighth_cell.onset + time_to_add_ms) last_cell.change_arg("offset", last_cell.onset + time_to_add_ms)

setColumn("newTrial", Trial_var)

rescue StandardError => e puts e.message puts e.backtrace end

asked 02 Apr '15, 12:06

LearningLab's gravatar image

LearningLab
1222
accept rate: 0%


the idea is to write a loop that just goes through however many cells you have in the trial column. everything else is the same:

begin

verbose = 1
time_to_add = 30
time_to_add_ms = time_to_add * 1000

puts "Starting script..." if verbose > 0

Trial_var = getColumn("Trial")

# this loops through however many cells are in the trial column, instead of manually setting each cell
for currentcell in Trial_var.cells
  currentcell.change_arg("offset", currentcell.onset + time_to_add_ms)
end

setColumn("newTrial", Trial_var)

rescue StandardError => e 
puts e.message 
puts e.backtrace

end
permanent link

answered 02 Apr '15, 12:24

GladysChan's gravatar image

GladysChan ♦♦
164116
accept rate: 0%

Thanks for the script! Unfortunately it doesn't seem to be working for us. We ran the script you sent us, and received the follow script message:


Running Script: TouchyPics.Add30secToOnset.rb on project: scripts_testrun


Starting script... undefined method getColumn' for main:Object <script>:9:in(root)'

Script completed successfully.

However, a new column was not added into the Datavyu spreadsheet. I'm not sure what could be wrong. Do you have any idea?

permanent link

answered 02 Apr '15, 14:56

LearningLab's gravatar image

LearningLab
1222
accept rate: 0%

You have to include the following line at the beginning of every script, and once you do it should be fine. Let me know if it still throws an error:

require 'Datavyu_API.rb'

permanent link

answered 02 Apr '15, 15:42

GladysChan's gravatar image

GladysChan ♦♦
164116
accept rate: 0%

edited 02 Apr '15, 15:43

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:

×3

question asked: 02 Apr '15, 12:06

question was seen: 3,812 times

last updated: 02 Apr '15, 15:43

powered by OSQA