metamri 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/metamri/raw_image_dataset.rb +15 -2
- data/lib/metamri/raw_image_dataset_resource.rb +3 -2
- data/lib/metamri/visit_raw_data_directory.rb +2 -2
- data/metamri.gemspec +4 -5
- metadata +16 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -42,6 +42,8 @@ class RawImageDataset
|
|
42
42
|
attr_reader :dicom_series_uid
|
43
43
|
# DICOM Study UID
|
44
44
|
attr_reader :dicom_study_uid
|
45
|
+
# Array of Read Error Strings
|
46
|
+
attr_reader :read_errors
|
45
47
|
|
46
48
|
# * dir: The directory containing the files.
|
47
49
|
# * files: An array of #RawImageFile objects that compose the complete data set.
|
@@ -51,6 +53,7 @@ class RawImageDataset
|
|
51
53
|
# * any of the raw image files is not actually a RawImageFile => IndexError
|
52
54
|
# * series description, rmr number, or timestamp cannot be extracted from the first RawImageFile => IndexError
|
53
55
|
def initialize(directory, raw_image_files)
|
56
|
+
@read_errors = Array.new
|
54
57
|
@directory = File.expand_path(directory)
|
55
58
|
raise(IOError, "#{@directory} not found.") if not File.directory?(@directory)
|
56
59
|
raise(IOError, "No raw image files supplied.") unless raw_image_files
|
@@ -90,7 +93,7 @@ class RawImageDataset
|
|
90
93
|
validates_metainfo_for :protocol_name, :msg => "No protocol name found" if dicom?
|
91
94
|
|
92
95
|
@operator_name = @raw_image_files.first.operator_name
|
93
|
-
validates_metainfo_for :operator_name if dicom?
|
96
|
+
validates_metainfo_for :operator_name, :optional => true if dicom?
|
94
97
|
|
95
98
|
@patient_name = @raw_image_files.first.patient_name
|
96
99
|
validates_metainfo_for :patient_name if dicom?
|
@@ -104,6 +107,15 @@ class RawImageDataset
|
|
104
107
|
$LOG ||= Logger.new(STDOUT)
|
105
108
|
end
|
106
109
|
|
110
|
+
# Prints a "success" dot or error mesage if any errors in @read_errors.
|
111
|
+
def print_scan_status
|
112
|
+
if @read_errors.empty?
|
113
|
+
print "."; STDOUT.flush
|
114
|
+
else
|
115
|
+
puts @read_errors.join("; ")
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
107
119
|
|
108
120
|
|
109
121
|
# Generates an SQL insert statement for this dataset that can be used to
|
@@ -330,7 +342,8 @@ private
|
|
330
342
|
def validates_metainfo_for(info_variable, options = {})
|
331
343
|
raise StandardError, "#{info_variable} must be a symbol" unless info_variable.kind_of? Symbol
|
332
344
|
if self.instance_variable_get("@" + info_variable.to_s).nil?
|
333
|
-
|
345
|
+
@read_errors << options[:msg] ||= "Couldn't find #{info_variable.to_s}"
|
346
|
+
raise IndexError, message unless options[:optional]
|
334
347
|
end
|
335
348
|
end
|
336
349
|
|
@@ -108,7 +108,7 @@ class RawImageDatasetResource < ActiveResource::Base
|
|
108
108
|
unless image_dataset_quality_checks.empty?
|
109
109
|
image_dataset_quality_checks.each do |qc|
|
110
110
|
qc.failed_checks.each do |check|
|
111
|
-
output << "* #{check[:name].capitalize.gsub("_", " ")} (#{check[:value]}): #{check[:comment]
|
111
|
+
output << "* #{check[:name].capitalize.gsub("_", " ") } (#{check[:value]}): #{(check[:comment] + ".") if check[:comment]}"
|
112
112
|
end
|
113
113
|
|
114
114
|
output << "Concerns: #{qc.other_issues}" if qc.other_issues
|
@@ -131,7 +131,8 @@ class RawImageDatasetResource < ActiveResource::Base
|
|
131
131
|
datasets.sort_by{ |ds| [ds.timestamp, File.basename(ds.path)] },
|
132
132
|
:headers => { :relative_dataset_path => 'Dataset', :series_description => 'Series Details', :file_count => "File Count", :image_dataset_quality_checks_tablerow => "Quality Checks"},
|
133
133
|
:fields => [:relative_dataset_path, :series_description, :file_count, :image_dataset_quality_checks_tablerow],
|
134
|
-
:description => false # Turn off rendering row count description at bottom.
|
134
|
+
:description => false, # Turn off rendering row count description at bottom.
|
135
|
+
:resize => false
|
135
136
|
)
|
136
137
|
rescue NameError => e
|
137
138
|
raise e
|
@@ -95,8 +95,8 @@ class VisitRawDataDirectory
|
|
95
95
|
begin
|
96
96
|
matches = options[:ignore_patterns].collect {|pat| dd.to_s =~ pat ? dd : nil }.compact
|
97
97
|
next unless matches.empty?
|
98
|
-
dd.each_pfile { |pf| @datasets << import_dataset(pf, dd);
|
99
|
-
dd.first_dicom { |fd| @datasets << import_dataset(fd, dd);
|
98
|
+
dd.each_pfile { |pf| @datasets << import_dataset(pf, dd); @datasets.last.print_scan_status if $LOG.level == Logger::INFO }
|
99
|
+
dd.first_dicom { |fd| @datasets << import_dataset(fd, dd); @datasets.last.print_scan_status if $LOG.level == Logger::INFO }
|
100
100
|
rescue StandardError => e
|
101
101
|
raise(e, "There was an error scaning dataset #{dd}: #{e}")
|
102
102
|
end
|
data/metamri.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{metamri}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristopher J. Kosmatka"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-18}
|
13
13
|
s.description = %q{Extraction of MRI metadata and insertion into compatible sqlite3 databases.}
|
14
14
|
s.email = %q{kk4@medicine.wisc.edu}
|
15
15
|
s.executables = ["convert_visit.rb", "import_visit.rb", "import_respiratory_files.rb", "import_study.rb", "list_visit"]
|
@@ -57,7 +57,7 @@ Gem::Specification.new do |s|
|
|
57
57
|
]
|
58
58
|
s.homepage = %q{http://github.com/brainmap/metamri}
|
59
59
|
s.require_paths = ["lib"]
|
60
|
-
s.rubygems_version = %q{1.
|
60
|
+
s.rubygems_version = %q{1.4.1}
|
61
61
|
s.summary = %q{MRI metadata}
|
62
62
|
s.test_files = [
|
63
63
|
"spec/helper_spec.rb",
|
@@ -73,10 +73,9 @@ Gem::Specification.new do |s|
|
|
73
73
|
]
|
74
74
|
|
75
75
|
if s.respond_to? :specification_version then
|
76
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
77
76
|
s.specification_version = 3
|
78
77
|
|
79
|
-
if Gem::Version.new(Gem::
|
78
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
80
79
|
s.add_runtime_dependency(%q<sqlite3-ruby>, [">= 0"])
|
81
80
|
s.add_runtime_dependency(%q<dicom>, [">= 0"])
|
82
81
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metamri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Kristopher J. Kosmatka
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-01-18 00:00:00 -06:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: sqlite3-ruby
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: dicom
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -45,9 +50,11 @@ dependencies:
|
|
45
50
|
name: rspec
|
46
51
|
prerelease: false
|
47
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
55
|
- - ">="
|
50
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
51
58
|
segments:
|
52
59
|
- 0
|
53
60
|
version: "0"
|
@@ -113,23 +120,27 @@ rdoc_options: []
|
|
113
120
|
require_paths:
|
114
121
|
- lib
|
115
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
116
124
|
requirements:
|
117
125
|
- - ">="
|
118
126
|
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
119
128
|
segments:
|
120
129
|
- 0
|
121
130
|
version: "0"
|
122
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
123
133
|
requirements:
|
124
134
|
- - ">="
|
125
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 3
|
126
137
|
segments:
|
127
138
|
- 0
|
128
139
|
version: "0"
|
129
140
|
requirements: []
|
130
141
|
|
131
142
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.4.1
|
133
144
|
signing_key:
|
134
145
|
specification_version: 3
|
135
146
|
summary: MRI metadata
|