tasci_merger 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd3e333e1f5e530dc5d787a353b3e0ca9d93b0f9
4
- data.tar.gz: 5bf68b195adba0290cbd0342d00d7283149eb235
3
+ metadata.gz: 3ee0a6748202ef6011e7ea7874beba30d2c6793e
4
+ data.tar.gz: 92226f6f49b06a61da8048f56a9a0b19bb30383e
5
5
  SHA512:
6
- metadata.gz: 591c91f176a71103eb577b8d147cd40a2a6a20519077dde6a4b26f8c6b93c861750678e46960ae80f365d158cc0acb6ef04c06f11a5431b2052aa2e334667a18
7
- data.tar.gz: a58b5d6d11dadf6e2685348da713c826ef91380352202864b858c3c96c5d9b6ddcf32e92657e758afd182b901fabba0bc84a1a611dee35a73c6520e14fae264c
6
+ metadata.gz: 5f05efeb325926df9aa0953367cbb0626598ff22234201e4557614566c20e9ae6a046c0d4ca0960ba5ce4723899a64fe0657688b4b229c1249d13d3f6e0952c5
7
+ data.tar.gz: 2b456248a907b62e02c8ea2a9e0054500ada0b222ecb83e7c1fba65d988f650ca296a473de0b01d438ce876a91226639d9608c1ed97d0130b6ea530ed5dedb24
data/README.md CHANGED
@@ -71,7 +71,7 @@ The command creates a master file and merged file in the output directory.
71
71
  **Example Usage:**
72
72
 
73
73
  ```
74
- tasci_merger 3441GX X:/TasciFilesFor3441GX C:/Circadian
74
+ merge_tasci 3441GX X:/TasciFilesFor3441GX C:/Circadian
75
75
  ```
76
76
 
77
77
  This command would create the 2 files in the `C:/Circadian` directory.
data/lib/tasci_merger.rb CHANGED
@@ -122,6 +122,9 @@ class TasciMerger
122
122
  merged_file = CSV.open(File.join(@output_directory, "#{@subject_code}_merged_#{Time.zone.now.strftime("%Y%m%d")}.csv"), "wb")
123
123
  merged_file << %w(SUBJECT_CODE FILE_NAME_SLEEP_WAKE_EPISODE LABTIME SLEEP_STAGE LIGHTS_OFF_ON_FLAG SEM_FLAG)
124
124
 
125
+ simple_merged_file = CSV.open(File.join(@output_directory, "#{@subject_code}_merged_simple_#{Time.zone.now.strftime("%Y%m%d")}.csv"), "wb")
126
+ simple_merged_file << %w(SLEEP_STAGE LABTIME)
127
+
125
128
  previous_first_labtime = nil
126
129
  previous_last_labtime = nil
127
130
 
@@ -246,16 +249,60 @@ class TasciMerger
246
249
  # 0 No Slow Eye Movement
247
250
  sem_event = (fields[7] =~ /SEM/ ? 1 : 0)
248
251
 
249
- # Previous Effort:
250
- #line_time = Time.zone.local(file_info[:record_full_time].year, file_info[:record_full_time].month, file_info[:record_full_time].day, fields[4].to_i, fields[5].to_i, fields[6].to_i)
251
- #line_labtime = Labtime.parse(line_time)
252
+
253
+
254
+
255
+ # Alternate Coding:
256
+ # 0 - UNDEF
257
+ # 1 - N1
258
+ # 2 - N2
259
+ # 3 - N3
260
+ # 4 - 4
261
+ # 5 - Wake
262
+ # 6 - REM
263
+ # 7 - MT
264
+ # 8 - Sleep Onset (LIGHTS OFF)
265
+ # 9 - Lights On
266
+
267
+ ### SLEEP STAGE, LABTIME
268
+ simple_line_event = nil
269
+ if fields[8] == "Wake"
270
+ simple_line_event = 5
271
+ elsif fields[8] == "Undefined"
272
+ simple_line_event = 0
273
+ elsif fields[8] == "N1"
274
+ simple_line_event = 1
275
+ elsif fields[8] == "N2"
276
+ simple_line_event = 2
277
+ elsif fields[8] == "N3"
278
+ simple_line_event = 3
279
+ elsif fields[8] == "4"
280
+ simple_line_event = 4
281
+ elsif fields[8] == "REM"
282
+ simple_line_event = 6
283
+ elsif fields[8] == "MVT"
284
+ simple_line_event = 7
285
+ else
286
+ raise StandardError, "Cannot map the following event: #{fields[8]}"
287
+ end
288
+
289
+ if sleep_period == 1
290
+ simple_line_event = 8
291
+ elsif sleep_period == 2
292
+ simple_line_event = 9
293
+ end
294
+
295
+
296
+
297
+
252
298
 
253
299
  first_labtime = line_labtime if first_labtime.nil?
254
300
  last_labtime = line_labtime
255
301
 
256
302
  output_line = [@subject_code.upcase, file_info[:sleep_wake_episode], line_labtime.to_decimal, line_event, sleep_period, sem_event]
303
+ simple_output_line = [simple_line_event, line_labtime.to_decimal]
257
304
  merged_file << output_line
258
-
305
+ simple_merged_file << simple_output_line
259
306
 
260
307
  #MY_LOG.info fields
261
308
  end
@@ -270,6 +317,7 @@ class TasciMerger
270
317
  previous_last_labtime = last_labtime
271
318
  end
272
319
  merged_file.close
320
+ simple_merged_file.close
273
321
  end
274
322
 
275
323
  end
data/tasci_merger.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'tasci_merger'
3
- s.version = '0.0.1'
3
+ s.version = '0.1.0'
4
4
  s.date = '2015-02-06'
5
5
  s.summary = "Merger utility for TASCI scored sleep files."
6
6
  s.description = "Merger utility for TASCI scored sleep files, built for the Division of Sleep and Circadian Disorders at BWH."
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.required_ruby_version = '>= 2.1.0'
17
17
 
18
18
  s.add_dependency "activesupport", '~> 4.2', '>= 4.2.0'
19
- s.add_dependency "tzinfo-data"
19
+ s.add_dependency "tzinfo-data", '~> 1'
20
20
  end
21
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tasci_merger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Mankowski
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: tzinfo-data
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: '1'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ">="
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
46
+ version: '1'
47
47
  description: Merger utility for TASCI scored sleep files, built for the Division of
48
48
  Sleep and Circadian Disorders at BWH.
49
49
  email: pmankowski@partners.org