split durations into intervals

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

split durations into intervals

Lutz Kolburg
Hey Guys,

I would love to hear some suggestions for a problem which puzzles me for
a while:
I have some Eye-Tracking data which is already processed, so each row
represents one fixation. But now I would like to split these fixations
into intervals. The stimulus presentation was 6000ms long and I would
like to split it into 12 intervals á 500ms. The amount of time of each
fixation should be written in  the corresponding interval. As you can
see below I started writing a lot of IF statments, but I'm pretty,
pretty sure that this is not the smartest way. I tried LOOP and other
stuff, but I always failed at the point when I have to point to the
interval depending on the time when the fixation has started. An idea
would be greatly appreciated!

Some example data:

DATA LIST FREE /Fixationstartms Fixationendms.
BEGIN DATA
8 242
278 450
540 690
758 1088
1188 1468
1532 1832
1872 2040
2079 2545
2587 5700
END DATA.

And this is what it should look like:

DATA LIST FREE /Fixationstartms Fixationendms Interval.1 TO Interval.12.
BEGIN DATA
8 242 234 0 0 0 0 0 0 0 0 0 0 0
278 450 171 0 0 0 0 0 0 0 0 0 0 0
540 690 0 150 0 0 0 0 0 0 0 0 0 0
758 1088 0 242 88 0 0 0 0 0 0 0 0 0
1188 1468 0 0 280 0 0 0 0 0 0 0 0 0
1532 1832 0 0 0 300 0 0 0 0 0 0 0 0
1872 2040 0 0 0 128 40 0 0 0 0 0 0 0
2079 2545 0 0 0 0 421 45 0 0 0 0 0 0
2587 5700 0 0 0 0 0 413 500 500 500 500 500 200
END DATA.

This is what I've accomplished so far:

NUMERIC Intervalstart (F2) Intervalend (F2).
LOOP #i = 0 to 6000 by 500.
IF (FixationStartms GE #i AND Fixationstartms LT #i + 500) Intervalstart
= #i.
IF (FixationEndms GE #i  AND Fixationendms LT #i + 500) Intervalend = #i.
END LOOP.
EXECUTE.

RECODE Intervalstart Intervalend (0 = 1) (500 = 2) (1000 = 3) (1500 = 4)
(2000 = 5) (2500 = 6) (3000 =7) (3500 = 8) (4000 = 9) (4500 = 10) (5000
= 11) (5500 = 12) (6000 = 12).
EXECUTE.


NUMERIC Interval.1 to Interval.12 (F4).
DO IF Intervalstart = 1 and Intervalend = 1.
COMPUTE Interval.1 = Fixationendms - Fixationstartms.
ELSE IF Intervalstart = 1 and Intervalend = 2.
COMPUTE Interval.1 = 500 - Fixationstartms.
COMPUTE Interval.2 = Fixationendms - 500.
ELSE IF Intervalstart = 1 and Intervalend = 3.
COMPUTE Interval.1 = 500 - Fixationstartms.
COMPUTE Interval.2 = 500.
COMPUTE Interval.3 = Fixationendms - 500.
END IF.
EXECUTE.

Thank you so much!
Lutz

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Automatic reply: split durations into intervals

Fuller, Matthew
I will be out of the office until November 20th, with limited access to e-mail.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Automatic reply: split durations into intervals

Lorin Drake
In reply to this post by Lutz Kolburg
I will be in meetings from 9:00 a.m -8:00 p.m. Wednesday November 14 and from 2:00 p.m. to 8:00 p.m. on Thursday the 15th.
I will have very limited email access during these two days. I will return to the office on Friday, November 16.
If your need is urgent, please call our main switchboard and someone will direct your call: (813) 207-0332.
Reply | Threaded
Open this post in threaded view
|

Re: split durations into intervals

David Marso
Administrator
In reply to this post by Lutz Kolburg
I see you have done your homework (RTFM, hairpulling, coding attempts etc)
so here's a fully cooked fish ;-)
-----
DATA LIST FREE /Fixstart Fixend.
BEGIN DATA
8 242
278 450
540 690
758 1088
1188 1468
1532 1832
1872 2040
2079 2545
2587 5700
END DATA.

COMPUTE #IntSt=TRUNC(fixstart/500)+1.
COMPUTE #Intend=  TRUNC(fixend/500)+1  .
VECTOR INT (12).
RECODE INT1 TO INT12 (ELSE=0).
FORMATS INT1 TO INT12 (F3.0).
DO IF #intst=#intend.
+  COMPUTE int(#intst)=Fixend-Fixstart.
ELSE.
+  COMPUTE int(#intst)=#intst*500-fixstart.
+  COMPUTE int(#intend)=fixend-(#intend-1)*500.
+  LOOP #=#intst+1 TO #intend-1.
+    COMPUTE int(#)=500.
+  END LOOP.
END IF.
EXE.
LIST.


FIXSTART   FIXEND INT1 INT2 INT3 INT4 INT5 INT6 INT7 INT8 INT9 INT10 INT11 INT12

8.000000 242.0000  234    0    0    0    0    0    0    0    0    0     0     0
278.0000 450.0000  172    0    0    0    0    0    0    0    0    0     0     0
540.0000 690.0000    0  150    0    0    0    0    0    0    0    0     0     0
758.0000 1088.000    0  242   88    0    0    0    0    0    0    0     0     0
1188.000 1468.000    0    0  280    0    0    0    0    0    0    0     0     0
1532.000 1832.000    0    0    0  300    0    0    0    0    0    0     0     0
1872.000 2040.000    0    0    0  128   40    0    0    0    0    0     0     0
2079.000 2545.000    0    0    0    0  421   45    0    0    0    0     0     0
2587.000 5700.000    0    0    0    0    0  413  500  500  500  500   500   200


Number of cases read:  9    Number of cases listed:  9


Lutz Kolburg wrote
Hey Guys,

I would love to hear some suggestions for a problem which puzzles me for
a while:
I have some Eye-Tracking data which is already processed, so each row
represents one fixation. But now I would like to split these fixations
into intervals. The stimulus presentation was 6000ms long and I would
like to split it into 12 intervals á 500ms. The amount of time of each
fixation should be written in  the corresponding interval. As you can
see below I started writing a lot of IF statments, but I'm pretty,
pretty sure that this is not the smartest way. I tried LOOP and other
stuff, but I always failed at the point when I have to point to the
interval depending on the time when the fixation has started. An idea
would be greatly appreciated!

Some example data:

DATA LIST FREE /Fixationstartms Fixationendms.
BEGIN DATA
8 242
278 450
540 690
758 1088
1188 1468
1532 1832
1872 2040
2079 2545
2587 5700
END DATA.

And this is what it should look like:

DATA LIST FREE /Fixationstartms Fixationendms Interval.1 TO Interval.12.
BEGIN DATA
8 242 234 0 0 0 0 0 0 0 0 0 0 0
278 450 171 0 0 0 0 0 0 0 0 0 0 0
540 690 0 150 0 0 0 0 0 0 0 0 0 0
758 1088 0 242 88 0 0 0 0 0 0 0 0 0
1188 1468 0 0 280 0 0 0 0 0 0 0 0 0
1532 1832 0 0 0 300 0 0 0 0 0 0 0 0
1872 2040 0 0 0 128 40 0 0 0 0 0 0 0
2079 2545 0 0 0 0 421 45 0 0 0 0 0 0
2587 5700 0 0 0 0 0 413 500 500 500 500 500 200
END DATA.

This is what I've accomplished so far:

NUMERIC Intervalstart (F2) Intervalend (F2).
LOOP #i = 0 to 6000 by 500.
IF (FixationStartms GE #i AND Fixationstartms LT #i + 500) Intervalstart
= #i.
IF (FixationEndms GE #i  AND Fixationendms LT #i + 500) Intervalend = #i.
END LOOP.
EXECUTE.

RECODE Intervalstart Intervalend (0 = 1) (500 = 2) (1000 = 3) (1500 = 4)
(2000 = 5) (2500 = 6) (3000 =7) (3500 = 8) (4000 = 9) (4500 = 10) (5000
= 11) (5500 = 12) (6000 = 12).
EXECUTE.


NUMERIC Interval.1 to Interval.12 (F4).
DO IF Intervalstart = 1 and Intervalend = 1.
COMPUTE Interval.1 = Fixationendms - Fixationstartms.
ELSE IF Intervalstart = 1 and Intervalend = 2.
COMPUTE Interval.1 = 500 - Fixationstartms.
COMPUTE Interval.2 = Fixationendms - 500.
ELSE IF Intervalstart = 1 and Intervalend = 3.
COMPUTE Interval.1 = 500 - Fixationstartms.
COMPUTE Interval.2 = 500.
COMPUTE Interval.3 = Fixationendms - 500.
END IF.
EXECUTE.

Thank you so much!
Lutz

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"