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

Hi,

We are having difficulty with our script that outputs raw data; it's skipping slides, looks, and is outputting incorrect times. In the example we have attached for instance, column 6 represents slide number. You can see that slides 1, 6, 8, etc. are not included. Additionally, column 9 represents the "look" cells and again 1,4,5 etc. The times represented in columns 10 and 11 also seem to be mostly random. In an effort to conserve space we have not included our script, but please let us know if you need it.

link text

asked 14 Aug '13, 16:06

Lakusta%20Lab's gravatar image

Lakusta Lab
71121214
accept rate: 0%


Can you please upload a copy of one of the opf you are trying to export and the export script? (I have given your account additional karma points so you can upload them right to the forum.) Since I wrote these scripts, I can quickly run them on my end to replicate the problem.

permanent link

answered 15 Aug '13, 12:49

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

The numbers in columns 10 and 11 are the onset and offset of each cell in milliseconds (a conversion of the hours:minutes:seconds:milliseconds presentation in the spreadsheet). You can subtract the offset from the onset and divide by thousands to get the duration of that cell/event in seconds.

permanent link

answered 16 Aug '13, 11:21

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

The issue doesn't seem to be with the script but with how the data are coded into the spreadsheet. In order to use the script as it is currently written, every event in the Look variable needs to be completed nested within only one event in the Stim variable. That is, the onset of the look event must have an onset equal to or greater than the onset of the Stim event; the offset of the look event must have an offset equal to or less than the offset of the Stim event. And a single Look cell cannot span multiple Stim cells. If a Look cell has a duration that spans more than one Stim cell—even by 1 ms—the script doesn't know which Stim cell to bind it to (and it can only bind it to one cell) and won't be exported.

For example, for the Stim cell coded as related to slide 1 (cells #1 and #2 in the Stim column), there is only a single look event coded, with a duration that spans both Stim cells. The offset of that look is greater than the offset of Stim cell #1 and the onset of that look is less than the onset of Stim cell #2—one Look cell cannot be linked to 2 Stim cells and so nothing is exported.

For Slide 2, Look#4 would not export because it's onset is less than the onset of the Stim#4. But Looks#2 and #3 would export.

Similarly, for slide 6 (Stim cells# 11-13), the first Look event (cell#20) has an offset that is greater than the offset of the first Stim cell (by about 450 ms). So that look is not bound within a Stim cell and wouldn't export. The next Look event (cell#21) spans both cells #12 and #13 in Stim, and again would not be exported.

Similar issues would affect exporting of Look#4, Look#5, Look#10, Look#28, Look#29, Look#31, Look#35, Look#39, Look#40, Look#44, Look#45, Look#52, Look#54, Look#58, Look#59, Look#60, Look#65, Look#69, Look#72, Look#75, Look#77, Look#82, Look#84, Look#85, Look#92, Look#95, Look#100, Look#104, Look#106, Look#113, Look#119, Look#121, Look#122, Look#127, Look#129, Look#130.

In order to use this export script as written, Look cells need to be completely bound by Stim cells. Even if the participant keeps the same look direction, when a new cell in Stim starts, the Look cell needs to end (with an offset that is equal to the offset of the Stim cell). And then a new Look cell starts with the onset of the next Stim cell, keeping its same direction code.

It is possible to deal with the data as they are currently coded, but a new export script using mutually exclusive cell creation would need to be written.

permanent link

answered 16 Aug '13, 11:46

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

edited 16 Aug '13, 11:54

Right. Basically, in order to get one row per look to export properly (with each look related to some Stim cell), there needs to be a nested structure for the data. So every Stim cell is nested within the Subject Info cell. And every Look cell is nested within a Stim cell. There can be multiple Stim cells bound by the onset/offset of Subject Info, and there can be multiple Look cells bound by the onset/offset of Stim cells. But it cannot be the other way around as well (multiple Stim cells bound by a Look cell). Each cell is treated as a single event.

The spreadsheet database has no inherent way to know what is related to what. It just knows it has a X many cells with ordinals, onsets, offsets, and arguments in it. The user has to define how they are related in a script (this can be based on ordinal, onset, offset, or some combination of arguments). And the conditions for linking cells is mutually exclusive: for example, either Look is bound within Stim onset/offset, or Stim is bound within Look onset/offset; both cannot be true.

Even though several Stim cells might be coded continuously and Look cells coded continuously, the important thing is the relation between them. The onset or offset of a Look cell cannot extend beyond the onset/offset of the Stim cell you want to link it to (based on the criteria defined in the FOR loop part of the script). The suggestion to do continuous coding is more for coding efficiency (the coder only needs to press the 0 button), and because the events are actually happening continuously.

permanent link

answered 16 Aug '13, 13:14

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

User comment moved from "uploading opf file question":

Below is the link to the uploaded files. It includes both the opf file and the user editable section of the script. I have also copied and pasted the script below if that is easier for you. Thank you.

http://www.sendspace.com/filegroup/V6kdB5Tu4iBmKgtAoSW5rA


begin

# Define directory where all of the files you want to export are. # Usually copy them to this location rather than run on original directory in case of problems. filedir = "/Users/lakustal/Desktop/" # Define Ruby variable for each opf file. filenames = Dir.new(filedir).entries

# Loop over all files in the directory for file in filenames # Only pull opf files and no others if file.include?(".opf")

  # Load files one at a time
  puts "LOADING DATABASE: " + filedir+file
  $db,proj = load_db(filedir+file)
  puts "SUCCESSFULLY LOADED"

  # Define Ruby variables for each of the variables/columns we want to get data from to export
  sub = getVariable("SubInfo")
  stim = getVariable("Stim")
  look = getVariable("Look")

  # Define directory where we want to export txt file to.
  printdir = File.expand_path("~/Desktop")
  # Name file we want to export data to.
  # The "a+" means every run of this script will add more data to bottom of txt file.
  out_file = File.new(printdir + "/PLPStimLook.txt", "a+")

  # Loop over all cells in subinfo
  for subcell in sub.cells
    # Loop over all cells in stim
    for stimcell in stim.cells
        # Bind each stim cell to each subinfo cell using onsets and offsets  
        # All stim cells will have onsets greater than subinfo cell onset, and offsets less than subinfo cell offset.
        if stimcell.onset >= subcell.onset and stimcell.offset <= subcell.offset
          # Loop over all look cells.
          for lookcell in look.cells
            # Bind each look cell to each stim cell using onsets and offsets  
            # All look cells will have onsets greater than or equal to their matching stim cell onset,
            # and offsets less than or equal to their matching stum cell offset.
            if lookcell.onset >= stimcell.onset and lookcell.offset <= stimcell.offset
               # Write to the outfile each of the arguments we want, separated by tab, and ending with a new line
               # Any output that would be a numeral needs to be converted to a string using .to_s
               # Onset and offset are exported as ms counts, so need to be subtracted in SPSS/Excel for durations.
               # Remove all punctuation and capitals from arguments.
               # If argument name starts with a numeral need to append underscore to front
               # So 1/2/3/4 becomes _1234, Goal/source becomes goalsource.
               out_file.syswrite (subcell.subnum.to_s + "\\t" + subcell.age.to_s + "\\t" + subcell.sex + "\\t" + subcell.cond + "\\t" + subcell.goalsource  + "\\t" + stimcell.trial.to_s +  "\\t" + stimcell.aud + "\\t" + stimcell.prep + "\\t" + lookcell.ordinal.to_s + "\\t" + lookcell.onset.to_s + "\\t" + lookcell.offset.to_s + "\\t" + lookcell._12ac + "\\n" )
            # Now count up each FOR or IF in loop through cells part and match it with an END
            end
          end
        end
    end
  end
# Now count up each FOR or IF in loop through files part and match it with an END
end

end

# Change to remind you of name and location of file you specified above. puts "Printed to ~/Desktop/PLPStimLook.txt"

Ends Ruby script

end

permanent link

answered 16 Aug '13, 11:25

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

Okay, I see. So even though the times across a full slide are continuous, they are still recognized as separate and thus the coding of the look needs to be ended when the cell ends. The fact that the next stim cell occurs immediately after (as opposed to the gap between slides) does not matter. I think that is where the disconnect was; just because cells are coded continuously in relation to the preceding cell, they are not all recognized as one "event". Correct?

permanent link

answered 16 Aug '13, 12:36

Lakusta%20Lab's gravatar image

Lakusta Lab
71121214
accept rate: 0%

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:

×11
×3

question asked: 14 Aug '13, 16:06

question was seen: 5,393 times

last updated: 16 Aug '13, 13:14

powered by OSQA