metamri 0.1.0
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.
- data/.gitignore +3 -0
- data/Manifest +16 -0
- data/README.rdoc +43 -0
- data/Rakefile +34 -0
- data/VERSION +1 -0
- data/bin/import_study.rb +170 -0
- data/bin/import_visit.rb +74 -0
- data/lib/metamri.rb +6 -0
- data/lib/mysql_tools.rb +33 -0
- data/lib/raw_image_dataset.rb +147 -0
- data/lib/raw_image_file.rb +418 -0
- data/lib/series_description_parameters.rb +81 -0
- data/lib/visit_raw_data_directory.rb +395 -0
- data/metamri.gemspec +61 -0
- data/test/raw_image_dataset_test.rb +46 -0
- data/test/raw_image_file_test.rb +135 -0
- data/test/visit_duplication_test.rb +24 -0
- data/test/visit_test.rb +77 -0
- metadata +76 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'raw_image_dataset'
|
8
|
+
require 'raw_image_file'
|
9
|
+
|
10
|
+
class RawImageDatasetTest < Test::Unit::TestCase
|
11
|
+
DBFILE = 'fixtures/development.sqlite3'
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@aa = RawImageFile.new('fixtures/I.001')
|
15
|
+
@bb = RawImageFile.new('fixtures/P27648.7')
|
16
|
+
@cc = RawImageFile.new('fixtures/P59392.7')
|
17
|
+
@dd = RawImageFile.new('fixtures/S4_EFGRE3D.0001')
|
18
|
+
@dset = RawImageDataset.new('/Data/home/kris/NetBeansProjects/ImageData/test/fixtures', [@aa,@bb,@cc,@dd])
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_raw_image_files
|
22
|
+
assert_equal 4, @dset.raw_image_files.length
|
23
|
+
assert_equal '"I.*"', @dset.glob
|
24
|
+
assert_equal "SAG T2 W FSE 1.7 skip 0.3", @dset.series_description
|
25
|
+
assert_equal "ALZMRI002", @dset.rmr_number
|
26
|
+
assert_equal "2003-01-31T04:39:04+00:00", @dset.timestamp.to_s
|
27
|
+
assert_equal "ALZMRI002::2003-01-31T04:39:04+00:00", @dset.dataset_key
|
28
|
+
assert_equal "DELETE FROM image_datasets WHERE dataset_key = 'ALZMRI002::2003-01-31T04:39:04+00:00'", @dset.db_remove
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_db_insertion
|
32
|
+
assert_raise IndexError do
|
33
|
+
@dset.db_insert!(DBFILE)
|
34
|
+
@dset.db_insert!(DBFILE)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_raw_image_insertion
|
39
|
+
@dset.db_insert_raw_images!(DBFILE)
|
40
|
+
end
|
41
|
+
|
42
|
+
def teardown
|
43
|
+
@dset.db_remove_raw_images!(DBFILE)
|
44
|
+
@dset.db_remove!(DBFILE)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'raw_image_file'
|
8
|
+
|
9
|
+
class RawImageFileTest < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@GEDicom = 'fixtures/I.001'
|
12
|
+
@DiDicom = 'fixtures/S4_EFGRE3D.0001'
|
13
|
+
@EarlyGEPfile = 'fixtures/P59392.7'
|
14
|
+
@LateGEPfile = 'fixtures/P27648.7'
|
15
|
+
@notafile = 'fixtures/XXX.XXX'
|
16
|
+
@ged = RawImageFile.new(@GEDicom)
|
17
|
+
@did = RawImageFile.new(@DiDicom)
|
18
|
+
@egep = RawImageFile.new(@EarlyGEPfile)
|
19
|
+
@lgep = RawImageFile.new(@LateGEPfile)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_gehdr_dicom_init
|
23
|
+
assert_nothing_raised do
|
24
|
+
RawImageFile.new(@GEDicom)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
def test_dicomhdr_dicom_init
|
28
|
+
assert_nothing_raised do
|
29
|
+
RawImageFile.new(@DiDicom)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
def test_early_gehdr_pfile_init
|
33
|
+
assert_nothing_raised do
|
34
|
+
RawImageFile.new(@EarlyGEPfile)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
def test_late_gehdr_pfile_init
|
38
|
+
assert_nothing_raised do
|
39
|
+
RawImageFile.new(@LateGEPfile)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def test_nonfile_init
|
43
|
+
assert_raise IOError do
|
44
|
+
RawImageFile.new(@notafile)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
def test_pfile?
|
48
|
+
assert !@ged.pfile?
|
49
|
+
assert !@did.pfile?
|
50
|
+
assert @egep.pfile?
|
51
|
+
assert @lgep.pfile?
|
52
|
+
end
|
53
|
+
def test_dicom?
|
54
|
+
assert @ged.dicom?
|
55
|
+
assert @did.dicom?
|
56
|
+
assert !@egep.dicom?
|
57
|
+
assert !@lgep.dicom?
|
58
|
+
end
|
59
|
+
def test_gehdr_dicom_values
|
60
|
+
assert_equal "I.001", @ged.filename
|
61
|
+
assert_equal "rdgehdr", @ged.hdr_reader
|
62
|
+
assert_equal "dicom", @ged.file_type
|
63
|
+
assert_equal "2003-01-31T05:02:54+00:00", @ged.timestamp.to_s
|
64
|
+
assert_equal "Andys3T", @ged.source
|
65
|
+
assert_equal "ALZMRI002", @ged.rmr_number
|
66
|
+
assert_equal 1.7, @ged.slice_thickness
|
67
|
+
assert_equal 0.3, @ged.slice_spacing
|
68
|
+
assert_equal 240.0, @ged.reconstruction_diameter
|
69
|
+
assert_equal 256, @ged.acquisition_matrix_x
|
70
|
+
assert_equal 256, @ged.acquisition_matrix_y
|
71
|
+
assert_equal 9.0, @ged.rep_time
|
72
|
+
assert_equal 2, @ged.bold_reps
|
73
|
+
end
|
74
|
+
def test_dicomhdr_dicom_values
|
75
|
+
assert_equal "S4_EFGRE3D.0001", @did.filename
|
76
|
+
assert_equal "dicom_hdr", @did.hdr_reader
|
77
|
+
assert_equal "dicom", @did.file_type
|
78
|
+
assert_equal "2006-11-16T10:59:23+00:00", @did.timestamp.to_s
|
79
|
+
assert_equal "Andys3T", @did.source
|
80
|
+
assert_equal "RMRRF2267", @did.rmr_number
|
81
|
+
assert_equal 1.2, @did.slice_thickness
|
82
|
+
assert_equal 1.2, @did.slice_spacing
|
83
|
+
assert_equal 240.0, @did.reconstruction_diameter
|
84
|
+
assert_equal 256, @did.acquisition_matrix_x
|
85
|
+
assert_equal 256, @did.acquisition_matrix_y
|
86
|
+
assert_equal 8.364, @did.rep_time
|
87
|
+
assert_equal 0, @did.bold_reps
|
88
|
+
end
|
89
|
+
def test_early_pfile_values
|
90
|
+
assert_equal "P59392.7", @egep.filename
|
91
|
+
assert_equal "rdgehdr", @egep.hdr_reader
|
92
|
+
assert_equal "pfile", @egep.file_type
|
93
|
+
assert_equal "2003-01-31T04:39:04+00:00", @egep.timestamp.to_s
|
94
|
+
assert_equal "Andys3T", @egep.source
|
95
|
+
assert_equal "ALZMRI002", @egep.rmr_number
|
96
|
+
assert_equal 4.0, @egep.slice_thickness
|
97
|
+
assert_equal 1.0, @egep.slice_spacing
|
98
|
+
assert_equal 240.0, @egep.reconstruction_diameter
|
99
|
+
assert_equal 64, @egep.acquisition_matrix_x
|
100
|
+
assert_equal 64, @egep.acquisition_matrix_y
|
101
|
+
assert_equal 1.999996, @egep.rep_time
|
102
|
+
assert_equal 124, @egep.bold_reps
|
103
|
+
end
|
104
|
+
def test_late_pfile_values
|
105
|
+
assert_equal "P27648.7", @lgep.filename
|
106
|
+
assert_equal "rdgehdr", @lgep.hdr_reader
|
107
|
+
assert_equal "pfile", @lgep.file_type
|
108
|
+
assert_equal "2006-11-16T04:35:02+00:00", @lgep.timestamp.to_s
|
109
|
+
assert_equal "Andys3T", @lgep.source
|
110
|
+
assert_equal "RMRRF2267", @lgep.rmr_number
|
111
|
+
assert_equal 4.0, @lgep.slice_thickness
|
112
|
+
assert_equal 1.0, @lgep.slice_spacing
|
113
|
+
assert_equal 240.0, @lgep.reconstruction_diameter
|
114
|
+
assert_equal 64, @lgep.acquisition_matrix_x
|
115
|
+
assert_equal 64, @lgep.acquisition_matrix_y
|
116
|
+
assert_equal 2.000010, @lgep.rep_time
|
117
|
+
assert_equal 124, @lgep.bold_reps
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_db_insert
|
121
|
+
@ged.db_insert!('fixtures/development.sqlite3')
|
122
|
+
@did.db_insert!('fixtures/development.sqlite3')
|
123
|
+
@egep.db_insert!('fixtures/development.sqlite3')
|
124
|
+
@lgep.db_insert!('fixtures/development.sqlite3')
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
def teardown
|
130
|
+
@ged.db_remove!('fixtures/development.sqlite3')
|
131
|
+
@did.db_remove!('fixtures/development.sqlite3')
|
132
|
+
@egep.db_remove!('fixtures/development.sqlite3')
|
133
|
+
@lgep.db_remove!('fixtures/development.sqlite3')
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'visit'
|
8
|
+
require 'pathname'
|
9
|
+
|
10
|
+
|
11
|
+
class RawImageFileTest < Test::Unit::TestCase
|
12
|
+
DBFILE = '/Data/home/kris/TextMateProjects/TransferScans/db/development.sqlite3'
|
13
|
+
|
14
|
+
def setup
|
15
|
+
# DO NOTHING
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_scan_and_insert
|
19
|
+
@v = Visit.new( '/Data/vtrak1/raw/alz_2000/alz093', 'ALZ' )
|
20
|
+
@v.scan
|
21
|
+
@v.init_db(DBFILE)
|
22
|
+
@v.db_insert!
|
23
|
+
end
|
24
|
+
end
|
data/test/visit_test.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# To change this template, choose Tools | Templates
|
2
|
+
# and open the template in the editor.
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'visit_raw_data_directory'
|
8
|
+
require 'pathname'
|
9
|
+
require 'logger'
|
10
|
+
|
11
|
+
class RawImageFileTest < Test::Unit::TestCase
|
12
|
+
DBFILE = '/Users/kris/projects/TransferScans/db/development.sqlite3'
|
13
|
+
LOG = Logger.new('visit_test.log', shift_age = 7, shift_size = 1048576)
|
14
|
+
STUDIES = [
|
15
|
+
# Pathname.new('/Data/vtrak1/raw/alz_2000'),
|
16
|
+
# Pathname.new('/Data/vtrak1/raw/alz_2000'),
|
17
|
+
# Pathname.new('/Data/vtrak1/raw/pib_pilot_mri'),
|
18
|
+
# Pathname.new('/Data/vtrak1/raw/johnson.tbi-va.visit1'),
|
19
|
+
# Pathname.new('/Data/vtrak1/raw/wrap140'),
|
20
|
+
Pathname.new('/Data/vtrak1/raw/cms/uwmr'),
|
21
|
+
Pathname.new('/Data/vtrak1/raw/cms/wais'),
|
22
|
+
Pathname.new('/Data/vtrak1/raw/esprit/9month'),
|
23
|
+
Pathname.new('/Data/vtrak1/raw/esprit/baseline')
|
24
|
+
# Pathname.new('/Data/vtrak1/raw/gallagher_pd'),
|
25
|
+
# Pathname.new('/Data/vtrak1/raw/pc_4000'),
|
26
|
+
# Pathname.new('/Data/vtrak1/raw/ries.aware.visit1'),
|
27
|
+
# Pathname.new('/Data/vtrak1/raw/tbi_1000'),
|
28
|
+
# Pathname.new('/Data/vtrak1/raw/tbi_aware')
|
29
|
+
]
|
30
|
+
FILTERS = [
|
31
|
+
# /^alz...$/,
|
32
|
+
# /^alz..._[2AB]$/,
|
33
|
+
# /^3..._/,
|
34
|
+
# /^tbi/,
|
35
|
+
# /^25/,
|
36
|
+
/^cms_...$/,
|
37
|
+
/^pc...$/,
|
38
|
+
/^3.._/,
|
39
|
+
/^3.._/
|
40
|
+
# /^pd..._/,
|
41
|
+
# /^pc...$/,
|
42
|
+
# /^awr.*\d$/,
|
43
|
+
# /^tbi...$|^tbi..._2$/,
|
44
|
+
# /^tbi..._3$/
|
45
|
+
]
|
46
|
+
PROTOCOLS = ['ALZ_visit1','ALZ_visit2','PIB_PILOT','TBI_VA','WRAP140','CMS_UWMR','CMS_WAIS','ESPRIT_9month',
|
47
|
+
'ESPRIT_baseline','gallagher_pd','pc_4000','ries.aware.visit1','tbi_1000','tbi_aware']
|
48
|
+
|
49
|
+
def setup
|
50
|
+
# DO NOTHING
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_scan_and_insert
|
54
|
+
STUDIES.each_with_index do |study, i|
|
55
|
+
filter = FILTERS[i]
|
56
|
+
protocol = PROTOCOLS[i]
|
57
|
+
study.entries.each do |visit|
|
58
|
+
next if visit.to_s =~ /^\./
|
59
|
+
next unless visit.to_s =~ filter
|
60
|
+
visitdir = study + visit
|
61
|
+
v = VisitRawDataDirectory.new( visitdir.to_s )
|
62
|
+
begin
|
63
|
+
v.scan
|
64
|
+
v.db_insert!(DBFILE)
|
65
|
+
rescue Exception => e
|
66
|
+
puts "There was a problem scanning a dataset in #{visitdir}... skipping."
|
67
|
+
puts "Exception message: #{e.message}"
|
68
|
+
LOG.error "There was a problem scanning a dataset in #{visitdir}... skipping."
|
69
|
+
LOG.error "Exception message: #{e.message}"
|
70
|
+
ensure
|
71
|
+
v = nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metamri
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kristopher J. Kosmatka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-08 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Extraction of MRI metadata and insertion into compatible sqlite3 databases.
|
17
|
+
email: kk4@medicine.wisc.edu
|
18
|
+
executables:
|
19
|
+
- import_study.rb
|
20
|
+
- import_visit.rb
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- Manifest
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- bin/import_study.rb
|
32
|
+
- bin/import_visit.rb
|
33
|
+
- lib/metamri.rb
|
34
|
+
- lib/mysql_tools.rb
|
35
|
+
- lib/raw_image_dataset.rb
|
36
|
+
- lib/raw_image_file.rb
|
37
|
+
- lib/series_description_parameters.rb
|
38
|
+
- lib/visit_raw_data_directory.rb
|
39
|
+
- metamri.gemspec
|
40
|
+
- test/raw_image_dataset_test.rb
|
41
|
+
- test/raw_image_file_test.rb
|
42
|
+
- test/visit_duplication_test.rb
|
43
|
+
- test/visit_test.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://github.com/brainmap/metamri
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options:
|
50
|
+
- --charset=UTF-8
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: MRI metadata
|
72
|
+
test_files:
|
73
|
+
- test/raw_image_dataset_test.rb
|
74
|
+
- test/raw_image_file_test.rb
|
75
|
+
- test/visit_duplication_test.rb
|
76
|
+
- test/visit_test.rb
|