metamri 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGQ1ZTRjNjZkY2E3NmVkNDgyYmNhM2Y3MGYyZDcwNGQzOTc4Y2UxNA==
5
+ data.tar.gz: !binary |-
6
+ NWUxZDA4ZjQ1N2ExYTk0NjI3OGI1ZWMyZDk5ZTEyNGQxODg0MTM3MQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NjEyYmJkMjdjMDBlZjM1M2Y0OGM3NGEwNjQ1MTczMWViYzJlNTI1MzcwZTEw
10
+ YTBjYTljMjE4ZmNlMWQ4YTAwNjFhMTc5ZDZjOThhN2JhMDZmODI5ZjhjOTYz
11
+ NWVhZGY2NmM2MDRhYzE4NjY4MzMwMWQ4MDczYjFhZDNkNjNjZWE=
12
+ data.tar.gz: !binary |-
13
+ YTAwMWRiOTgzNDA2OTY5YTBjMDhlZjIxYWQzZDgwZmY3YTgxNGI0NzU2ZTEy
14
+ MzRlY2RmZTRiYjNiZWU2OWYyYTFhNzM1YjEzZjJmNDMxZWE4YjQ4M2JjMWVi
15
+ ZWQ5OTliNTY3OGY1NTQ0NzMxMDE4NmFmZmFjNTcyMGZlYzZkNTg=
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
-
4
3
  # Specify your gem's dependencies in metamri.gemspec
5
4
  gemspec
data/bin/convert_visit.rb CHANGED
@@ -42,7 +42,7 @@ def convert_visit(raw_directory, scan_procedure_codename, output_directory = nil
42
42
  output_directory = output_directory ||= v.default_preprocess_directory
43
43
 
44
44
  begin
45
- default_options = {:ignore_patterns => [/vipr/,/900$/,/901$/,/999$/]} # seems to like number , not like string
45
+ default_options = {:ignore_patterns => [/vipr/,/$Processed-Images$/,/900$/,/901$/,/999$/]} # seems to like number , not like string
46
46
  #options = default_options.merge(options)
47
47
  v.scan(default_options)
48
48
  v.to_nifti!(output_directory)
@@ -19,8 +19,9 @@ class RawImageFile
19
19
  MIN_HDR_LENGTH = 400
20
20
  DICOM_HDR = "dicom_hdr"
21
21
  RDGEHDR = "rdgehdr"
22
+ PRINTRAW = "printraw"
22
23
  RUBYDICOM_HDR = "rubydicom"
23
- VALID_HEADERS = [DICOM_HDR, RDGEHDR, RUBYDICOM_HDR]
24
+ VALID_HEADERS = [DICOM_HDR, PRINTRAW, RDGEHDR, RUBYDICOM_HDR]
24
25
  MONTHS = {
25
26
  :jan => "01", :feb => "02", :mar => "03", :apr => "04", :may => "05",
26
27
  :jun => "06", :jul => "07", :aug => "08", :sep => "09", :oct => "10",
@@ -269,15 +270,25 @@ private
269
270
 
270
271
  case File.basename(absfilepath)
271
272
  when /^P.{5}\.7$|^I\..{3}/
272
- # Try reading Pfiles or Genesis I-Files with GE's rdgehdr
273
- @current_hdr_reader = RDGEHDR
274
- header = `#{RDGEHDR} '#{absfilepath}' 2> /dev/null`
273
+ # Try reading Pfiles or Genesis I-Files with GE's printraw
274
+ @current_hdr_reader = PRINTRAW
275
+ header = `#{PRINTRAW} '#{absfilepath}' 2> /dev/null`
275
276
  #header = `#{RDGEHDR} #{absfilepath}`
276
277
  if ( header.chomp != "" and
277
278
  header.length > MIN_HDR_LENGTH )
278
279
  @current_hdr_reader = nil
279
- return [ header, RDGEHDR ]
280
+ return [ header, PRINTRAW ]
280
281
  end
282
+ # Try reading Pfiles or Genesis I-Files with GE's rdgehdr -- rdgehdr newer version needs macos 10.8, adrcdev2 = 10.7.5 -
283
+ # works on old headers, not on new header format
284
+ ###@current_hdr_reader = RDGEHDR
285
+ ###header = `#{RDGEHDR} '#{absfilepath}' 2> /dev/null`
286
+ #header = `#{RDGEHDR} #{absfilepath}`
287
+ ###if ( header.chomp != "" and
288
+ ### header.length > MIN_HDR_LENGTH )
289
+ ### @current_hdr_reader = nil
290
+ ### return [ header, RDGEHDR ]
291
+ ### end
281
292
  else
282
293
  # Try reading with RubyDICOM
283
294
  @current_hdr_reader = RUBYDICOM_HDR
@@ -323,6 +334,7 @@ private
323
334
  case @hdr_reader
324
335
  when "rubydicom" then rubydicom_hdr_import
325
336
  when "dicom_hdr" then dicom_hdr_import
337
+ when "printraw" then printraw_import
326
338
  when "rdgehdr" then rdgehdr_import
327
339
  end
328
340
  end
@@ -573,6 +585,76 @@ private
573
585
 
574
586
  end
575
587
 
588
+ def printraw_import
589
+ source_pat = /hospital [Nn]ame: ([[:graph:]\t ]+)/i
590
+ num_slices_pat = /rdb_hdr_nslices = ([0-9]+)/i
591
+ slice_thickness_pat = /slthick = ([[:graph:]]+)/i
592
+ slice_spacing_pat = /scanspacing = ([[:graph:]]+)/i
593
+ date_pat = /ex_datetime = (.*)\n/i
594
+ gender_pat = /patsex = (1|2)/i
595
+ acquisition_matrix_x_pat = /imatrix_X = ([0-9]+)/i
596
+ acquisition_matrix_y_pat = /imatrix_Y = ([0-9]+)/i
597
+ series_description_pat = /se_desc = ([[:graph:] \t]+)/i
598
+ recon_diam_pat = /dfov = ([0-9]+)/i
599
+ rmr_number_pat = /Patient ID for this exam: ([[:graph:]]+)/i
600
+ bold_reps_pat = /nex = ([0-9]+)/i
601
+ rep_time_pat = /reptime = ([0-9]+)/i # not sure ifg this is right
602
+ study_uid_pat = /Ssop_uid = ([[:graph:]]+)/i
603
+ series_uid_pat = /series_uid = ([[:graph:]]+)/i
604
+ image_uid_pat = /image_uid = (.*)/i #([[:graph:]]+)/i
605
+
606
+
607
+ rmr_number_pat =~ @hdr_data
608
+ @rmr_number = ($1).nil? ? "rmr not found" : ($1).strip.chomp
609
+
610
+ source_pat =~ @hdr_data
611
+ @source = ($1).nil? ? "source not found" : ($1).strip.chomp
612
+
613
+ num_slices_pat =~ @hdr_data
614
+ @num_slices = ($1).to_i
615
+
616
+ slice_thickness_pat =~ @hdr_data
617
+ @slice_thickness = ($1).to_f
618
+
619
+ slice_spacing_pat =~ @hdr_data
620
+ @slice_spacing = ($1).to_f
621
+
622
+ date_pat =~ @hdr_data
623
+ @timestamp = Time.at($1.to_i).to_datetime
624
+ # @timestamp = DateTime.parse($1) --- 2 rows- same start of line- first since epoch, 2nd date stamnp
625
+
626
+ gender_pat =~ @hdr_data
627
+ @gender = $1 == 1 ? "M" : "F"
628
+
629
+ acquisition_matrix_x_pat =~ @hdr_data
630
+ @acquisition_matrix_x = ($1).to_i
631
+ acquisition_matrix_y_pat =~ @hdr_data
632
+ @acquisition_matrix_y = ($1).to_i
633
+
634
+ series_description_pat =~ @hdr_data
635
+ @series_description = ($1).strip.chomp
636
+
637
+
638
+ recon_diam_pat =~ @hdr_data
639
+ @reconstruction_diameter = ($1).to_i
640
+
641
+ bold_reps_pat =~ @hdr_data
642
+ @bold_reps = ($1).to_i
643
+
644
+ rep_time_pat =~ @hdr_data
645
+ @rep_time = ($1).to_f / 1000000
646
+
647
+
648
+ study_uid_pat =~ @hdr_data
649
+ @study_uid = ($1).strip.chomp unless $1.nil?
650
+
651
+ series_uid_pat =~ @hdr_data
652
+ @series_uid = ($1).strip.chomp unless $1.nil?
653
+
654
+ image_uid_pat =~ @hdr_data
655
+ @image_uid = ($1).strip.chomp unless $1.nil?
656
+
657
+ end
576
658
 
577
659
  # Extracts a collection of metadata from @hdr_data retrieved using the rdgehdr
578
660
  # utility.
@@ -631,6 +713,7 @@ private
631
713
 
632
714
  rep_time_pat =~ @hdr_data
633
715
  @rep_time = ($1).to_f / 1000000
716
+
634
717
 
635
718
  study_uid_pat =~ @hdr_data
636
719
  @study_uid = ($1).strip.chomp unless $1.nil?
@@ -1,3 +1,3 @@
1
1
  module Metamri
2
- VERSION = "0.2.16"
2
+ VERSION = "0.2.17"
3
3
  end
data/metamri.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
 
20
20
  s.add_runtime_dependency('dicom', "~> 0.8.0")
21
21
  s.add_runtime_dependency('activeresource', "~> 3.0")
22
- ##### s.add_runtime_dependency('rmagick', "~> 2.13.1")
22
+ # s.add_runtime_dependency('rmagick')
23
23
  s.add_runtime_dependency('hirb', "~> 0.4")
24
24
  s.add_runtime_dependency('sqlite3', "~>1.3.4")
25
25
  s.add_development_dependency('rspec', "~> 2.5")
metadata CHANGED
@@ -1,127 +1,111 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: metamri
3
- version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 16
10
- version: 0.2.16
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.17
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Kristopher J. Kosmatka
14
8
  - Erik Kastman
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2013-03-25 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-10-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: dicom
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
27
18
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 63
30
- segments:
31
- - 0
32
- - 8
33
- - 0
19
+ - !ruby/object:Gem::Version
34
20
  version: 0.8.0
35
21
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: activeresource
39
22
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 0.8.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: activeresource
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
43
32
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 3
48
- - 0
49
- version: "3.0"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
50
35
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: hirb
54
36
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: hirb
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
58
46
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- - 4
64
- version: "0.4"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.4'
65
49
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: sqlite3
69
50
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
73
53
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 19
76
- segments:
77
- - 1
78
- - 3
79
- - 4
54
+ - !ruby/object:Gem::Version
55
+ version: '0.4'
56
+ - !ruby/object:Gem::Dependency
57
+ name: sqlite3
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
80
62
  version: 1.3.4
81
63
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
64
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.4
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
89
74
  - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 9
92
- segments:
93
- - 2
94
- - 5
95
- version: "2.5"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.5'
96
77
  type: :development
97
- version_requirements: *id005
98
- - !ruby/object:Gem::Dependency
99
- name: escoffier
100
78
  prerelease: false
101
- requirement: &id006 !ruby/object:Gem::Requirement
102
- none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '2.5'
84
+ - !ruby/object:Gem::Dependency
85
+ name: escoffier
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
110
91
  type: :development
111
- version_requirements: *id006
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
112
98
  description: Extraction of MRI metadata.
113
99
  email: ekk@medicine.wisc.edu
114
- executables:
100
+ executables:
115
101
  - convert_visit.rb
116
102
  - import_respiratory_files.rb
117
103
  - import_study.rb
118
104
  - import_visit.rb
119
105
  - list_visit
120
106
  extensions: []
121
-
122
107
  extra_rdoc_files: []
123
-
124
- files:
108
+ files:
125
109
  - .gitignore
126
110
  - .rspec
127
111
  - Gemfile
@@ -167,38 +151,28 @@ files:
167
151
  - test/visit_test.rb
168
152
  homepage: http://github.com/brainmap/metamri
169
153
  licenses: []
170
-
154
+ metadata: {}
171
155
  post_install_message:
172
156
  rdoc_options: []
173
-
174
- require_paths:
157
+ require_paths:
175
158
  - lib
176
- required_ruby_version: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- hash: 3
182
- segments:
183
- - 0
184
- version: "0"
185
- required_rubygems_version: !ruby/object:Gem::Requirement
186
- none: false
187
- requirements:
188
- - - ">="
189
- - !ruby/object:Gem::Version
190
- hash: 3
191
- segments:
192
- - 0
193
- version: "0"
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
194
169
  requirements: []
195
-
196
170
  rubyforge_project:
197
- rubygems_version: 1.8.10
171
+ rubygems_version: 2.1.4
198
172
  signing_key:
199
- specification_version: 3
173
+ specification_version: 4
200
174
  summary: MRI metadata
201
- test_files:
175
+ test_files:
202
176
  - spec/helper_spec.rb
203
177
  - spec/unit/dicom_additions_spec.rb
204
178
  - spec/unit/nifti_builder_spec.rb