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

I'm analyzing the behavior of an animal that's in an arena that is half black and half white. I record each time the animal crosses from the white side to the black side, and from the black side to the white side. My spreadsheet has two columns: cross to white and cross to black, and the time of the crossing is recorded in each cell. For example, the animal crossed to the black side at 00:00:38:608 and then crossed to the white side at 00:01:14:599. Thus, he spent approximately 37 seconds on the black side.

I would like to calculate the total amount of time spent in the white and black halves of the arena, as well as the duration of each stay in the white or black half. How can I do this?

asked 10 Jun '13, 15:35

Della's gravatar image

Della
1112
accept rate: 0%


The way that I would recommend to do this is to use a Ruby script to export the raw data from the file to either Excel or SPSS. Then you can subtract the onset from the offset and divide by 1000 to convert milliseconds to seconds. This will give the duration of each event, which can then be summed, averaged, etc. across trials and/or across subjects.

If you need help with the export script, I can provide a sample script to work from.

permanent link

answered 11 Jun '13, 16:54

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

Actually, the black column and the white column would need to be combined into a single column before the data could exported. To have the Ruby script export everything correctly there cannot be uncoded time that doesn't match between the columns. This would be an extra step in the script.

Depending on how much you have coded, I would suggest making a change. Rather than tagging the time of each crossing in a separate column for each, the easiest way for both the coder and exporting would be to code everything in one column. The coder marks cell onset when the animal is on the white side and sets "w" in the argument for that cell. The coder keeps that cell going until the animal crosses to the black side. When the coder sees the crossing, they can pause and use the 0 key to create a new cell in the column. This will automatically set the offset of the "w" cell, set the onset of the new cell, and they can then code "b" in the new cell's argument. Again, keeping that cell going until the animal crosses back to the white side, hitting 0 to set the cell offset and create a new cell.

That way a continuous series of Ws and Bs is coded with the onset being when the crossing took place and the offset just being 1 ms before the next cell's onset. This is how I have coded infant look (left/right looking) and is very efficient. It then allows you to pull out the frequency of switches, the total duration spent in each, etc.

If you want to try to go ahead with the initial way let us know and someone can try to help with the script.

permanent link

answered 14 Jun '13, 10:21

KCSoska's gravatar image

KCSoska ♦
2363
accept rate: 17%

Thank you. I would definitely appreciate a sample script. I have basically no coding experience, so any little bit helps.

permanent link

answered 11 Jun '13, 17:35

Della's gravatar image

Della
1112
accept rate: 0%

So, I've arranged my data so that each cell has an onset and offset, but there are still two columns, one for time in the white side and one for time in the black side. The offset time for one cell is the onset time for the next cell, so each cell represents the duration of time on either the black or white side.

Assuming this in an appropriate format, could you give me some help writing the script for exporting these data to excel?

permanent link

answered 17 Jun '13, 18:20

Della's gravatar image

Della
1112
accept rate: 0%

If the only information that you need is the total duration of time spent in the white and black areas then the best course of action actually doesn't require a script. You can open your file and "save as" it as a .csv file. You can open that file up with Excel and it should contain all of the onsets and offsets for the time spent in each area. You can then subtract the offsets from the onsets to create a duration for each cell and then sum those durations across the white and black areas to find the duration of time spent in each.

If you would like to perform more involved analyses then you'll need a couple of scripts. The way that the data is laid out would require a script that would add an argument to each of the variables (columns) to denote which variable had which onset and offset. It would also need to create a mutually exclusive variable so that the information from both columns was in one column. You would then be able to use a simple print script to export the data into a text file.

If you plan on doing additional coding I would strongly suggest following the format that Kasey suggested above. Having all of the information in one column would be easier to code and easier to export (it would only need a print script).

permanent link

answered 19 Jun '13, 12:49

david's gravatar image

david ♦
143235
accept rate: 4%

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
×6

question asked: 10 Jun '13, 15:35

question was seen: 5,081 times

last updated: 19 Jun '13, 12:49

powered by OSQA