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

I am a complete Datavyu and Ruby novice, so it is possible this is a wholly elementary issue....

I am coding videos of mother-child dyads. I am trying to develop a script that will generate a spreadsheet for each dyad (one dyad per video), with a column for mom and a column for child, and multiple codes within each column. I want to code in 10 second intervals. The videos themselves vary in length, some being 15m on the nose and some being slightly longer, so the script needs to accommodate that the number of potential 10s intervals varies by video.

Right now, my script runs but generates a spreadsheet with a few issues:

  1. there are no offset times (probably I have a basic mistake in my script? how do I tell it to set the offset?)
  2. it generates 121 intervals regardless of the video length -- is there a way to cut it off from making new intervals after the video ends or do extra intervals need to be removed manually?
  3. the intervals in the mom and child columns sometimes do not align, they are offset by 30 seconds. sometimes this goes away on its own when I click on the spreadsheet...any rhyme or reason why that might be happening?

Thank you for any assistance!

Here is the script:

require 'Datavyu_API.rb'
begin
    mom = createColumn("mom", "praise", "critique")
    for i in 0..120
        time = i * 1000 * 10
        cell = mom.make_new_cell()
        cell.change_code("onset", time)
    end 
    setColumn(mom)
        child = createColumn("child", "persist", "quit")
    for i in 0..120
        time = i * 1000 * 10
        cell = child.make_new_cell()
        cell.change_code("onset", time)
    end
    setColumn(child)
end

asked 25 Sep '15, 15:25

emilyfcoyle's gravatar image

emilyfcoyle
11114
accept rate: 0%


Hi,

1) You have to set the offset value of cells to some new value; otherwise they'll default to 0. For example: cell.change_code("offset", time+10*1000) or cell.offset = time + 10*1000 to set the offset 10 seconds after the onset.

2) The easiest way to accomplish this would be to create a column and manually add a cell that spans the region in which this script will create the cells. If let's say you call that column 'session', you could use :

cellSession = getVariable('session').cells.first start = cellSession.onset stop = cellSession.offset for time in (start..stop).step(10 * 1000) code to create cell here end

3) This is odd. Do you have a sample file where this shows up that you could send to us?

permanent link

answered 29 Sep '15, 12:24

Shohan%20Hasan's gravatar image

Shohan Hasan ♦♦
381126
accept rate: 11%

Thank you for your help! I'm still hung up on part 2 -- I understood your instructions to mean to manually create the Session column in Datavyu and then add this piece of script before the rest of my script to set-up the spreadsheet but I'm realizing that may not be correct. Here is what I have:

require 'Datavyu_API.rb'
begin
cellSession = getVariable('session').cells.first
start = cellSession.onset
stop = cellSession.offset
for time in (start..stop).step(10 * 1000)
    mom = createColumn("mom", "praise", "critique")
    for i in 0..108
        time = i * 1000 * 10
        cell = mom.make_new_cell()
        cell.change_code("onset", time)
        cell.change_code("offset", time+10*1000)
    end 
    setColumn(mom)
        child = createColumn("child", "persist", "quit")
    for i in 0..108
        time = i * 1000 * 10
        cell = child.make_new_cell()
        cell.change_code("onset", time)
        cell.change_code("offset", time+10*1000)
    end
    setColumn(child)
end
end

Re: #3, I think I have that resolved. Thanks!

permanent link

answered 05 Oct '15, 12:51

emilyfcoyle's gravatar image

emilyfcoyle
11114
accept rate: 0%

I should add -- the error I get when I run this is:

** SCRIPT ERROR **

NoMethodError: undefined method `onset' for nil:NilClass (root) at <script>:4

See line 4 of C:\Users\coyleef\Google Drive\Coyle Lab\EFC Testing Datavyu\Testing3.rb: start = cellSession.onset


(05 Oct '15, 12:53) emilyfcoyle emilyfcoyle's gravatar image

Did you also create the cell in the session column? You should create a single cell whose onset is the first time you want to create a cell and whose offset is the end of the video.

Also, the script is a bit wonky at the moment. I think you want to move the createColumn and setColumn outside of the loop. The for-loop I included should compute your onset times as well, so you do not need the additional for-loops inside.

(09 Oct '15, 10:38) 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:

×4
×3
×3

question asked: 25 Sep '15, 15:25

question was seen: 2,528 times

last updated: 09 Oct '15, 10:38

powered by OSQA