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

Hi everyone. I'm very new to Ruby and I have a question about getting all argument values from a cell.

I have two quasi nested variables in that a majority of the level 2 cells (smaller cells) are contained within the level 1 cells (larger cells), but sometimes the level 2 offset cells might extend beyond the corresponding level 1 offset. I currently have something setup (I hope) that splits the cells accordingly and adjusts the onset/offset times but I need a way to fill in the arguments for the new cells created.

What I want to know is how can I get all argument information from one cell and copy that information to another cell? I can type of the names of each individual argument and change the values but I might have many arguments in a cell.

Also if you notice something I might have overlooked during the splitting of overlapping cells please let me know.

I have copied some code that will create two .opf files. One with overlapping cells and one with the split cells but unfilled arguments.


require 'OpenSHAPA_API.rb'

begin

  #Some path stuff (change if you don't like your desktop)
  pathLocation = File.expand_path("~/Desktop")
  db1 = pathLocation+"/DB1.opf"
  db2 = pathLocation+"/DB2.opf"

  #Create 2 new variables
  var1 = createNewVariable("var1","arg1","arg2")
  for i in 0..4
    v1Cell = var1.make_new_cell()
    v1Cell.change_arg("onset",i*1000)
    v1Cell.change_arg("offset",v1Cell.onset+999)
    v1Cell.change_arg("arg1",i.to_i)
    v1Cell.change_arg("arg2",(i+1).to_i)
  end
  setVariable("var1",var1)

  var2 = createNewVariable("var2","arg1","arg2")
  for i in 0..9
    v2Cell = var2.make_new_cell()
    v2Cell.change_arg("onset",(i*500)+17)
    v2Cell.change_arg("offset",v2Cell.onset+500)
    v2Cell.change_arg("arg1",i.to_i)
    v2Cell.change_arg("arg2",(i+1).to_i)
  end
  setVariable("var2",var2)

  #Save original database
  save_db(db1)

  #Start looping through level 1 and level 2 cells
  for v1_i in var1.cells
    for v2_j in var2.cells
      #Find level 2 cells that start at current Level 1 cell but bleed into next Level 1 cell
      #Split the cell at Level 1 offset
      #Create new cell with remaining time after split
      #Figure out how to get and copy all arguments to new cell!
      if v2_j.onset < v1_i.offset and v2_j.offset > v1_i.offset
        oldCell = v2_j
        newCell = var2.make_new_cell()
        newCell.change_arg("onset",v1_i.offset+1)
        newCell.change_arg("offset",oldCell.offset)
        oldCell.change_arg("offset",v1_i.offset)
      end
    end
  end

  #sort added cells and set them to openSHAPA
  var2.sort_cells()
  setVariable("var2",var2)

  #save split database
  save_db(db2)
end

asked 09 May '12, 13:38

jmburling's gravatar image

jmburling
1266613
accept rate: 0%

It's hard to tell just from looking at the script. Is some part of it working? Do some cells but not others copy to the second database?

(10 May '12, 06:11) JohnFranchak ♦ JohnFranchak's gravatar image

So far I don't seem to have issues with the cells being split and copied to the second database. My issue is mainly with the new cells that are copied. They currently don't have any arguments. I was looking for a way to extract all arguments from a cell and place these values into a new blank cell.

(10 May '12, 06:22) jmburling jmburling's gravatar image
Be the first one to answer this question!
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:

×18
×6
×2

question asked: 09 May '12, 13:38

question was seen: 1,833 times

last updated: 10 May '12, 06:22

powered by OSQA