metamri 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/raw_image_file.rb +97 -55
- data/lib/visit_raw_data_directory.rb +1 -1
- data/metamri.gemspec +6 -6
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.15
|
data/lib/raw_image_file.rb
CHANGED
@@ -89,8 +89,10 @@ temporary file.
|
|
89
89
|
# are not found
|
90
90
|
begin
|
91
91
|
import_hdr
|
92
|
+
rescue ScriptError => e
|
93
|
+
raise ScriptError, "Could not find required DICOM Header Meta Element: #{e}"
|
92
94
|
rescue Exception => e
|
93
|
-
raise
|
95
|
+
raise IOError, "Header import failed for file #{@filename}. #{e}"
|
94
96
|
end
|
95
97
|
|
96
98
|
# deallocate the header data to save memory space.
|
@@ -295,65 +297,105 @@ Extracts a collection of metadata from @hdr_data retrieved using the dicom_hdr
|
|
295
297
|
utility.
|
296
298
|
=end
|
297
299
|
def dicom_hdr_import
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
300
|
+
meta_matchers = {}
|
301
|
+
meta_matchers[:rmr_number] = {
|
302
|
+
:type => :string,
|
303
|
+
:pat => /[ID Accession Number|ID Study Description]\/\/(RMR.*)\n/i,
|
304
|
+
:required => true
|
305
|
+
}
|
306
|
+
meta_matchers[:slice_thickness] = {
|
307
|
+
:type => :float,
|
308
|
+
:pat => /ACQ SLICE THICKNESS\/\/(.*)\n/i,
|
309
|
+
:required => false
|
310
|
+
}
|
311
|
+
meta_matchers[:slice_spacing] = {
|
312
|
+
:type => :float,
|
313
|
+
:pat => /ACQ SPACING BETWEEN SLICES\/\/(.*)\n/i,
|
314
|
+
:required => false
|
315
|
+
}
|
316
|
+
meta_matchers[:source] = {
|
317
|
+
:type => :string,
|
318
|
+
:pat => /ID INSTITUTION NAME\/\/(.*)\n/i,
|
319
|
+
:required => true
|
320
|
+
}
|
321
|
+
meta_matchers[:series_description] = {
|
322
|
+
:type => :string,
|
323
|
+
:pat => /ID SERIES DESCRIPTION\/\/(.*)\n/i,
|
324
|
+
:required => true
|
325
|
+
}
|
326
|
+
meta_matchers[:gender] = {
|
327
|
+
:type => :string,
|
328
|
+
:pat => /PAT PATIENT SEX\/\/(.)/i,
|
329
|
+
:required => false
|
330
|
+
}
|
331
|
+
meta_matchers[:reconstruction_diameter] = {
|
332
|
+
:type => :int,
|
333
|
+
:pat => /ACQ RECONSTRUCTION DIAMETER\/\/([0-9]+)/i,
|
334
|
+
:required => false
|
335
|
+
}
|
336
|
+
meta_matchers[:acquisition_matrix_x] = {
|
337
|
+
:type => :int,
|
338
|
+
:pat => /IMG Rows\/\/ ([0-9]+)/i,
|
339
|
+
:required => false
|
340
|
+
}
|
341
|
+
meta_matchers[:acquisition_matrix_y] = {
|
342
|
+
:type => :int,
|
343
|
+
:pat => /IMG Columns\/\/ ([0-9]+)/i,
|
344
|
+
:required => false
|
345
|
+
}
|
346
|
+
meta_matchers[:num_slices] = {
|
347
|
+
:type => :int,
|
348
|
+
:pat => /REL Images in Acquisition\/\/([0-9]+)/i,
|
349
|
+
:required => false
|
350
|
+
}
|
351
|
+
meta_matchers[:bold_reps] = {
|
352
|
+
:type => :int,
|
353
|
+
:pat => /REL Number of Temporal Positions\/\/([0-9]+)/i,
|
354
|
+
:required => true
|
355
|
+
}
|
356
|
+
meta_matchers[:rep_time] = {
|
357
|
+
:type => :float,
|
358
|
+
:pat => /ACQ Repetition Time\/\/(.*)\n/i,
|
359
|
+
:required => false
|
360
|
+
}
|
361
|
+
meta_matchers[:date] = {
|
362
|
+
:type => :datetime,
|
363
|
+
:pat => /ID STUDY DATE\/\/(.*)\n/i #,
|
364
|
+
# :required => false
|
365
|
+
}
|
366
|
+
meta_matchers[:time] = {
|
367
|
+
:type => :datetime,
|
368
|
+
:pat => /ID Series Time\/\/(.*)\n/i #,
|
369
|
+
# :required => false
|
370
|
+
}
|
328
371
|
|
329
|
-
|
372
|
+
meta_matchers.each_pair do |name, tag_hash|
|
373
|
+
begin
|
374
|
+
next if tag_hash[:type] == :datetime
|
375
|
+
tag_hash[:pat] =~ @hdr_data
|
376
|
+
raise ScriptError, "No match found for #{name}" if ($1).nil?
|
377
|
+
value = case tag_hash[:type]
|
378
|
+
when :string then ($1).strip.chomp
|
379
|
+
when :float then ($1).strip.chomp.to_f
|
380
|
+
when :int then ($1).to_i
|
381
|
+
end
|
382
|
+
self.instance_variable_set("@#{name}", value)
|
383
|
+
rescue ScriptError => e
|
384
|
+
if tag_hash[:required]
|
385
|
+
raise ScriptError, "#{name}"
|
386
|
+
else
|
387
|
+
puts "+++ Warning: #{name} could not be found."
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
# Set Timestamp separately because it requires both Date and Time to be extracted.
|
393
|
+
meta_matchers[:date][:pat] =~ @hdr_data
|
330
394
|
date = $1
|
331
|
-
|
395
|
+
meta_matchers[:time][:pat] =~ @hdr_data
|
332
396
|
time = $1
|
333
397
|
@timestamp = DateTime.parse(date + time)
|
334
398
|
|
335
|
-
gender_pat =~ @hdr_data
|
336
|
-
@gender = $1
|
337
|
-
|
338
|
-
#acquisition_matrix_pat =~ @hdr_data
|
339
|
-
#matrix = [($1).to_i, ($2).to_i, ($3).to_i, ($4).to_i]
|
340
|
-
#matrix = matrix.delete_if { |x| x == 0 }
|
341
|
-
acq_mat_x_pat =~ @hdr_data
|
342
|
-
@acquisition_matrix_x = ($1).to_i
|
343
|
-
acq_mat_y_pat =~ @hdr_data
|
344
|
-
@acquisition_matrix_y = ($1).to_i
|
345
|
-
|
346
|
-
series_description_pat =~ @hdr_data
|
347
|
-
@series_description = ($1).strip.chomp
|
348
|
-
|
349
|
-
recon_diam_pat =~ @hdr_data
|
350
|
-
@reconstruction_diameter = ($1).to_i
|
351
|
-
|
352
|
-
bold_reps_pat =~ @hdr_data
|
353
|
-
@bold_reps = ($1).to_i
|
354
|
-
|
355
|
-
rep_time_pat =~ @hdr_data
|
356
|
-
@rep_time = ($1).strip.chomp.to_f
|
357
399
|
end
|
358
400
|
|
359
401
|
|
@@ -317,7 +317,7 @@ generates an sql insert statement to insert this visit with a given participant
|
|
317
317
|
begin
|
318
318
|
rawimagefile = RawImageFile.new(rawfile.to_s)
|
319
319
|
rescue Exception => e
|
320
|
-
raise(IOError, "Trouble reading raw image file #{rawfile}. #{e}")
|
320
|
+
raise(IOError, "+++ Trouble reading raw image file #{rawfile}. #{e}")
|
321
321
|
end
|
322
322
|
|
323
323
|
return RawImageDataset.new(original_parent_directory.to_s, [rawimagefile])
|
data/metamri.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{metamri}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.15"
|
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{2010-
|
12
|
+
s.date = %q{2010-04-23}
|
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
|
-
s.executables = ["import_study.rb", "
|
15
|
+
s.executables = ["import_study.rb", "convert_visit.rb", "import_respiratory_files.rb", "import_visit.rb", "list_visit"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"README.rdoc"
|
18
18
|
]
|
@@ -51,11 +51,11 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.rubygems_version = %q{1.3.6}
|
52
52
|
s.summary = %q{MRI metadata}
|
53
53
|
s.test_files = [
|
54
|
-
"test/
|
55
|
-
"test/raw_image_dataset_test.rb",
|
54
|
+
"test/raw_image_dataset_test.rb",
|
56
55
|
"test/raw_image_file_test.rb",
|
57
56
|
"test/visit_duplication_test.rb",
|
58
|
-
"test/visit_test.rb"
|
57
|
+
"test/visit_test.rb",
|
58
|
+
"test/nifti_builder_spec.rb"
|
59
59
|
]
|
60
60
|
|
61
61
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 15
|
9
|
+
version: 0.1.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristopher J. Kosmatka
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-23 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -45,10 +45,10 @@ description: Extraction of MRI metadata and insertion into compatible sqlite3 da
|
|
45
45
|
email: kk4@medicine.wisc.edu
|
46
46
|
executables:
|
47
47
|
- import_study.rb
|
48
|
-
-
|
48
|
+
- convert_visit.rb
|
49
49
|
- import_respiratory_files.rb
|
50
|
+
- import_visit.rb
|
50
51
|
- list_visit
|
51
|
-
- convert_visit.rb
|
52
52
|
extensions: []
|
53
53
|
|
54
54
|
extra_rdoc_files:
|
@@ -112,8 +112,8 @@ signing_key:
|
|
112
112
|
specification_version: 3
|
113
113
|
summary: MRI metadata
|
114
114
|
test_files:
|
115
|
-
- test/nifti_builder_spec.rb
|
116
115
|
- test/raw_image_dataset_test.rb
|
117
116
|
- test/raw_image_file_test.rb
|
118
117
|
- test/visit_duplication_test.rb
|
119
118
|
- test/visit_test.rb
|
119
|
+
- test/nifti_builder_spec.rb
|