optimus-ep 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +9 -0
- data/bin/eprime2tabfile +165 -0
- data/bin/stim.times +5 -0
- data/bin/stim1.times +5 -0
- data/bin/stim1_b.times +5 -0
- data/bin/stim1_c.times +5 -0
- data/bin/stim1_d.times +5 -0
- data/bin/test_data.txt +278 -0
- data/bin/test_data2.txt +277 -0
- data/bin/test_eprime_stimfile.rb +20 -0
- data/lib/calculator.rb +49 -0
- data/lib/column_calculator.rb +308 -0
- data/lib/eprime.rb +23 -0
- data/lib/eprime_data.rb +154 -0
- data/lib/eprime_reader.rb +105 -0
- data/lib/eprimetab_parser.rb +21 -0
- data/lib/excel_parser.rb +21 -0
- data/lib/log_file_parser.rb +208 -0
- data/lib/row_filter.rb +40 -0
- data/lib/tabfile_parser.rb +55 -0
- data/lib/tabfile_writer.rb +44 -0
- data/lib/writers/stimtimes_writer.rb +97 -0
- data/spec/calculator_spec.rb +56 -0
- data/spec/column_calculator_spec.rb +368 -0
- data/spec/eprime_data_spec.rb +202 -0
- data/spec/eprime_reader_spec.rb +115 -0
- data/spec/eprimetab_parser_spec.rb +23 -0
- data/spec/excel_parser_spec.rb +26 -0
- data/spec/log_file_parser_spec.rb +156 -0
- data/spec/row_filter_spec.rb +32 -0
- data/spec/samples/bad_excel_tsv.txt +4 -0
- data/spec/samples/corrupt_log_file.txt +116 -0
- data/spec/samples/eprime_tsv.txt +7 -0
- data/spec/samples/excel_tsv.txt +5 -0
- data/spec/samples/optimus_log.txt +110 -0
- data/spec/samples/short_columns.txt +1 -0
- data/spec/samples/sorted_columns.txt +1 -0
- data/spec/samples/std_columns.txt +1 -0
- data/spec/samples/unknown_type.txt +2 -0
- data/spec/samples/unreadable_file +1 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/tabfile_parser_spec.rb +62 -0
- data/spec/tabfile_writer_spec.rb +91 -0
- data/spec/writers/stimtimes_writer_spec.rb +16 -0
- metadata +106 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# Part of the Optimus package for managing E-Prime data
|
2
|
+
#
|
3
|
+
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
|
4
|
+
#
|
5
|
+
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
|
6
|
+
# Imaging and Behavior, University of Wisconsin - Madison
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/eprime')
|
10
|
+
include EprimeTestHelper
|
11
|
+
|
12
|
+
describe Eprime::Reader::ExcelParser do
|
13
|
+
|
14
|
+
# We don't need to do much here; the superclass handles almost everything
|
15
|
+
|
16
|
+
before :each do
|
17
|
+
@file = File.open(EXCEL_FILE, 'r')
|
18
|
+
@reader = Eprime::Reader::ExcelParser.new(@file)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should read the sample excel file" do
|
22
|
+
lambda {
|
23
|
+
@reader.to_eprime
|
24
|
+
}.should_not raise_error
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# Part of the Optimus package for managing E-Prime data
|
2
|
+
#
|
3
|
+
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
|
4
|
+
#
|
5
|
+
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
|
6
|
+
# Imaging and Behavior, University of Wisconsin - Madison
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/eprime')
|
10
|
+
include EprimeTestHelper
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
describe Eprime::Reader::LogfileParser do
|
15
|
+
describe "parsing a good file" do
|
16
|
+
before :each do
|
17
|
+
@file = File.open(LOG_FILE, 'r')
|
18
|
+
@reader = Eprime::Reader::LogfileParser.new(@file)
|
19
|
+
@reader.make_frames!
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should create six frames from the example file" do
|
23
|
+
@reader.frames.size.should == 6
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have data in every frame" do
|
27
|
+
@reader.frames.detect{ |c| c.keys.size == 0}.should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a level 3 frame at the start" do
|
31
|
+
@reader.frames.first.level.should == 3
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have a level 1 frame at the end" do
|
35
|
+
@reader.frames.last.level.should == 1
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have a known TypeA key in first frame" do
|
39
|
+
@reader.frames.first["TypeA"].should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should not have a known Gibberish key in first frame" do
|
43
|
+
@reader.frames.first["Gibberish"].should be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have a known RandomSeed key in last frame" do
|
47
|
+
@reader.frames.last["RandomSeed"].should_not be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not have a known StartR.OnsetTime key in last frame" do
|
51
|
+
@reader.frames.last["StartR.OnsetTime"].should be_nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should read levels from the header" do
|
55
|
+
@reader.levels.should include("Session")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should find a top_level of 3" do
|
59
|
+
@reader.top_level.should == 3
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should have three top frames" do
|
63
|
+
@reader.top_frames.length.should == 3
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have a parent in the first frame" do
|
67
|
+
@reader.frames.first.parent.should_not be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "making eprime data" do
|
71
|
+
before :each do
|
72
|
+
@eprime = @reader.to_eprime
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should generate three rows from the example file" do
|
76
|
+
@eprime.length.should == 3
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should ignore extra colons in input data" do
|
80
|
+
@eprime.first['SessionTime'].should == '11:11:11'
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should append level name to ambiguous columns" do
|
84
|
+
@eprime.columns.should include("CarriedVal[Session]")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should not include ambiguous columns without level name" do
|
88
|
+
@eprime.columns.should_not include("CarriedVal")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should mark ambiguous columns for skip" do
|
92
|
+
@reader.skip_columns.should include("CarriedVal")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should include columns from level 2 and level 1 frames" do
|
96
|
+
@eprime.columns.should include("RandomSeed")
|
97
|
+
@eprime.columns.should include("BlockTitle")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should rename Experiment to ExperimentName" do
|
101
|
+
@eprime.columns.should include("ExperimentName")
|
102
|
+
@eprime.columns.should_not include("Experiment")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should compute task counters" do
|
106
|
+
@eprime.first["Block"].should == 1
|
107
|
+
@eprime.last["Block"].should == 2
|
108
|
+
@eprime.last["Trial"].should == 2
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should have a counter column" do
|
112
|
+
@eprime.columns.should include("Trial")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "with sorted columns" do
|
118
|
+
before :each do
|
119
|
+
@file = File.open(LOG_FILE, 'r')
|
120
|
+
@reader = Eprime::Reader::LogfileParser.new(@file, :columns => STD_COLUMNS)
|
121
|
+
@reader.make_frames!
|
122
|
+
@eprime = @reader.to_eprime
|
123
|
+
end
|
124
|
+
|
125
|
+
after :each do
|
126
|
+
@file.close
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should have ExperimentName first" do
|
130
|
+
@eprime.columns.first.should == "ExperimentName"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should have three rows" do
|
134
|
+
@eprime.length.should == 3
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "parsing bad files" do
|
141
|
+
before :each do
|
142
|
+
@file = File.open(CORRUPT_LOG_FILE, 'r')
|
143
|
+
@reader = Eprime::Reader::LogfileParser.new(@file)
|
144
|
+
end
|
145
|
+
after :each do
|
146
|
+
@file.close
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should throw an error when the last frame is not closed" do
|
150
|
+
lambda {@reader.make_frames!}.
|
151
|
+
should raise_error(Eprime::DamagedFileError)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Part of the Optimus package for managing E-Prime data
|
2
|
+
#
|
3
|
+
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
|
4
|
+
#
|
5
|
+
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
|
6
|
+
# Imaging and Behavior, University of Wisconsin - Madison
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/eprime')
|
10
|
+
require 'row_filter'
|
11
|
+
include EprimeTestHelper
|
12
|
+
|
13
|
+
describe Eprime::RowFilter do
|
14
|
+
before :each do
|
15
|
+
@edata = mock_edata
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should allow filtering based on a proc" do
|
19
|
+
filter = Eprime::RowFilter.new(@edata, lambda { |row| !row['sparse'].to_s.empty? })
|
20
|
+
filter.each do |row|
|
21
|
+
row['sparse'].to_s.should_not be_empty
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should filter based on column equal test" do
|
26
|
+
filter = Eprime::RowFilter.new(@edata, ['run_start', 'equals', 2400])
|
27
|
+
filter.to_a.size.should_not == 0
|
28
|
+
filter.each do |row|
|
29
|
+
row['run_start'].should == '2400'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/path/to/my_test
|
2
|
+
ExperimentName Subject Session RFP.StartTime BlockTitle PeriodA CarriedVal[Session] BlockList Trial NameOfPeriodList NumPeriods PeriodB Procedure[Block] Block Group CarriedVal[Block] BlockList.Sample SessionTime Clock.Scale BlockList.Cycle Stim1.OnsetTime CarriedVal[Trial] Display.RefreshRate Running[Block] StartDelay CarriedVal Stim1.OffsetTime Running[Trial] ScanStartTime Periods TypeA BlockElapsed RFP.LastPulseTime BlockTime Procedure[Trial] SessionDate TypeB Procedure StartTime RandomSeed Running
|
3
|
+
optimus_test 1 1 15000 My Task 10000 SessionLevel 1 1 TestList 3 10000 testBlocProc 1 1 BlockLevel 1 11 1 1 88684 TrialLevel 60.000 TestBlockList 0 TrialLevel 93583 TestList 11 2 Danger 300000 15000 15000 RunTrial 03-15-2008 2 RunTrial 5000 1123581321 TestList
|
4
|
+
optimus_test 1 1 305000 My Task 10000 SessionLevel 1 1 TestList 3
|
@@ -0,0 +1,116 @@
|
|
1
|
+
*** Header Start ***
|
2
|
+
VersionPersist: 1
|
3
|
+
LevelName: Session
|
4
|
+
LevelName: Block
|
5
|
+
LevelName: Trial
|
6
|
+
LevelName: SubTrial
|
7
|
+
LevelName: LogLevel5
|
8
|
+
LevelName: LogLevel6
|
9
|
+
LevelName: LogLevel7
|
10
|
+
LevelName: LogLevel8
|
11
|
+
LevelName: LogLevel9
|
12
|
+
LevelName: LogLevel10
|
13
|
+
Experiment: test_gng_v1
|
14
|
+
SessionDate: 11-11-2006
|
15
|
+
SessionTime: 15:11:37
|
16
|
+
RandomSeed: -1148015259
|
17
|
+
Group: 1
|
18
|
+
Subject: 043
|
19
|
+
Session: 043
|
20
|
+
Display.RefreshRate: 60.365
|
21
|
+
*** Header End ***
|
22
|
+
Level: 2
|
23
|
+
*** LogFrame Start ***
|
24
|
+
BlockList: 1
|
25
|
+
NoGoTypeA: Fear
|
26
|
+
NoGoTypeB: 2
|
27
|
+
blocknumb: 1
|
28
|
+
shapeface: faces of all expressions
|
29
|
+
Procedure: RunTrial
|
30
|
+
BlockList.Cycle: 1
|
31
|
+
BlockList.Sample: 1
|
32
|
+
Running: BlockList
|
33
|
+
StartTime: 5000
|
34
|
+
FixTime: 20000
|
35
|
+
InstTime: 5000
|
36
|
+
StartR.OnsetTime: 64697
|
37
|
+
StartR.OffsetTime: 68683
|
38
|
+
FixatRun.OnsetTime: 68739
|
39
|
+
FixatRun.OffsetTime: 88583
|
40
|
+
NoGoInstruct.OnsetTime: 88684
|
41
|
+
NoGoInstruct.OffsetTime: 93583
|
42
|
+
InitITI.OnsetTime: 93687
|
43
|
+
InitITI.OffsetTime: 96083
|
44
|
+
*** LogFrame End ***
|
45
|
+
Level: 2
|
46
|
+
*** LogFrame Start ***
|
47
|
+
BlockList: 2
|
48
|
+
NoGoTypeA: Fear
|
49
|
+
NoGoTypeB: 2
|
50
|
+
blocknumb: 1
|
51
|
+
shapeface:
|
52
|
+
Procedure: StimProc
|
53
|
+
StimList1: 1
|
54
|
+
StimTypeA: Anger
|
55
|
+
StimTypeB: 2
|
56
|
+
gonogo: Fear2
|
57
|
+
ITI_Run: 3300
|
58
|
+
Code: 14
|
59
|
+
BlockList.Cycle: 1
|
60
|
+
BlockList.Sample: 2
|
61
|
+
Running: BlockList
|
62
|
+
StimTime: 500
|
63
|
+
StimPresent.OnsetDelay: 6
|
64
|
+
StimPresent.OnsetTime: 96189
|
65
|
+
StimPresent.DurationError: -6
|
66
|
+
StimPresent.OffsetTime: 96583
|
67
|
+
StimPresent.RTTime: 0
|
68
|
+
StimPresent.ACC: 1
|
69
|
+
StimPresent.RT: 0
|
70
|
+
StimPresent.RESP:
|
71
|
+
StimPresent.CRESP:
|
72
|
+
ITIFixat.OnsetTime: 96686
|
73
|
+
ITIFixat.OffsetTime: 99883
|
74
|
+
TrialType: Go
|
75
|
+
*** LogFrame End ***
|
76
|
+
Level: 2
|
77
|
+
*** LogFrame Start ***
|
78
|
+
BlockList: 2
|
79
|
+
NoGoTypeA: Fear
|
80
|
+
NoGoTypeB: 2
|
81
|
+
blocknumb: 1
|
82
|
+
shapeface:
|
83
|
+
Procedure: StimProc
|
84
|
+
StimList1: 2
|
85
|
+
StimTypeA: Fear
|
86
|
+
StimTypeB: 2
|
87
|
+
gonogo: Fear2
|
88
|
+
ITI_Run: 2600
|
89
|
+
Code: 15
|
90
|
+
BlockList.Cycle: 1
|
91
|
+
BlockList.Sample: 3
|
92
|
+
Running: BlockList
|
93
|
+
StimTime: 500
|
94
|
+
StimPresent.OnsetDelay: -1
|
95
|
+
StimPresent.OnsetTime: 99982
|
96
|
+
StimPresent.DurationError: 1
|
97
|
+
StimPresent.OffsetTime: 100383
|
98
|
+
StimPresent.RTTime: 0
|
99
|
+
StimPresent.ACC: 1
|
100
|
+
StimPresent.RT: 0
|
101
|
+
StimPresent.RESP:
|
102
|
+
StimPresent.CRESP:
|
103
|
+
ITIFixat.OnsetTime: 100496
|
104
|
+
ITIFixat.OffsetTime: 102983
|
105
|
+
TrialType: NoGo
|
106
|
+
*** LogFrame End ***
|
107
|
+
Level: 1
|
108
|
+
*** LogFrame Start ***
|
109
|
+
Experiment: test_gng_v1
|
110
|
+
SessionDate: 11-11-2006
|
111
|
+
SessionTime: 15:11:37
|
112
|
+
RandomSeed: -1148015259
|
113
|
+
Group: 1
|
114
|
+
Subject: 043
|
115
|
+
Session: 043
|
116
|
+
Display.RefreshRate: 60.365
|
@@ -0,0 +1,7 @@
|
|
1
|
+
STRING INTEGER INTEGER INTEGER STRING STRING STRING STRING INTEGER STRING STRING STRING STRING INTEGER STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING
|
2
|
+
EXPNAME SUBJECT SESSION LOG_LEVEL VARIABLE VARIABLE VARIABLE VARIABLE LOG_LEVEL VARIABLE VARIABLE VARIABLE VARIABLE LOG_LEVEL VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE VARIABLE
|
3
|
+
1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
|
4
|
+
ExperimentName Subject Session RFP.StartTime BlockTitle PeriodA CarriedVal[Session] BlockList Trial NameOfPeriodList NumPeriods PeriodB Procedure[Block] Block Group CarriedVal[Block] BlockList.Sample SessionTime Clock.Scale BlockList.Cycle Stim1.OnsetTime CarriedVal[Trial] Display.RefreshRate Running[Block] StartDelay Stim1.OffsetTime Running[Trial] ScanStartTime Periods TypeA BlockElapsed RFP.LastPulseTime BlockTime Procedure[Trial] SessionDate TypeB StartTime RandomSeed
|
5
|
+
optimus_test 1 1 15000 My Task 10000 SessionLevel 1 1 TestList 3 10000 testBlocProc 1 1 BlockLevel 1 11 1 1 88684 TrialLevel 60 TestBlockList 0 93583 TestList 11 2 Danger 300000 15000 15000 RunTrial 3/15/08 2 5000 1123581321
|
6
|
+
optimus_test 1 1 305000 My Task 10000 SessionLevel 1 1 TestList 3 10000 testBlocProc 2 1 BlockLevel 1 11 1 1 99999 TrialLevel 60 TestBlockList 0 111111 TestList 11 2 Fear 300000 305000 15000 RunTrial 3/15/08 1 5000 1123581321
|
7
|
+
optimus_test 1 1 305000 My Task 10000 SessionLevel 1 2 TestList 3 10000 testBlocProc 2 1 BlockLevel 1 11 1 2 122222 TrialLevel 60 TestBlockList 0 133333 TestList 11 2 Loathing 300000 305000 15000 RunTrial 3/15/08 1 5000 1123581321
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/path/to/my_test
|
2
|
+
ExperimentName Subject Session RFP.StartTime BlockTitle PeriodA CarriedVal[Session] BlockList Trial NameOfPeriodList NumPeriods PeriodB Procedure[Block] Block Group CarriedVal[Block] BlockList.Sample SessionTime Clock.Scale BlockList.Cycle Stim1.OnsetTime CarriedVal[Trial] Display.RefreshRate Running[Block] StartDelay Stim1.OffsetTime Running[Trial] ScanStartTime Periods TypeA BlockElapsed RFP.LastPulseTime BlockTime Procedure[Trial] SessionDate TypeB StartTime RandomSeed
|
3
|
+
optimus_test 1 1 15000 My Task 10000 SessionLevel 1 1 TestList 3 10000 testBlocProc 1 1 BlockLevel 1 11 1 1 88684 TrialLevel 60 TestBlockList 0 93583 TestList 11 2 Danger 300000 15000 15000 RunTrial 3/15/08 2 5000 1123581321
|
4
|
+
optimus_test 1 1 305000 My Task 10000 SessionLevel 1 1 TestList 3 10000 testBlocProc 2 1 BlockLevel 1 11 1 1 99999 TrialLevel 60 TestBlockList 0 111111 TestList 11 2 Fear 300000 305000 15000 RunTrial 3/15/08 1 5000 1123581321
|
5
|
+
optimus_test 1 1 305000 My Task 10000 SessionLevel 1 2 TestList 3 10000 testBlocProc 2 1 BlockLevel 1 11 1 2 122222 TrialLevel 60 TestBlockList 0 133333 TestList 11 2 Loathing 300000 305000 15000 RunTrial 3/15/08 1 5000 1123581321
|
@@ -0,0 +1,110 @@
|
|
1
|
+
*** Header Start ***
|
2
|
+
VersionPersist: 1
|
3
|
+
LevelName: Session
|
4
|
+
LevelName: Block
|
5
|
+
LevelName: Trial
|
6
|
+
LevelName: SubTrial
|
7
|
+
LevelName: LogLevel5
|
8
|
+
LevelName: LogLevel6
|
9
|
+
LevelName: LogLevel7
|
10
|
+
LevelName: LogLevel8
|
11
|
+
LevelName: LogLevel9
|
12
|
+
LevelName: LogLevel10
|
13
|
+
Experiment: optimus_test
|
14
|
+
SessionDate: 03-15-2008
|
15
|
+
SessionTime: 11:11:11
|
16
|
+
RandomSeed: 1123581321
|
17
|
+
Group: 1
|
18
|
+
Subject: 1
|
19
|
+
Session: 1
|
20
|
+
Display.RefreshRate: 60.000
|
21
|
+
*** Header End ***
|
22
|
+
Level: 3
|
23
|
+
*** LogFrame Start ***
|
24
|
+
BlockList: 1
|
25
|
+
TypeA: Danger
|
26
|
+
TypeB: 2
|
27
|
+
Procedure: RunTrial
|
28
|
+
BlockList.Cycle: 1
|
29
|
+
BlockList.Sample: 1
|
30
|
+
Running: TestList
|
31
|
+
StartTime: 5000
|
32
|
+
Stim1.OnsetTime: 88684
|
33
|
+
Stim1.OffsetTime: 93583
|
34
|
+
CarriedVal: TrialLevel
|
35
|
+
*** LogFrame End ***
|
36
|
+
Level: 2
|
37
|
+
*** LogFrame Start ***
|
38
|
+
BlockTitle: My Task
|
39
|
+
NameOfPeriodList: TestList
|
40
|
+
Periods: 2
|
41
|
+
StartDelay: 0
|
42
|
+
Procedure: testBlocProc
|
43
|
+
Running: TestBlockList
|
44
|
+
ScanStartTime: 11:11:11
|
45
|
+
BlockTime: 15000
|
46
|
+
RFP.StartTime: 15000
|
47
|
+
RFP.LastPulseTime: 15000
|
48
|
+
BlockElapsed: 300000
|
49
|
+
CarriedVal: BlockLevel
|
50
|
+
*** LogFrame End ***
|
51
|
+
Level: 3
|
52
|
+
*** LogFrame Start ***
|
53
|
+
BlockList: 1
|
54
|
+
TypeA: Fear
|
55
|
+
TypeB: 1
|
56
|
+
Procedure: RunTrial
|
57
|
+
BlockList.Cycle: 1
|
58
|
+
BlockList.Sample: 1
|
59
|
+
Running: TestList
|
60
|
+
StartTime: 5000
|
61
|
+
Stim1.OnsetTime: 99999
|
62
|
+
Stim1.OffsetTime: 111111
|
63
|
+
CarriedVal: TrialLevel
|
64
|
+
*** LogFrame End ***
|
65
|
+
Level: 3
|
66
|
+
*** LogFrame Start ***
|
67
|
+
BlockList: 1
|
68
|
+
TypeA: Loathing
|
69
|
+
TypeB: 1
|
70
|
+
Procedure: RunTrial
|
71
|
+
BlockList.Cycle: 2
|
72
|
+
BlockList.Sample: 1
|
73
|
+
Running: TestList
|
74
|
+
StartTime: 5000
|
75
|
+
Stim1.OnsetTime: 122222
|
76
|
+
Stim1.OffsetTime: 133333
|
77
|
+
CarriedVal: TrialLevel
|
78
|
+
*** LogFrame End ***
|
79
|
+
Level: 2
|
80
|
+
*** LogFrame Start ***
|
81
|
+
BlockTitle: My Task
|
82
|
+
NameOfPeriodList: TestList
|
83
|
+
Periods: 2
|
84
|
+
StartDelay: 0
|
85
|
+
Procedure: testBlocProc
|
86
|
+
Running: TestBlockList
|
87
|
+
ScanStartTime: 11:11:11
|
88
|
+
BlockTime: 15000
|
89
|
+
RFP.StartTime: 305000
|
90
|
+
RFP.LastPulseTime: 305000
|
91
|
+
BlockElapsed: 300000
|
92
|
+
CarriedVal: BlockLevel
|
93
|
+
Block: 0
|
94
|
+
*** LogFrame End ***
|
95
|
+
Level: 1
|
96
|
+
*** LogFrame Start ***
|
97
|
+
CarriedVal: SessionLevel
|
98
|
+
Experiment: optimus_test
|
99
|
+
SessionDate: 03-15-2008
|
100
|
+
SessionTime: 11:11:11
|
101
|
+
RandomSeed: 1123581321
|
102
|
+
Group: 1
|
103
|
+
Subject: 1
|
104
|
+
Session: 1
|
105
|
+
Display.RefreshRate: 60.000
|
106
|
+
Clock.Scale: 1
|
107
|
+
NumPeriods: 3
|
108
|
+
PeriodA: 10000
|
109
|
+
PeriodB: 10000
|
110
|
+
*** LogFrame End ***
|
@@ -0,0 +1 @@
|
|
1
|
+
ExperimentName StartDelay
|
@@ -0,0 +1 @@
|
|
1
|
+
Block BlockElapsed BlockList BlockList.Cycle BlockList.Sample BlockTime BlockTitle CarriedVal CarriedVal[Block] CarriedVal[Session] CarriedVal[Trial] Clock.Scale Display.RefreshRate ExperimentName Group NameOfPeriodList NumPeriods PeriodA PeriodB Periods Procedure Procedure[Block] Procedure[Trial] RFP.LastPulseTime RFP.StartTime RandomSeed Running Running[Block] Running[Trial] ScanStartTime Session SessionDate SessionTime StartDelay StartTime Stim1.OffsetTime Stim1.OnsetTime Subject Trial TypeA TypeB
|
@@ -0,0 +1 @@
|
|
1
|
+
ExperimentName Subject Session RFP.StartTime BlockTitle PeriodA CarriedVal[Session] BlockList Trial NameOfPeriodList NumPeriods PeriodB Procedure[Block] Block Group CarriedVal[Block] BlockList.Sample SessionTime Clock.Scale BlockList.Cycle Stim1.OnsetTime CarriedVal[Trial] Display.RefreshRate Running[Block] StartDelay CarriedVal Stim1.OffsetTime Running[Trial] ScanStartTime Periods TypeA BlockElapsed RFP.LastPulseTime BlockTime Procedure[Trial] SessionDate TypeB Procedure StartTime RandomSeed Running
|
@@ -0,0 +1 @@
|
|
1
|
+
The spec should render this file chmod 000
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Part of the Optimus package for managing E-Prime data
|
2
|
+
#
|
3
|
+
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
|
4
|
+
#
|
5
|
+
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
|
6
|
+
# Imaging and Behavior, University of Wisconsin - Madison
|
7
|
+
|
8
|
+
module EprimeTestHelper
|
9
|
+
unless constants.include?('SAMPLE_DIR')
|
10
|
+
SAMPLE_DIR = File.join(File.dirname(__FILE__), 'samples')
|
11
|
+
LOG_FILE = File.join(SAMPLE_DIR, 'optimus_log.txt')
|
12
|
+
EXCEL_FILE = File.join(SAMPLE_DIR, 'excel_tsv.txt')
|
13
|
+
BAD_EXCEL_FILE = File.join(SAMPLE_DIR, 'bad_excel_tsv.txt')
|
14
|
+
EPRIME_FILE = File.join(SAMPLE_DIR, 'eprime_tsv.txt')
|
15
|
+
UNKNOWN_FILE = File.join(SAMPLE_DIR, 'unknown_type.txt')
|
16
|
+
UNREADABLE_FILE = File.join(SAMPLE_DIR, 'unreadable_file')
|
17
|
+
CORRUPT_LOG_FILE = File.join(SAMPLE_DIR, 'corrupt_log_file.txt')
|
18
|
+
|
19
|
+
|
20
|
+
STD_COLUMNS = ["ExperimentName", "Subject", "Session", "RFP.StartTime", "BlockTitle", "PeriodA", "CarriedVal[Session]", "BlockList", "Trial",
|
21
|
+
"NameOfPeriodList", "NumPeriods", "PeriodB", "Procedure[Block]", "Block", "Group",
|
22
|
+
"CarriedVal[Block]", "BlockList.Sample", "SessionTime", "Clock.Scale", "BlockList.Cycle",
|
23
|
+
"Stim1.OnsetTime", "CarriedVal[Trial]", "Display.RefreshRate", "Running[Block]",
|
24
|
+
"StartDelay", "Stim1.OffsetTime", "Running[Trial]", "ScanStartTime",
|
25
|
+
"Periods", "TypeA", "BlockElapsed", "RFP.LastPulseTime", "BlockTime", "Procedure[Trial]",
|
26
|
+
"SessionDate", "TypeB", "StartTime", "RandomSeed"]
|
27
|
+
|
28
|
+
SORTED_COLUMNS = STD_COLUMNS.sort
|
29
|
+
|
30
|
+
SHORT_COLUMNS = ["ExperimentName", "Subject"]
|
31
|
+
|
32
|
+
CONST_EXPRS = {
|
33
|
+
:const => ["1", lambda { 1 }],
|
34
|
+
:add => ["1+3", lambda { 1+3 }],
|
35
|
+
:mul => ["2*4", lambda { 2*4 }],
|
36
|
+
:add_neg => ["4 + -5", lambda { 4 + -5 }],
|
37
|
+
:add_mul_group => ["4*(3+2)", lambda { 4*(3+2) }],
|
38
|
+
:fdiv => ["9/2.0", lambda { 9/2.0 }],
|
39
|
+
:fmul => ["0.44*10", lambda { 0.44*10 }],
|
40
|
+
:mod => ["10 % 4", lambda { 10 % 4}]
|
41
|
+
}
|
42
|
+
|
43
|
+
COMP_EXPRS = {
|
44
|
+
'stim_offset' => '{stim_time} - {run_start}',
|
45
|
+
'stim_offset_s' => '{stim_offset}/1000'
|
46
|
+
}
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def mock_eprime(col_count, row_count)
|
52
|
+
data = Eprime::Data.new()
|
53
|
+
1.upto(row_count) do |rownum|
|
54
|
+
row = data.add_row
|
55
|
+
1.upto(col_count) do |colnum|
|
56
|
+
unless (rownum == row_count and colnum > 1)
|
57
|
+
# Leave some blanks in the last row
|
58
|
+
row["col_#{colnum}"] = "c_#{colnum}_r_#{rownum}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
return data
|
63
|
+
end
|
64
|
+
|
65
|
+
def mock_edata
|
66
|
+
data = Eprime::Data.new()
|
67
|
+
row = data.add_row
|
68
|
+
row['stim_time'] = '3188'
|
69
|
+
row['run_start'] = '2400'
|
70
|
+
row = data.add_row
|
71
|
+
row['stim_time'] = '4515'
|
72
|
+
row['run_start'] = '2400'
|
73
|
+
row['sparse'] = '20'
|
74
|
+
row = data.add_row
|
75
|
+
row['stim_time'] = '6515'
|
76
|
+
row['run_start'] = '2400'
|
77
|
+
row = data.add_row
|
78
|
+
row['stim_time'] = '8115'
|
79
|
+
row['run_start'] = '2400'
|
80
|
+
row['sparse'] = '50'
|
81
|
+
row = data.add_row
|
82
|
+
row['stim_time'] = '9815'
|
83
|
+
row['run_start'] = '2400'
|
84
|
+
row = data.add_row
|
85
|
+
row['stim_time'] = '12515'
|
86
|
+
row['run_start'] = '2800'
|
87
|
+
return data
|
88
|
+
end
|
89
|
+
|
90
|
+
def es(sym)
|
91
|
+
CONST_EXPRS[sym][0]
|
92
|
+
end
|
93
|
+
|
94
|
+
def ev(sym)
|
95
|
+
CONST_EXPRS[sym][1].call.to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Part of the Optimus package for managing E-Prime data
|
2
|
+
#
|
3
|
+
# Copyright (C) 2008 Board of Regents of the University of Wisconsin System
|
4
|
+
#
|
5
|
+
# Written by Nathan Vack <njvack@wisc.edu>, at the Waisman Laborotory for Brain
|
6
|
+
# Imaging and Behavior, University of Wisconsin - Madison
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__),'spec_helper')
|
9
|
+
require File.join(File.dirname(__FILE__), '../lib/eprime')
|
10
|
+
include EprimeTestHelper
|
11
|
+
|
12
|
+
|
13
|
+
shared_examples_for "Eprime::Reader::TabfileParser with sample data" do
|
14
|
+
it "should generate and Eprime::Data object" do
|
15
|
+
@eprime.should be_an_instance_of(Eprime::Data)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have columns matching the test set" do
|
19
|
+
@eprime.columns.sort.should == STD_COLUMNS.sort
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should contain three rows" do
|
23
|
+
@eprime.length.should == 3
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe Eprime::Reader::TabfileParser do
|
28
|
+
|
29
|
+
describe "without column order specified" do
|
30
|
+
before :each do
|
31
|
+
@file = File.open(EXCEL_FILE, 'r')
|
32
|
+
@reader = Eprime::Reader::TabfileParser.new(@file, :skip_lines => 1)
|
33
|
+
@eprime = @reader.to_eprime
|
34
|
+
end
|
35
|
+
|
36
|
+
it_should_behave_like "Eprime::Reader::TabfileParser with sample data"
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "with column order specified" do
|
40
|
+
before :each do
|
41
|
+
@file = File.open(EXCEL_FILE, 'r')
|
42
|
+
@reader = Eprime::Reader::TabfileParser.new(@file, :skip_lines => 1, :columns => SORTED_COLUMNS)
|
43
|
+
@eprime = @reader.to_eprime
|
44
|
+
end
|
45
|
+
|
46
|
+
it_should_behave_like "Eprime::Reader::TabfileParser with sample data"
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "with data missing from some rows" do
|
51
|
+
before :each do
|
52
|
+
@file = File.open(BAD_EXCEL_FILE, 'r')
|
53
|
+
@reader = Eprime::Reader::TabfileParser.new(@file, :skip_lines => 1)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should raise an error when parsing" do
|
57
|
+
lambda {
|
58
|
+
@reader.to_eprime
|
59
|
+
}.should raise_error(Eprime::DamagedFileError)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|