Please use our GitHub Issues page for all new support inquiries. If you need to contact us directly, please e-mail [email protected]

Hi, I'm trying to write a script that will create a new column, then create 30-second-long cells within that column. It needs to take the onset time from my ID column, make that the onset for the first column, then add new cells continuously until the offset of the ID column.

I'm pretty sure the script is going to have to loop back on itself iteratively until it reaches the offset time of the ID column.

I'm not sue how to do it, but the logic we've worked out so far is like this:

require 'Datavyu_API.rb'

begin parentrating = createColumn("ParentRating","Rating")

id = getColumn("ID") timeoffset = (60*1000) timeonset = 1 time = id.cells[0].onset

#LOOP here is where you'd make the loop start #keep doing that as long as offset of parentrating cell < offset of id

cell = parentrating.make_new_cell() cell.change_code("onset", time) cell.change_code("offset", time + timeoffset)

time = cell.offset+timeonset

#LOOP AGAIN if time < id offset #LOOP END if time >= id offset

setColumn("ParentRating", parentrating)


asked 30 Aug '16, 18:38

mmcnew's gravatar image

accept rate: 0%

You almost have it. Here's one way to do the loop:

stop_time = id.cells.first.offset # same as id.cells[0].offset
while(time < stop_time)
  cell = parentrating.make_new_cell()
  cell.onset = time # same as your line but less writing :)
  cell.offset = time + timeoffset # ^
  time = cell.offset + timeonset
permanent link

answered 30 Aug '16, 19:09

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
accept rate: 14%

Also note that your timeoffset is currently set to 60s, so the cells will have a 60s duration.

(30 Aug '16, 19:11) Shohan Hasan ♦♦ Shohan%20Hasan's gravatar image

Thank you so much!!

(08 Sep '16, 10:19) mmcnew mmcnew'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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 30 Aug '16, 18:38

question was seen: 3,693 times

last updated: 08 Sep '16, 10:19

powered by OSQA