immunoscore_results_aggregator 0.0.3

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.
@@ -0,0 +1,280 @@
1
+ #Copyright (c) 2014, Carlo B. Bifulco. All rights reserved.
2
+
3
+ require_relative "analyzer"
4
+ require_relative "immunoscore_results_loader"
5
+
6
+ require_relative "database_connection"
7
+
8
+ # module Show
9
+ # def show file_path=self.path
10
+ # tf=Tempfile.new ["temp",File.extname(file_path)]
11
+ # tf.write (File.read file_path)
12
+ # tf.close
13
+ # puts "#{tf.path}"
14
+ # fork do
15
+ # `open #{tf.path}`
16
+
17
+ # end
18
+ # puts Process.waitall
19
+ # tf.unlink
20
+ # end
21
+ # end
22
+
23
+ ### Enables all Mongo classes listed below to have instances capable their own CD quicly
24
+ module CdIncluder
25
+ def get_cd
26
+ puts self.cd_type
27
+ if (self.cd_type and self.case_n) != nil
28
+ cd= Cd.get(self.cd_type, self.case_n)
29
+ end
30
+ puts cd
31
+ if cd
32
+ self.cd=cd
33
+ end
34
+ self.save
35
+ end
36
+ end
37
+
38
+ ### enables loading and showing of binary datatsets
39
+ module BinManager
40
+ def load_bin
41
+ self.data_load=File.read path
42
+ end
43
+
44
+ def show graphic_data=self.data_load
45
+ tf=Tempfile.new ["temp",".jpg"]
46
+ tf.write graphic_data
47
+ tf.close
48
+ puts "#{tf.path}"
49
+ fork do
50
+ `open #{tf.path}`
51
+ end
52
+ Process.wait
53
+ tf.unlink
54
+ end
55
+ end
56
+
57
+ class ImmunoScoreResults
58
+ include MongoMapper::Document
59
+ include DataUtilities
60
+ safe
61
+ timestamps!
62
+ many :cd
63
+ key :case_n, String
64
+
65
+ def self.get case_n
66
+ self.find_by_case_n(case_n) or self.create(:case_n=>case_n)
67
+ end
68
+
69
+ end
70
+
71
+
72
+ class Cd
73
+ include MongoMapper::Document
74
+ include DataUtilities
75
+ safe
76
+ timestamps!
77
+ belongs_to :immuno_score_results
78
+ key :cd_type, String
79
+ key :case_n, String
80
+ many :ct_tile
81
+ many :im_tile
82
+ many :statistic
83
+ many :classification
84
+ many :original
85
+ many :density
86
+ many :histogram
87
+
88
+ #either get a brand new cd with its own Immunoscore Results instance of find a preexisting one
89
+ def self.get cd_type, case_n
90
+ self.find_by_cd_type_and_case_n(cd_type,case_n) or self.create(:case_n=>case_n,
91
+ :cd_type=>cd_type,
92
+ :immuno_score_results_id=>ImmunoScoreResults.get(case_n)._id)
93
+ end
94
+ end
95
+
96
+
97
+
98
+
99
+ # {:cd=>"CD3",
100
+ # :path=>
101
+ # "/Volumes/LaCie/patient 1-5/patient 1-5/results/RS_SM02-2576-A4_CD3_2013-11-01 16_52_41.image_0000006553/View_Exports
102
+ # :tile=>"CT2",
103
+ # :case_n=>"SM02-2576-A4",
104
+ # :type=>:ct_tile}}
105
+
106
+ class CtTile
107
+ include MongoMapper::Document
108
+ include DataUtilities
109
+ include CdIncluder
110
+ include BinManager
111
+ extend ClassDataUtilities
112
+ safe
113
+ timestamps!
114
+ belongs_to :cd
115
+ key :tile, String
116
+ key :path, String
117
+ key :case_n, String
118
+ key :cd_type, String
119
+ key :data_load, Binary
120
+ before_save :load_bin
121
+ end
122
+
123
+
124
+
125
+ class ImTile
126
+ include MongoMapper::Document
127
+ include DataUtilities
128
+ include CdIncluder
129
+ include BinManager
130
+ extend ClassDataUtilities
131
+ safe
132
+ timestamps!
133
+ belongs_to :cd
134
+ key :tile, String
135
+ key :path, String
136
+ key :case_n, String
137
+ key :cd_type, String
138
+ key :data_load, Binary
139
+ before_save :load_bin
140
+ end
141
+
142
+ # {:case=>"SM02-2456-A6",
143
+ # :cd=>"CD8",
144
+ # :path=>
145
+ # "/Volumes/LaCie/patient 1-5/patient 1-5/results/RS_SM02-2456-A6_CD8_2013-11-01 14_27_27.image_0000006515/image_000000
146
+ # :type=>:classification},
147
+ class Classification
148
+ include MongoMapper::Document
149
+ include DataUtilities
150
+ include CdIncluder
151
+ include BinManager
152
+ extend ClassDataUtilities
153
+ safe
154
+ timestamps!
155
+ belongs_to :cd
156
+ key :path, String
157
+ key :case_n, String
158
+ key :cd_type, String
159
+ key :data_load, Binary
160
+ before_save :load_bin
161
+ end
162
+
163
+ class Original
164
+ include MongoMapper::Document
165
+ include DataUtilities
166
+ include CdIncluder
167
+ include BinManager
168
+ extend ClassDataUtilities
169
+ safe
170
+ timestamps!
171
+ belongs_to :cd
172
+ key :path, String
173
+ key :case_n, String
174
+ key :cd_type, String
175
+ key :data_load, Binary
176
+ before_save :load_bin
177
+ end
178
+
179
+ # {:case=>"RS_SM02-2576-A4_CD3_2013-11-01 16_52_41.image_0000006553",
180
+ # :path=>
181
+ # "/Volumes/LaCie/patient 1-5/patient 1-5/results/RS_SM02-2576-A4_CD3_2013-11-01 16_52_41.image_0000006553/Statistic_Exports/RS_SM02-2576-A4_CD3_2013-11-01 16_52_41.image_0000006553_Statistics.csv",
182
+ # :cd=>"CD3",
183
+ # :type=>:statistics}
184
+
185
+ class Statistic
186
+ include MongoMapper::Document
187
+ include DataUtilities
188
+ include CdIncluder
189
+ include BinManager
190
+ extend ClassDataUtilities
191
+ safe
192
+ timestamps!
193
+ belongs_to :cd
194
+ key :path, String
195
+ key :case_n, String
196
+ key :cd_type, String
197
+ key :data_load, Binary
198
+ before_save :load_bin
199
+ end
200
+
201
+
202
+ # {:path=>
203
+ # "/Volumes/LaCie/patient 1-5/patient 1-5/results/RS_SM02-2576-A4_CD3_2013-11-01 16_52_41.image_0000006553/View_Exports
204
+ # :case=>"SM02-2576-A4",
205
+ # :new_old=>"old",
206
+ # :cd=>"CD3",
207
+ # :type=>"density"}
208
+ class Density
209
+ include MongoMapper::Document
210
+ include DataUtilities
211
+ include CdIncluder
212
+ include BinManager
213
+ extend ClassDataUtilities
214
+ safe
215
+ timestamps!
216
+ belongs_to :cd
217
+ key :path, String
218
+ key :case_n, String
219
+ key :cd_type, String
220
+ key :new_old, String
221
+ key :data_load, Binary
222
+ before_save :load_bin
223
+ end
224
+
225
+
226
+ # {:path=>
227
+ # "/Volumes/LaCie/patient 1-5/patient 1-5/results/RS_SM02-2366-A5_CD8_2013-11-01 16_55_57.image_0000006556/View_Exports
228
+ # :case=>"SM02-2366-A5",
229
+ # :type=>:histogram,
230
+ # :cd=>"CD8"}
231
+ class Histogram
232
+ include MongoMapper::Document
233
+ include DataUtilities
234
+ include CdIncluder
235
+ include BinManager
236
+ extend ClassDataUtilities
237
+ safe
238
+ timestamps!
239
+ belongs_to :cd
240
+ key :path, String
241
+ key :case_n, String
242
+ key :cd_type, String
243
+ key :data_load, Binary
244
+ before_save :load_bin
245
+ end
246
+
247
+
248
+ class Test
249
+ include MongoMapper::Document
250
+ include DataUtilities
251
+ include CdIncluder
252
+ include BinManager
253
+ extend ClassDataUtilities
254
+
255
+ key :path, String
256
+
257
+ key :data_load, Binary
258
+ before_save :load_bin
259
+
260
+
261
+ end
262
+
263
+
264
+
265
+ ### mapping from definiens file type to proper database entity
266
+ JSON_CLASS_MAPPER={:ct_tile=>CtTile,
267
+ :im_tile=>ImTile,
268
+ :classification=>Classification,
269
+ :original=>Original,
270
+ :statistic=>Statistic,
271
+ :density=>Density,
272
+ :histogram=>Histogram}
273
+
274
+
275
+ ### resets all databases
276
+ def mm_clean_all
277
+ [ImmunoScoreResults, Cd, Histogram, Density, Statistic, Original, Classification, ImTile, CtTile].each do |mm_class|
278
+ mm_class.delete_all
279
+ end
280
+ end
@@ -0,0 +1,4 @@
1
+ require "yaml"
2
+ require "mongo_mapper"
3
+ require_relative "../config.rb"
4
+ MongoMapper.database = DATABASE_NAME
data/lib/exporter.rb ADDED
@@ -0,0 +1,76 @@
1
+ #Copyright (c) 2014, Carlo B. Bifulco. All rights reserved.
2
+
3
+
4
+ require "csv"
5
+ require_relative "analyzer"
6
+ require_relative "data_struct"
7
+ require_relative "immunoscore_results_loader"
8
+ require_relative "../config.rb"
9
+
10
+
11
+
12
+ def export_clean_all
13
+ `rm -rf #{EXPORT_DIR}/*`
14
+ end
15
+
16
+ def cd3? file_path
17
+ not (file_path !~ /_CD3_/)
18
+ end
19
+
20
+ def cd8? file_path
21
+ not (file_path !~ /_CD8_/)
22
+ end
23
+
24
+ def export_file case_dir,file_path
25
+ if cd8? file_path
26
+ Dir.mkdir(case_dir+"/CD8") unless Dir.exist?(case_dir+"/CD8")
27
+ fh=File.new(case_dir+"/CD8/"+File.basename(file_path),"w")
28
+ else
29
+ Dir.mkdir(case_dir+"/CD3") unless Dir.exist?(case_dir+"/CD3")
30
+ fh=File.new(case_dir+"/CD3/"+File.basename(file_path),"w")
31
+ end
32
+
33
+ end
34
+
35
+ # exports novel directory structure with only relevant files
36
+ def export_mongo
37
+ # defined in immunoscore_results_loader
38
+ JSON_CLASS_MAPPER.values.each do |mm_class|
39
+ mm_class.all.each do |mm_object|
40
+ puts "#{mm_object}: #{mm_object[:case_n]}"
41
+ next unless mm_object[:case_n] != nil
42
+ case_dir=(EXPORT_DIR+"/"+ mm_object[:case_n])
43
+ Dir.mkdir case_dir unless Dir.exist?(case_dir)
44
+ fh=export_file case_dir, mm_object[:path]
45
+ fh.write(mm_object[:data_load])
46
+ fh.close
47
+
48
+ end
49
+ end
50
+ end
51
+
52
+
53
+
54
+ def make_html reporting_order=[
55
+ :histogram,
56
+ :original,
57
+ :density,
58
+ :ct_tile,
59
+ :im_tile,
60
+ :statistic,
61
+ :classification]
62
+ all_cases=[]
63
+ ImmunoScoreResults.all.each do |i|
64
+ case_summary=[]
65
+ i.cd.sort.each do |slide_cd|
66
+ reporting_order.each do |feature|
67
+ slide_cd.public_send(feature).sort!{|a,b| a.path<=>b.path}.each do |report|
68
+ #binding.pry
69
+ case_summary<< report[:path]
70
+ end
71
+ end
72
+ end
73
+ all_cases << case_summary
74
+ end
75
+ all_cases
76
+ end
@@ -0,0 +1,3 @@
1
+ module ImmunoscoreTest
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,218 @@
1
+ #Copyright (c) 2014, Carlo B. Bifulco. All rights reserved.
2
+
3
+ require "csv"
4
+ require "yaml"
5
+ require "mongo_mapper"
6
+ require_relative "database_connection"
7
+ require_relative "analyzer"
8
+ require_relative "data_struct"
9
+ require_relative "../config.rb"
10
+
11
+ #puts "WORKING #{`pwd`}; exists #{File.exists?("../config.yaml")}"
12
+
13
+
14
+ ###Pull info from Definiens Immunoscore Directories
15
+ #
16
+ # pattern matching based
17
+
18
+
19
+ # filename convetions
20
+ # RS_SP02-15779-A8__CD3_2013...
21
+ # no underscores in the file name after the RS prefix
22
+ # they are required before and after case number for pattern matching
23
+
24
+ #### A few examples of what we are looking for
25
+ #
26
+ #image_0000006499_Classification.jpg
27
+ #image_0000006504_Original.jpg
28
+ #.image_0000006506_densitymap_new.jpg
29
+ #.image_0000006506_histogram.jpg
30
+ #image_0000006506_CT1.jpg. CT2, CT3
31
+ #IM1, IM2, IM3
32
+
33
+
34
+ #BASE_DIR="/Volumes/I\$/Christopher\ Paustian/Colon\ Immunoscore"
35
+
36
+ ### regex utilities
37
+ def pull_cd path
38
+ path.match(/.*(CD[8|3]).*/)[1] if path.match(/.*(CD[8|3]).*/)
39
+ end
40
+
41
+ def pull_ct path
42
+ pattern=/.*(CT[1|2|3|4|5|6|7|8])\.jpg/
43
+ path.match(pattern)[1] if path.match(pattern)
44
+ end
45
+
46
+ def pull_im path
47
+ pattern=/.*(IM[1|2|3|4|5|6|7|8])\.jpg/
48
+ path.match(pattern)[1] if path.match(pattern)
49
+ end
50
+
51
+ #### Case identification
52
+ # matched file names staring with RS follow by either - or _ followed by SP03
53
+ #followed by either - or _ followed by case number. Matching of teh block
54
+ # number is not included
55
+ def get_case_n path
56
+ match=path.match(/(RS[_-].?.?.?.?.[-_]\d*)/i)
57
+ match[0] if match
58
+ end
59
+
60
+
61
+ ### core function
62
+ def find_files file_name_ending="*Classification.jpg", base_dir=BASE_DIR
63
+ results=[]
64
+ Dir.glob("#{base_dir}/**/#{file_name_ending}").each do |full_path|
65
+ puts "am working on #{full_path}"
66
+ directory_name=full_path.split("\/")[-4]
67
+ case_name=get_case_n full_path
68
+ cd=directory_name.split("_")[2]
69
+ results << {:case_n=>case_name,
70
+ :cd_type =>cd,
71
+ :path=>full_path}
72
+ end
73
+ results
74
+ end
75
+
76
+
77
+ #### special functions
78
+
79
+ def find_ct
80
+ find_files(file_name_ending="*image*CT*.jpg").map{|x| x[:path]}.map do |path|
81
+ case_n=get_case_n path
82
+ cd =pull_cd(path)
83
+ tile=pull_ct path
84
+ {:cd_type=>cd, :path=>path, :tile=>tile, :case_n=>case_n, :type=>:ct_tile}
85
+ end
86
+ end
87
+
88
+ def find_im
89
+ find_files(file_name_ending="*image*IM*.jpg").map{|x| x[:path]}.map do |path|
90
+ case_n=get_case_n path
91
+ cd =pull_cd(path)
92
+ tile=pull_im path
93
+ {:cd_type=>cd, :path=>path, :tile=>tile, :case_n=>case_n,:type=>:im_tile}
94
+ end
95
+ end
96
+
97
+ def find_classification
98
+ find_files(file_name_ending="*Classification.jpg").map do |x|
99
+ x.merge({:type => :classification})
100
+ end
101
+ end
102
+
103
+ def find_original
104
+ find_files(file_name_ending="*Original.jpg").map do |x|
105
+ x.merge({:type => :original})
106
+ end
107
+ end
108
+
109
+ def find_statistics
110
+ find_files(file_name_ending="*Statistics.csv").map do |x|
111
+ puts x
112
+ {:case_n=> x[:case_n],
113
+ :path=> x[:path],
114
+ :cd_type=>pull_cd(x[:path]),
115
+ :type=> :statistic}
116
+ end
117
+ end
118
+
119
+
120
+ def find_density
121
+ find_files(file_name_ending="*densitymap*.jpg").map do |x|
122
+ path=x[:path]
123
+ case_n=get_case_n path
124
+ new_old=path.gsub(".jpg","")[-3..-1]
125
+ {:path=>path, :case_n=>case_n, :new_old=>new_old,
126
+ :cd_type=>pull_cd(path),:type=>:density}
127
+ end
128
+ end
129
+
130
+ def find_histogram
131
+ find_files(file_name_ending="*histogram.jpg").map do |x|
132
+ path=x[:path]
133
+ case_n=get_case_n path
134
+ cd=pull_cd(path)
135
+ {:path=>path, :case_n=>case_n,:type=>:histogram, :cd_type=>cd}
136
+ end
137
+ end
138
+
139
+
140
+ #### merges all the JSON structures coming from the search functions
141
+ # some metaprogramming: calls all find functions listed above
142
+ def search_all
143
+ r=[]
144
+ [:find_histogram,:find_density,:find_statistics,:find_original, :find_classification, :find_im,:find_ct].each do |m|
145
+ r << self.send(m)
146
+ puts "Done with #{m}"
147
+ end
148
+ r.flatten
149
+ end
150
+
151
+
152
+ class NilClass
153
+ def to_sym
154
+ false
155
+ end
156
+ end
157
+
158
+
159
+ ### query to ensure that entries are not recreated in teh database, but only paths and blobs are updated
160
+ def make_query data_set
161
+ if data_set.has_key?(:new_old)
162
+ query={:case_n => data_set[:case_n],:cd_type=>data_set[:cd_type], :new_old=>data_set[:new_old]}
163
+ elsif data_set.has_key?(:tile)
164
+ query={:case_n => data_set[:case_n],:cd_type=>data_set[:cd_type], :tile=>data_set[:tile]}
165
+ else
166
+ query={:case_n => data_set[:case_n],:cd_type=>data_set[:cd_type]}
167
+ end
168
+ query
169
+ end
170
+
171
+
172
+ #### load datasets in their mongo classes
173
+ #
174
+ # if entry preexisting updates results
175
+ #
176
+ #
177
+ def mongo_load_all search_results=search_all(), json_class_mapper=JSON_CLASS_MAPPER
178
+ search_results.each_with_index do |data_set,i|
179
+ puts "#{i}: #{data_set}"
180
+ puts data_set["type"]
181
+ mm_class=( json_class_mapper[data_set["type"]].to_sym or json_class_mapper[data_set[:type]])
182
+ puts "mm_class=#{mm_class}"
183
+ #puts "data set type=#{data_set[:type]}"
184
+ puts "class =#{mm_class}"
185
+ query=make_query data_set
186
+ puts "query= #{query}"
187
+ #query= {:case_n=>"RS-SV-05-16335", :cd_type=>"CD8", :tile=>"CT4"}
188
+ if mm_class.where(query).all.empty?
189
+ mm_object=mm_class.create data_set
190
+ puts "mm created #{mm_object}"
191
+ else
192
+ # upserts if entry pre-existing
193
+ mm_class.set(query, data_set, :upsert => true )
194
+ puts "uspsert created #{mm_object}"
195
+ mm_object=mm_class.where(data_set).find_one
196
+ end
197
+ #binding.pry
198
+ mm_object.get_cd
199
+ mm_object.save
200
+
201
+ end
202
+ puts "\n\n\n"
203
+ puts "finished uploading to databes"
204
+ end
205
+
206
+ def show graphic_data
207
+ tf=Tempfile.new ["temp",".jpg"]
208
+ tf.write graphic_data
209
+ tf.close
210
+ puts "#{tf.path}"
211
+ fork do
212
+ `open #{tf.path}`
213
+ end
214
+ Process.wait
215
+ tf.unlink
216
+ end
217
+
218
+
@@ -0,0 +1,106 @@
1
+ #Copyright (c) 2014, Carlo B. Bifulco. All rights reserved.
2
+
3
+ require_relative "analyzer"
4
+ require_relative "data_struct"
5
+ require_relative "immunoscore_results_loader"
6
+
7
+
8
+
9
+ class StatResults
10
+ include MongoMapper::Document
11
+ include DataUtilities
12
+ include CdIncluder
13
+ include BinManager
14
+ extend ClassDataUtilities
15
+ safe
16
+ timestamps!
17
+ key :case_n, String
18
+ key :file_name, String
19
+ key :tissue_detection_threshold, Integer
20
+ key :brown_threshold, Integer
21
+ key :mean_brown, Integer
22
+ key :median_brown, Float
23
+ key :sd_brown, Float
24
+ key :minimum_brown, Integer
25
+ key :maximum_brown, Float
26
+ key :mean_3_most_infiltrated_ct, Integer
27
+ key :density_ct_tile_1, Integer
28
+ key :area_ct_tile_1, Integer
29
+ key :number_of_cells_ct_tile_1, Integer
30
+ key :density_ct_tile_2, Integer
31
+ key :area_ct_tile_2, Integer
32
+ key :number_of_cells_ct_tile_2, Integer
33
+ key :density_ct_tile_3, Integer
34
+ key :area_ct_tile_3, Integer
35
+ key :number_of_cells_ct_tile_3, Integer
36
+ key :density_ct_tile_4, Integer
37
+ key :area_ct_tile_4, Integer
38
+ key :number_of_cells_ct_tile_4, Integer
39
+ key :density_ct_tile_5, Integer
40
+ key :area_ct_tile_5, Integer
41
+ key :number_of_cells_ct_tile_5, Integer
42
+ key :mean_3_most_infiltrated_im, Integer
43
+ key :density_im_tile_1, Integer
44
+ key :area_im_tile_1, Integer
45
+ key :number_of_cells_im_tile_1, Integer
46
+ key :density_im_tile_2, Integer
47
+ key :area_im_tile_2, Integer
48
+ key :number_of_cells_im_tile_2, Integer
49
+ key :density_im_tile_3, Integer
50
+ key :area_im_tile_3, Integer
51
+ key :number_of_cells_im_tile_3, Integer
52
+ key :density_im_tile_4, Integer
53
+ key :area_im_tile_4, Integer
54
+ key :number_of_cells_im_tile_4, Integer
55
+ key :density_im_tile_5, Integer
56
+ key :area_im_tile_5, Integer
57
+ key :number_of_cells_im_tile_5, Integer
58
+ key :old_mean_3_most_infiltrated_ct, Integer
59
+ key :old_density_ct_tile_1, Integer
60
+ key :old_area_ct_tile_1, Integer
61
+ key :old_number_of_cells_ct_tile_1, Integer
62
+ key :old_density_ct_tile_2, Integer
63
+ key :old_area_ct_tile_2, Integer
64
+ key :old_number_of_cells_ct_tile_2, Integer
65
+ key :old_density_ct_tile_3, Integer
66
+ key :old_area_ct_tile_3, Integer
67
+ key :old_number_of_cells_ct_tile_3, Integer
68
+ key :old_density_ct_tile_4, Integer
69
+ key :old_area_ct_tile_4, Integer
70
+ key :old_number_of_cells_ct_tile_4, Integer
71
+ key :old_density_ct_tile_5, Integer
72
+ key :old_area_ct_tile_5, Integer
73
+ key :old_number_of_cells_ct_tile_5, Integer
74
+ key :old_mean_3_most_infiltrated_im, Integer
75
+ key :old_density_im_tile_1, Integer
76
+ key :old_area_im_tile_1, Integer
77
+ key :old_number_of_cells_im_tile_1, Integer
78
+ key :old_density_im_tile_2, Integer
79
+ key :old_area_im_tile_2, Integer
80
+ key :old_number_of_cells_im_tile_2, Integer
81
+ key :old_density_im_tile_3, Integer
82
+ key :old_area_im_tile_3, Integer
83
+ key :old_number_of_cells_im_tile_3, Integer
84
+ key :old_density_im_tile_4, Integer
85
+ key :old_area_im_tile_4, Integer
86
+ key :old_number_of_cells_im_tile_4, Integer
87
+ key :old_density_im_tile_5, Integer
88
+ key :old_area_im_tile_5, Integer
89
+ key :old_number_of_cells_im_tile_5, Integer
90
+ end
91
+
92
+
93
+ ### aggregates in a single spreadsheat all csv/stat files entries present in database
94
+ def write_stats_csv file_path
95
+ csv_array=[]<< Statistic.all[0].data_load.to_s.split("\n")[0]
96
+ ###Stat Results will contain all datasets in an csv format
97
+ Statistic.all.each do |stat_entry|
98
+ csv_array<<stat_entry.data_load.to_s.split("\n")[1]
99
+ end
100
+ csv_array
101
+ fh=File.new(file_path,"w")
102
+ csv_array.each{|l| fh.write(l+"\n")}
103
+ fh.close
104
+ end
105
+
106
+