rpipe 0.0.1

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.
Files changed (104) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/LICENSE +20 -0
  4. data/README +0 -0
  5. data/README.rdoc +33 -0
  6. data/Rakefile +78 -0
  7. data/VERSION +1 -0
  8. data/bin/create_driver.rb +79 -0
  9. data/bin/rpipe +131 -0
  10. data/bin/swallow_batch_run.rb +21 -0
  11. data/lib/core_additions.rb +5 -0
  12. data/lib/custom_methods/JohnsonMerit220Visit1Preproc.m +26 -0
  13. data/lib/custom_methods/JohnsonMerit220Visit1Preproc.rb +43 -0
  14. data/lib/custom_methods/JohnsonMerit220Visit1Preproc_job.m +80 -0
  15. data/lib/custom_methods/JohnsonMerit220Visit1Stats.m +74 -0
  16. data/lib/custom_methods/JohnsonMerit220Visit1Stats.rb +63 -0
  17. data/lib/custom_methods/JohnsonMerit220Visit1Stats_job.m +63 -0
  18. data/lib/custom_methods/JohnsonTbiLongitudinalSnodPreproc.m +26 -0
  19. data/lib/custom_methods/JohnsonTbiLongitudinalSnodPreproc.rb +41 -0
  20. data/lib/custom_methods/JohnsonTbiLongitudinalSnodPreproc_job.m +69 -0
  21. data/lib/custom_methods/JohnsonTbiLongitudinalSnodStats.m +76 -0
  22. data/lib/custom_methods/JohnsonTbiLongitudinalSnodStats.rb +67 -0
  23. data/lib/custom_methods/JohnsonTbiLongitudinalSnodStats_job.m +59 -0
  24. data/lib/custom_methods/ReconWithHello.rb +7 -0
  25. data/lib/default_logger.rb +13 -0
  26. data/lib/default_methods/default_preproc.rb +76 -0
  27. data/lib/default_methods/default_recon.rb +80 -0
  28. data/lib/default_methods/default_stats.rb +94 -0
  29. data/lib/default_methods/recon/physionoise_helper.rb +69 -0
  30. data/lib/default_methods/recon/raw_sequence.rb +109 -0
  31. data/lib/generators/job_generator.rb +36 -0
  32. data/lib/generators/preproc_job_generator.rb +31 -0
  33. data/lib/generators/recon_job_generator.rb +76 -0
  34. data/lib/generators/stats_job_generator.rb +70 -0
  35. data/lib/generators/workflow_generator.rb +128 -0
  36. data/lib/global_additions.rb +18 -0
  37. data/lib/logfile.rb +310 -0
  38. data/lib/matlab_helpers/CreateFunctionalVolumeStruct.m +6 -0
  39. data/lib/matlab_helpers/import_csv.m +32 -0
  40. data/lib/matlab_helpers/matlab_queue.rb +37 -0
  41. data/lib/matlab_helpers/prepare_onsets_xls.m +30 -0
  42. data/lib/rpipe.rb +254 -0
  43. data/rpipe.gemspec +177 -0
  44. data/spec/generators/preproc_job_generator_spec.rb +27 -0
  45. data/spec/generators/recon_job_generator_spec.rb +33 -0
  46. data/spec/generators/stats_job_generator_spec.rb +50 -0
  47. data/spec/generators/workflow_generator_spec.rb +97 -0
  48. data/spec/helper_spec.rb +40 -0
  49. data/spec/integration/johnson.merit220.visit1_spec.rb +47 -0
  50. data/spec/integration/johnson.tbi.longitudinal.snod_spec.rb +48 -0
  51. data/spec/logfile_spec.rb +96 -0
  52. data/spec/matlab_queue_spec.rb +40 -0
  53. data/spec/merit220_stats_spec.rb +81 -0
  54. data/spec/physio_spec.rb +98 -0
  55. data/test/drivers/merit220_workflow_sample.yml +15 -0
  56. data/test/drivers/mrt00000.yml +65 -0
  57. data/test/drivers/mrt00015.yml +62 -0
  58. data/test/drivers/mrt00015_hello.yml +41 -0
  59. data/test/drivers/mrt00015_withphys.yml +81 -0
  60. data/test/drivers/tbi000.yml +129 -0
  61. data/test/drivers/tbi000_separatevisits.yml +137 -0
  62. data/test/drivers/tmp.yml +58 -0
  63. data/test/fixtures/faces3_recognitionA.mat +0 -0
  64. data/test/fixtures/faces3_recognitionA.txt +86 -0
  65. data/test/fixtures/faces3_recognitionA_equal.csv +25 -0
  66. data/test/fixtures/faces3_recognitionA_unequal.csv +21 -0
  67. data/test/fixtures/faces3_recognitionB_incmisses.txt +86 -0
  68. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CPd3R_40.txt +13360 -0
  69. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CPd3_40.txt +13360 -0
  70. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CPttl_40.txt +13360 -0
  71. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CRTd3R_40.txt +13360 -0
  72. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CRTd3_40.txt +13360 -0
  73. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_CRTttl_40.txt +13360 -0
  74. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_CRTd3R_40.txt +334 -0
  75. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_CRTd3_40.txt +334 -0
  76. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_CRTttl_40.txt +334 -0
  77. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_RRT_40.txt +334 -0
  78. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_RVT_40.txt +334 -0
  79. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_card_spline_40.txt +334 -0
  80. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_HalfTR_resp_spline_40.txt +334 -0
  81. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_RRT_40.txt +9106 -0
  82. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_RVT_40.txt +9106 -0
  83. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_CRTd3R_40.txt +167 -0
  84. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_CRTd3_40.txt +167 -0
  85. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_CRTttl_40.txt +167 -0
  86. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_RRT_40.txt +167 -0
  87. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_RVT_40.txt +167 -0
  88. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_card_spline_40.txt +167 -0
  89. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_TR_resp_spline_40.txt +167 -0
  90. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_card_spline_40.txt +13360 -0
  91. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_resp_spline_40.txt +9106 -0
  92. data/test/fixtures/physionoise_regressors/EPI__fMRI_Task1_resp_spline_downsampled_40.txt +9106 -0
  93. data/test/fixtures/ruport_summary.yml +123 -0
  94. data/test/fixtures/valid_scans.yaml +35 -0
  95. data/test/helper.rb +10 -0
  96. data/test/test_dynamic_method_inclusion.rb +10 -0
  97. data/test/test_includes.rb +11 -0
  98. data/test/test_integrative_johnson.merit220.visit1.rb +31 -0
  99. data/test/test_preproc.rb +11 -0
  100. data/test/test_recon.rb +11 -0
  101. data/test/test_rpipe.rb +19 -0
  102. data/vendor/output_catcher.rb +93 -0
  103. data/vendor/trollop.rb +781 -0
  104. metadata +260 -0
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Ruport::Data::Table
2
+ column_names: &id001
3
+ - enum
4
+ - task
5
+ - version
6
+ - ctime
7
+ - Total Count
8
+ - " Hits"
9
+ - " Misses"
10
+ - " Hit%"
11
+ - " Correct"
12
+ - " Incorrect"
13
+ - " Accuracy%"
14
+ - " RT min"
15
+ - " RT max"
16
+ - " RT avg"
17
+ - " RT stdev"
18
+ - " old_stimuli"
19
+ - " old_hits"
20
+ - " old_misses"
21
+ - " old_hit_percent"
22
+ - " old_correct_count"
23
+ - " old_incorrect_count"
24
+ - " old_accuracy"
25
+ - " old_rt_min"
26
+ - " old_rt_max"
27
+ - " old_rt_avg"
28
+ - " old_rt_stdev"
29
+ - " old_correct"
30
+ - " old_correct_rt_min"
31
+ - " old_correct_rt_max"
32
+ - " old_correct_rt_avg"
33
+ - " old_correct_rt_stdev"
34
+ - " old_incorrect"
35
+ - " old_incorrect_rt_min"
36
+ - " old_incorrect_rt_max"
37
+ - " old_incorrect_rt_avg"
38
+ - " old_incorrect_rt_stdev"
39
+ - " new_stimuli"
40
+ - " new_hits"
41
+ - " new_misses"
42
+ - " new_hit_percent"
43
+ - " new_correct_count"
44
+ - " new_incorrect_count"
45
+ - " new_accuracy"
46
+ - " new_rt_min"
47
+ - " new_rt_max"
48
+ - " new_rt_avg"
49
+ - " new_rt_stdev"
50
+ - " new_correct"
51
+ - " new_correct_rt_min"
52
+ - " new_correct_rt_max"
53
+ - " new_correct_rt_avg"
54
+ - " new_correct_rt_stdev"
55
+ - " new_incorrect"
56
+ - " new_incorrect_rt_min"
57
+ - " new_incorrect_rt_max"
58
+ - " new_incorrect_rt_avg"
59
+ - " new_incorrect_rt_stdev"
60
+ - " "
61
+ data:
62
+ - !ruby/object:Ruport::Data::Record
63
+ attributes: *id001
64
+ data:
65
+ " ":
66
+ " new_rt_stdev": "393.78058"
67
+ " new_rt_avg": "1451.43333"
68
+ " new_rt_min": "945.6"
69
+ " new_hits": "24"
70
+ " old_incorrect_rt_avg": "1614.75"
71
+ " old_incorrect_rt_min": "1150.3"
72
+ " old_correct_rt_max": "1801.4"
73
+ " Hit%": "100"
74
+ " Misses": "0"
75
+ " new_correct_rt_stdev": "414.191973"
76
+ " new_correct_rt_avg": "1464.65333"
77
+ " new_correct_rt_min": "1087.9"
78
+ " new_incorrect_count": "9"
79
+ " old_correct": "20"
80
+ " old_rt_avg": "1306.27083"
81
+ " old_rt_min": "799.4"
82
+ " old_correct_count": "20"
83
+ " RT stdev": "357.924556"
84
+ " old_hit_percent": "100"
85
+ enum: faces3
86
+ " new_incorrect_rt_max": "2123.4"
87
+ " new_correct": "15"
88
+ " new_accuracy": "62.5"
89
+ " old_incorrect": "4"
90
+ " old_correct_rt_avg": "1244.575"
91
+ " old_correct_rt_min": "799.4"
92
+ " old_misses": "0"
93
+ " old_hits": "24"
94
+ " Hits": "48"
95
+ " new_correct_count": "15"
96
+ " new_stimuli": "24"
97
+ " Accuracy%": "72.9166667"
98
+ " Incorrect": "13"
99
+ " new_incorrect": "9"
100
+ " old_correct_rt_stdev": "241.838353"
101
+ " RT max": "2400.8"
102
+ version:
103
+ " new_incorrect_rt_stdev": "356.089861"
104
+ " new_incorrect_rt_avg": "1429.4"
105
+ " new_incorrect_rt_min": "945.6"
106
+ " old_incorrect_rt_stdev": "370.275982"
107
+ " old_incorrect_rt_max": "2067.6"
108
+ ctime: 2010-05-27 18:23:44 -05:00
109
+ task:
110
+ " new_rt_max": "2400.8"
111
+ " new_hit_percent": "100"
112
+ " old_rt_stdev": "301.032812"
113
+ " old_accuracy": "83.3333333"
114
+ " new_correct_rt_max": "2400.8"
115
+ " new_misses": "0"
116
+ " old_rt_max": "2067.6"
117
+ " old_incorrect_count": "4"
118
+ " RT avg": "1378.85208"
119
+ " RT min": "799.4"
120
+ " old_stimuli": "24"
121
+ " Correct": "35"
122
+ Total Count: "48"
123
+ record_class: Ruport::Data::Record
@@ -0,0 +1,35 @@
1
+ ---
2
+ - label: EPI-fMRI-Task1
3
+ dir: s07_epi
4
+ type: func
5
+ z_slices: 36
6
+ rep_time: 2.0
7
+ bold_reps: 167
8
+ volumes_to_skip: 3
9
+ # task: "?"
10
+ # physio_files: "#TODO"
11
+ # physio_files:
12
+ # phys_directory: "../cardiac"
13
+ # series_description: "EPI fMRI Task1"
14
+ # respiration_signal: "RESPData_epiRT_0211201009_21_22_80"
15
+ # respiration_trigger:"RESPTrig_epiRT_0211201009_21_22_80"
16
+ # cardiac_signal: "PPGData_epiRT_0211201009_21_22_80"
17
+ # cardiac_trigger: "PPGTrig_epiRT_0211201009_21_22_80"
18
+ - label: EPI-fMRI-Task2
19
+ dir: s08_epi
20
+ type: func
21
+ z_slices: 36
22
+ rep_time: 2.0
23
+ bold_reps: 167
24
+ volumes_to_skip: 3
25
+ # task: "?"
26
+ # physio_files: "#TODO"
27
+ - label: EPI-Resting-fMRI
28
+ dir: s09_epi
29
+ type: func
30
+ z_slices: 36
31
+ rep_time: 2.0
32
+ bold_reps: 167
33
+ volumes_to_skip: 3
34
+ # task: "?"
35
+ # physio_files: "#TODO"
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'rpipe'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,10 @@
1
+ require 'helper'
2
+ require 'pp'
3
+
4
+ class TestDynamicMethodInclusion < Test::Unit::TestCase
5
+ should "include a dynamic method for recon" do
6
+ pipe = RPipe.new(File.join(File.dirname(__FILE__), 'drivers', 'mrt00015_hello.yml'))
7
+ r = pipe.recon_jobs.first
8
+ assert_equal "=== Hello World! ===", r.hello
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+
3
+ class TestIncludes < Test::Unit::TestCase
4
+ should "include the standard implementation of reconstruction" do
5
+ r = Reconstruction.new(
6
+ { 'subid' => 'swallow001', 'rawdir' => nil, 'origdir' => nil, 'procdir' => nil },
7
+ { 'scans' => nil, 'source' => nil, 'method' => nil }
8
+ )
9
+ assert_equal "swallow001", r.subid
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ require 'helper'
2
+ require 'pp'
3
+
4
+ # class TestJohnsonMerit220Preproc < Test::Unit::TestCase
5
+ # should "preprocess raw data" do
6
+ # pipe = RPipe.new('drivers/mrt00015.yml')
7
+ # p = pipe.preproc_jobs.first
8
+ # p.preproc_visit
9
+ # end
10
+ # end
11
+
12
+ # class TestJohnsonMerit220Stats < Test::Unit::TestCase
13
+ # should "run stats on processed data" do
14
+ # pipe = RPipe.new('drivers/mrt00015.yml')
15
+ # s = pipe.stats_jobs.first
16
+ # s.run_first_level_stats
17
+ # end
18
+ # end
19
+
20
+ class TestJohnsonMerit220Integrative < Test::Unit::TestCase
21
+ should "run through a subject." do
22
+ pipe = RPipe.new(File.join(File.dirname(__FILE__), 'drivers', '/mrt00015_hello.yml'))
23
+
24
+ # Run Each Job
25
+ pipe.jobs.each do |job|
26
+ job.perform
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+ require 'pp'
3
+
4
+ class TestRecon < Test::Unit::TestCase
5
+ should "preprocess raw data" do
6
+ driver = ARGV[0] ||= File.join(File.dirname(__FILE__), 'drivers', 'mrt00015.yml')
7
+ pipe = RPipe.new(driver)
8
+ p = pipe.preproc_jobs.first
9
+ p.preproc_visit
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+ require 'pp'
3
+
4
+ class TestRecon < Test::Unit::TestCase
5
+ should "reconstruct raw data" do
6
+ driver = ARGV[0] ||= File.join(File.dirname(__FILE__), 'drivers', 'mrt00015.yml')
7
+ pipe = RPipe.new(driver)
8
+ r = pipe.recon_jobs.first
9
+ r.recon_visit
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+
3
+ class TestRPipe < Test::Unit::TestCase
4
+ should "initialize a pipe from a yml spec file" do
5
+ pipe = RPipe.new(File.join(File.dirname(__FILE__), 'drivers', 'mrt00015.yml'))
6
+
7
+ assert_not_nil pipe.recon_jobs
8
+ assert_not_nil pipe.preproc_jobs
9
+ assert_not_nil pipe.stats_jobs
10
+
11
+ assert_equal 'mrt00015', pipe.jobs.first.subid
12
+ assert_equal '/tmp/mrt00015', pipe.jobs.first.rawdir
13
+ assert_equal '/tmp/mrt00015_orig', pipe.jobs.first.origdir
14
+ assert_equal '/tmp/mrt00015_proc', pipe.jobs.first.procdir
15
+ assert_equal '/tmp/mrt00015_stats', pipe.jobs.first.statsdir
16
+ assert_equal :destroy, pipe.jobs.first.collision_policy
17
+
18
+ end
19
+ end
@@ -0,0 +1,93 @@
1
+ =begin rdoc
2
+
3
+ = OutputCatcher
4
+
5
+ by Matthias Hennemeyer <mhennemeyer@gmail.com>
6
+
7
+ == Introduction
8
+
9
+ OutputCatcher is available as a Rails plugin and as a gem.
10
+ It provides a way to capture the standard out($stdout) or standard error($stderr) of your code without pain
11
+ and suppresses the output of the 'err' or 'out' stream.
12
+
13
+
14
+ == Usage
15
+
16
+ OutputCatcher knows only two methods: .catch_err and .catch_out
17
+
18
+ To capture the stderr of your code:
19
+
20
+ err = OutputCatcher.catch_err do
21
+ $stderr << "error error"
22
+ end
23
+ err #=> "error error"
24
+
25
+
26
+ To capture the stdout of your code:
27
+
28
+ out = OutputCatcher.catch_out do
29
+ puts "Hello Hello"
30
+ end
31
+ out #=> "Hello Hello"
32
+
33
+ == INSTALL:
34
+ Rails:
35
+
36
+ $ ruby script/plugin install git://github.com/mhennemeyer/output_catcher.git
37
+
38
+ Gem:
39
+
40
+ $ gem install mhennemeyer-output_catcher
41
+
42
+
43
+ Copyright (c) 2008 Matthias Hennemeyer, released under the MIT license
44
+
45
+ =end
46
+
47
+ require 'stringio'
48
+
49
+ class OutputCatcher
50
+ class << self
51
+
52
+ def catch_io(post, &block)
53
+ original = eval("$std" + post)
54
+ fake = StringIO.new
55
+ eval("$std#{post} = fake")
56
+ begin
57
+ yield
58
+ ensure
59
+ eval("$std#{post} = original")
60
+ end
61
+ fake.string
62
+ end
63
+
64
+ def catch_out(&block)
65
+ catch_io("out", &block)
66
+ end
67
+
68
+ def catch_err(&block)
69
+ catch_io("err", &block)
70
+ end
71
+
72
+ end
73
+ end
74
+
75
+ class Tee < IO
76
+ FILE_DESC = {:in => 0, :out => 1, :err => 2}
77
+
78
+ def initialize(filename, post = :out, mode_string = 'w')
79
+ super(FILE_DESC[post], mode_string)
80
+ @file = File.open(filename, 'w')
81
+ eval("$std#{post} = self")
82
+ end
83
+
84
+ def write(string)
85
+ STDOUT.write string
86
+ @file.puts string
87
+ @file.flush
88
+ end
89
+
90
+ def self.open(filename, post, mode_string, &block)
91
+
92
+ end
93
+ end