metamri 0.2.22 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/bin/convert_visit.rb +3 -1
- data/lib/metamri/core_additions.rb +61 -0
- data/lib/metamri/nifti_builder.rb +1 -1
- data/lib/metamri/raw_image_dataset_resource.rb +56 -2
- data/lib/metamri/raw_image_file.rb +127 -16
- data/lib/metamri/version.rb +1 -1
- data/lib/metamri/visit_raw_data_directory.rb +19 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWY3NWY2MWZkMDY2ZGEwOTc1YTU0OGZmM2Q0YzBjMWQ4ZTExZTkyNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDgyNWE5ZjJkMDkxYzRkM2VmNWJiMjdiZWZiZWI5MWEzZWM1NWY3ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDNkNTA3ZDY1ZjFhZWVlMzk1NWY4ZmM5OTZjMTRlNTJkMzUwYjc5MzEzNzZj
|
10
|
+
YzA2YmZlMDA4N2UyMjU2N2UxZTJjZDVhMWZkMzdmMzRjYjRlM2M2NzNkZGM1
|
11
|
+
YWFhM2U5MjQ5YzMwOWNiM2JhMTZjYjFkZjRiZDBlNDQzZWJiYzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Q1NjY2OGFmZGQzZTFiODI3MWU5MmQwNTM4OWZhOWE3OGQ2MzI2OWE0Yjhh
|
14
|
+
NWRmZWMwZWMyMWJiZDRiZDA0ZjQyOGE1NTRhODgxODIzN2UzMmI0YWM5YzRj
|
15
|
+
MDhkMDYwZmQzNDhkZDQzMjRhOTUxOGVkYWQzNjRlOWQyNDA3ZDA=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.24
|
data/bin/convert_visit.rb
CHANGED
@@ -42,7 +42,9 @@ 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
|
-
|
45
|
+
## default_options = {:ignore_patterns => [/vipr/,/ge_physios/,/raw$/,/pfiles/,/Processed-Images/,/900$/,/901$/,/999$/,/\/01300\./,/\/01301\./,/\/01001\./,/\/01002\./,/\/01000\./,/\/00600\./]} # does not like "raw" because in dir path
|
46
|
+
## new flair has numbers in name and should not be skipped - removing
|
47
|
+
default_options = {:ignore_patterns => [/vipr/,/ge_physios/,/raw$/,/pfiles/,/Processed-Images/]} # does not like "raw" because in dir path
|
46
48
|
#options = default_options.merge(options)
|
47
49
|
v.scan(default_options)
|
48
50
|
v.to_nifti!(output_directory)
|
@@ -38,12 +38,24 @@ class Pathname
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def each_pfile(min_file_size = MIN_PFILE_SIZE)
|
41
|
+
#puts "in each_pfile"
|
42
|
+
#puts "core_additions each_pfile ==> local_copy"
|
41
43
|
entries.each do |leaf|
|
42
44
|
next unless leaf.to_s =~ /^P.{5}\.7(\.bz2)/
|
43
45
|
branch = self + leaf
|
44
46
|
next if branch.symlink?
|
45
47
|
if branch.size >= min_file_size
|
48
|
+
# check for P*.7.summary
|
49
|
+
# if there, skip local_copy of P*.7.bz2
|
50
|
+
leaf_summary_s = (leaf.to_s).gsub(/\.bz2/,"")+".summary"
|
51
|
+
branch_summary_s = self.to_s+"/"+leaf_summary_s
|
52
|
+
if File.exist?(branch_summary_s)
|
53
|
+
branch_summary_pn = Pathname.new(branch_summary_s)
|
54
|
+
lc = branch_summary_pn.local_copy
|
55
|
+
# summary_lc.delete
|
56
|
+
else
|
46
57
|
lc = branch.local_copy
|
58
|
+
end
|
47
59
|
begin
|
48
60
|
yield lc
|
49
61
|
rescue StandardError => e
|
@@ -59,6 +71,55 @@ class Pathname
|
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
74
|
+
|
75
|
+
def each_pfile_non_bz2(min_file_size = MIN_PFILE_SIZE)
|
76
|
+
# not using the P*.7.summary --- should be bzip2'ed
|
77
|
+
entries.each do |leaf|
|
78
|
+
next unless leaf.to_s =~ /^P.{5}(\.7)$/
|
79
|
+
branch = self + leaf
|
80
|
+
next if branch.symlink?
|
81
|
+
if branch.size >= min_file_size
|
82
|
+
lc = branch.local_copy
|
83
|
+
begin
|
84
|
+
yield lc
|
85
|
+
rescue StandardError => e
|
86
|
+
case $LOG.level
|
87
|
+
when Logger::DEBUG
|
88
|
+
raise e
|
89
|
+
else
|
90
|
+
puts "#{e}"
|
91
|
+
end
|
92
|
+
ensure
|
93
|
+
lc.delete
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def each_pfile_summary(min_file_size = MIN_PFILE_SIZE)
|
101
|
+
entries.each do |leaf|
|
102
|
+
next unless leaf.to_s =~ /^P.{5}(\.7\.summary)/
|
103
|
+
branch = self + leaf
|
104
|
+
next if branch.symlink?
|
105
|
+
if branch.size >= min_file_size
|
106
|
+
lc = branch.local_copy
|
107
|
+
begin
|
108
|
+
yield lc
|
109
|
+
rescue StandardError => e
|
110
|
+
case $LOG.level
|
111
|
+
when Logger::DEBUG
|
112
|
+
raise e
|
113
|
+
else
|
114
|
+
puts "#{e}"
|
115
|
+
end
|
116
|
+
ensure
|
117
|
+
lc.delete
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
62
123
|
|
63
124
|
def first_dicom
|
64
125
|
entries.each do |leaf|
|
@@ -12,7 +12,7 @@ module UnknownImageDataset
|
|
12
12
|
input_files = "#{input_options[:input_directory]}/'#{glob}'"
|
13
13
|
else input_files = "#{Dir.tmpdir}/'#{glob}'"
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
if @raw_image_files.first.rep_time && @raw_image_files.first.bold_reps && @raw_image_files.first.num_slices && !input_options[:no_timing_options]
|
17
17
|
slice_order = "altplus"
|
18
18
|
functional_args = "-time:zt #{@raw_image_files.first.num_slices} #{@raw_image_files.first.bold_reps} #{@raw_image_files.first.rep_time} #{slice_order}"
|
@@ -11,8 +11,13 @@ class RawImageDatasetResource < ActiveResource::Base
|
|
11
11
|
# This is a little wasteful since we really only care about the variables,
|
12
12
|
# not rescanning them.
|
13
13
|
|
14
|
+
# need to stop loading bz2 P files - 15 GB nmprage pfiles taking to long to bunzip2
|
15
|
+
# load just P*.7 and have routine job to pbzip2 things up later
|
14
16
|
filename = Pathname.new(File.join(path, scanned_file))
|
17
|
+
flash "wwwwwwwwwwww filename= #{filename}" if $LOG.level <= Logger::INFO
|
15
18
|
filename_matches = /P\d{5}.7(.bz2)?/.match(filename)
|
19
|
+
filename_matches_non_bz2 = /P\d{5}(.7)?/.match(filename)
|
20
|
+
filename_matches_summary = /P\d{5}(.7.summary)?/.match(filename)
|
16
21
|
|
17
22
|
if filename_matches # Pfile
|
18
23
|
if filename_matches[1] # '.bz2' if present, nil if otherwise.
|
@@ -24,7 +29,7 @@ class RawImageDatasetResource < ActiveResource::Base
|
|
24
29
|
# The actual file on the filesystem may be zipped or unzipped
|
25
30
|
# (although it Should! be zipped. Check for that or return IOError.
|
26
31
|
zipped_filename = filename.to_s.chomp + '.bz2'
|
27
|
-
|
32
|
+
summary_filename = filename.to_s.chomp + '.summary'
|
28
33
|
if filename.file?
|
29
34
|
image_file = filename
|
30
35
|
elsif Pathname.new(zipped_filename).file?
|
@@ -32,10 +37,59 @@ class RawImageDatasetResource < ActiveResource::Base
|
|
32
37
|
else
|
33
38
|
raise IOError, "Could not find #{filename} or it's bz2 zipped equivalent #{zipped_filename}."
|
34
39
|
end
|
35
|
-
|
40
|
+
puts "raw_image_dataset_resource before check for P*.7.summary"
|
41
|
+
if Pathname.new(summary_filename).file?
|
42
|
+
puts "raw_image_dataset_resource THERE IS A SUMMARY P*.7.summary file"
|
43
|
+
# skiplocal copy
|
44
|
+
# make @dataset
|
45
|
+
end
|
46
|
+
|
36
47
|
image_file.local_copy do |local_pfile|
|
37
48
|
@dataset = RawImageDataset.new( path, [RawImageFile.new(local_pfile)])
|
38
49
|
end
|
50
|
+
elsif filename_matches_non_bz2 # non-compressed Pfile
|
51
|
+
puts "raw_image_dataset_resource matches non_bz2"
|
52
|
+
if filename_matches_non_bz2[1]
|
53
|
+
# filename = Pathname.new(File.join(filename, '.bz2'))
|
54
|
+
else
|
55
|
+
filename = nil
|
56
|
+
end
|
57
|
+
if filename.file?
|
58
|
+
image_file = filename
|
59
|
+
else
|
60
|
+
raise IOError, "Could not find #{filename}."
|
61
|
+
end
|
62
|
+
# if non-bz2 P*.7 file , the pfile header reader is pulling file from /mounts/data/raw/...
|
63
|
+
# but the there is still a local copy being made - ? for the pfile reader?
|
64
|
+
# not sure if better to copy a bz2 file over to tmp, bunzip2, then cp to local, again?, for the pfile header reader
|
65
|
+
@dataset = RawImageDataset.new( path, [RawImageFile.new(filename)] )
|
66
|
+
|
67
|
+
# image_file.local_copy do |local_pfile|
|
68
|
+
# @dataset = RawImageDataset.new( path, [RawImageFile.new(local_pfile)])
|
69
|
+
# end
|
70
|
+
elsif filename_matches_summary # 3 line summary of Pfile
|
71
|
+
# not do anything - check in P*.7 and P*.7.bz2 if P*.7.summary exists
|
72
|
+
puts "raw_image_dataset_resource P*.7.summary match"
|
73
|
+
# if filename_matches_summary[1]
|
74
|
+
# filename = Pathname.new(File.join(filename, '.bz2'))
|
75
|
+
# puts " summary file name="+filename
|
76
|
+
# else
|
77
|
+
# filename = nil
|
78
|
+
# end
|
79
|
+
# if filename.file?
|
80
|
+
# image_file = filename
|
81
|
+
# else
|
82
|
+
# raise IOError, "Could not find #{filename}."
|
83
|
+
# end
|
84
|
+
# if non-bz2 P*.7 file , the pfile header reader is pulling file from /mounts/data/raw/...
|
85
|
+
# but the there is still a local copy being made - ? for the pfile reader?
|
86
|
+
# not sure if better to copy a bz2 file over to tmp, bunzip2, then cp to local, again?, for the pfile header reader
|
87
|
+
# @dataset = RawImageDataset.new( path, [RawImageFile.new(filename)] )
|
88
|
+
|
89
|
+
# image_file.local_copy do |local_pfile|
|
90
|
+
# @dataset = RawImageDataset.new( path, [RawImageFile.new(local_pfile)])
|
91
|
+
# end
|
92
|
+
|
39
93
|
|
40
94
|
else # Dicom
|
41
95
|
Pathname.new(path).first_dicom do |fd|
|
@@ -18,11 +18,13 @@ require 'dicom'
|
|
18
18
|
class RawImageFile
|
19
19
|
#:stopdoc:
|
20
20
|
MIN_HDR_LENGTH = 400
|
21
|
+
MIN_HDR_SUMMARY_LENGTH = 100
|
21
22
|
DICOM_HDR = "dicom_hdr"
|
22
23
|
RDGEHDR = "rdgehdr"
|
23
24
|
PRINTRAW = "printraw"
|
25
|
+
PRINTRAW_SUMMARY = "cat" #"printraw_summary"
|
24
26
|
RUBYDICOM_HDR = "rubydicom"
|
25
|
-
VALID_HEADERS = [DICOM_HDR, PRINTRAW, RDGEHDR, RUBYDICOM_HDR]
|
27
|
+
VALID_HEADERS = [DICOM_HDR, PRINTRAW, RDGEHDR, RUBYDICOM_HDR,PRINTRAW_SUMMARY]
|
26
28
|
MONTHS = {
|
27
29
|
:jan => "01", :feb => "02", :mar => "03", :apr => "04", :may => "05",
|
28
30
|
:jun => "06", :jul => "07", :aug => "08", :sep => "09", :oct => "10",
|
@@ -97,13 +99,21 @@ class RawImageFile
|
|
97
99
|
def initialize(pathtofile)
|
98
100
|
# raise an error if the file doesn't exist
|
99
101
|
absfilepath = File.expand_path(pathtofile)
|
102
|
+
puts "initialize raw image file ="+absfilepath
|
100
103
|
raise(IOError, "File not found at #{absfilepath}.") if not File.exists?(absfilepath)
|
101
104
|
@filename = File.basename(absfilepath)
|
102
105
|
@warnings = []
|
103
|
-
|
106
|
+
|
107
|
+
#if P*.7.summary need different read_header_summary
|
108
|
+
if @filename =~ /^P*\.summary/
|
109
|
+
@hdr_reader = PRINTRAW_SUMMARY
|
110
|
+
end
|
104
111
|
# try to read the header, raise an IOError if unsuccessful
|
105
112
|
begin
|
106
113
|
@hdr_data, @hdr_reader = read_header(absfilepath)
|
114
|
+
if @hdr_reader == nil
|
115
|
+
puts " hdr_reader is nil"
|
116
|
+
end
|
107
117
|
rescue Exception => e
|
108
118
|
raise(IOError, "Header not readable for file #{@filename} using #{@current_hdr_reader ? @current_hdr_reader : "unknown header reader."}. #{e}")
|
109
119
|
end
|
@@ -268,24 +278,36 @@ private
|
|
268
278
|
#
|
269
279
|
# Note: The rdgehdr is a binary file; the correct version for your architecture must be installed in the path.
|
270
280
|
def read_header(absfilepath)
|
281
|
+
tmp_filename= File.basename(absfilepath)
|
271
282
|
|
272
283
|
case File.basename(absfilepath)
|
273
284
|
when /^P.{5}\.7$|^I\..{3}/
|
285
|
+
# check for
|
274
286
|
# Try reading Pfiles or Genesis I-Files with GE's printraw
|
275
287
|
# printraw works on the new waisman p-files
|
276
288
|
# rdgehdr works on wimr p-files, and old waisman p-files
|
277
289
|
@current_hdr_reader = PRINTRAW
|
278
|
-
|
290
|
+
#puts "aaaaaaa absfilepath="+absfilepath
|
279
291
|
header = `#{PRINTRAW} '#{absfilepath}' 2> /dev/null`
|
280
292
|
#header = `#{RDGEHDR} #{absfilepath}`
|
281
|
-
|
293
|
+
# puts "bbbbb pfile header="+header
|
282
294
|
header = header.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "").force_encoding('UTF-8')
|
283
295
|
if ( header.chomp != "" and
|
284
296
|
header.length > MIN_HDR_LENGTH )
|
285
297
|
@current_hdr_reader = nil
|
286
298
|
return [ header, PRINTRAW ]
|
287
299
|
end
|
288
|
-
|
300
|
+
when /^P.{5}\.7\.summary/
|
301
|
+
# check for
|
302
|
+
@current_hdr_reader = PRINTRAW_SUMMARY
|
303
|
+
# puts "aaaaaaa summary absfilepath="+absfilepath
|
304
|
+
header = `#{PRINTRAW_SUMMARY} '#{absfilepath}' 2> /dev/null`
|
305
|
+
header = header.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "").force_encoding('UTF-8')
|
306
|
+
if ( header.chomp != "" and
|
307
|
+
header.length > MIN_HDR_SUMMARY_LENGTH )
|
308
|
+
@current_hdr_reader = nil
|
309
|
+
return [ header, PRINTRAW_SUMMARY ]
|
310
|
+
end
|
289
311
|
|
290
312
|
# Try reading Pfiles or Genesis I-Files with GE's rdgehdr -- rdgehdr newer version needs macos 10.8, adrcdev2 = 10.7.5 -
|
291
313
|
# works on old headers, not on new header format
|
@@ -331,6 +353,7 @@ private
|
|
331
353
|
# All other images are called "dicom".
|
332
354
|
def determine_file_type
|
333
355
|
return "pfile" if image? and (@filename =~ /^P.....\.7/) != nil
|
356
|
+
return "pfile" if (@filename =~ /^P.....\.7\.summary/) != nil
|
334
357
|
return "geifile" if image? and (@filename =~ /^I\.\d*/) != nil
|
335
358
|
return "dicom" if image? and (@filename =~ /^P.....\.7/) == nil
|
336
359
|
return nil
|
@@ -340,13 +363,21 @@ private
|
|
340
363
|
# Parses the header data and extracts a collection of instance variables. If
|
341
364
|
# @hdr_data and @hdr_reader are not already available, this function does nothing.
|
342
365
|
def import_hdr
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
366
|
+
|
367
|
+
if @hdr_reader == nil
|
368
|
+
case @file_type
|
369
|
+
when "pfile" then printraw_summary_import
|
370
|
+
end
|
371
|
+
else
|
372
|
+
raise(IndexError, "No Header Data Available.") if @hdr_data == nil
|
373
|
+
case @hdr_reader
|
374
|
+
when "rubydicom" then rubydicom_hdr_import
|
375
|
+
when "dicom_hdr" then dicom_hdr_import
|
376
|
+
when "printraw" then printraw_import
|
377
|
+
when "rdgehdr" then rdgehdr_import
|
378
|
+
when "cat" then printraw_summary_import
|
379
|
+
end
|
380
|
+
end
|
350
381
|
end
|
351
382
|
|
352
383
|
|
@@ -626,11 +657,8 @@ private
|
|
626
657
|
hdr_data_bak = @hdr_data
|
627
658
|
@hdr_data.encode!("ISO-8859-1", :invalid => :replace).encode("UTF-8") #Attribute was supposed to be a Hash, but was a String
|
628
659
|
|
629
|
-
puts "aaaaaaaaaaa"
|
630
|
-
|
631
660
|
rmr_number_pat =~ @hdr_data
|
632
661
|
@rmr_number = ($1).nil? ? "rmr not found" : ($1).strip.chomp
|
633
|
-
puts "bbbbbbbb "
|
634
662
|
|
635
663
|
source_pat =~ @hdr_data
|
636
664
|
@source = ($1).nil? ? "source not found" : ($1).strip.chomp
|
@@ -676,7 +704,90 @@ private
|
|
676
704
|
image_uid_pat =~ @hdr_data
|
677
705
|
@image_uid = ($1).strip.chomp unless $1.nil?
|
678
706
|
|
679
|
-
puts "rrrrrr @image_uid ="+@image_uid .to_s
|
707
|
+
puts "printraw_import rrrrrr @image_uid ="+@image_uid .to_s
|
708
|
+
@hdr_data = nil
|
709
|
+
|
710
|
+
end
|
711
|
+
|
712
|
+
def printraw_summary_import
|
713
|
+
source_pat = /hospital [Nn]ame: ([[:graph:]\t ]+)/i
|
714
|
+
num_slices_pat = /rdb_hdr_nslices = ([0-9]+)/i
|
715
|
+
slice_thickness_pat = /slthick = ([[:graph:]]+)/i
|
716
|
+
slice_spacing_pat = /scanspacing = ([[:graph:]]+)/i
|
717
|
+
date_pat = /ex_datetime = (.*)\n/i
|
718
|
+
gender_pat = /patsex = (1|2)/i
|
719
|
+
acquisition_matrix_x_pat = /imatrix_X = ([0-9]+)/i
|
720
|
+
acquisition_matrix_y_pat = /imatrix_Y = ([0-9]+)/i
|
721
|
+
series_description_pat = /se_desc = ([[:graph:] \t]+)/i
|
722
|
+
recon_diam_pat = /dfov = ([0-9]+)/i
|
723
|
+
rmr_number_pat = /Patient ID for this exam: ([[:graph:]]+)/i
|
724
|
+
bold_reps_pat = /nex = ([0-9]+)/i
|
725
|
+
rep_time_pat = /reptime = ([0-9]+)/i # not sure ifg this is right
|
726
|
+
study_uid_pat = /Ssop_uid = ([[:graph:]]+)/i
|
727
|
+
series_uid_pat = /series_uid = ([[:graph:]]+)/i
|
728
|
+
image_uid_pat = /image_uid = (.*)/i #([[:graph:]]+)/i
|
729
|
+
|
730
|
+
# @hdr_data = @hdr_data.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "").force_encoding('UTF-8')
|
731
|
+
#@hdr_data = @hdr_data.encode!('UTF-8', 'UTF-8', :invalid => :replace)
|
732
|
+
#@hdr_data_2 = @hdr_data.encode("UTF-8")
|
733
|
+
#@hdr_data.encode!("ISO-8859-1", :invalid => :replace).encode("UTF-8")
|
734
|
+
#@hdr_data.encode("UTF-8", :invalid => :replace, :replace => "") == invalid byte sequence in UTF-8
|
735
|
+
#@hdr_data.encode!("UTF-8", :invalid => :replace, :replace => "") invalid byte sequence in UTF-8
|
736
|
+
#@hdr_data.encode("ISO-8859-1", :invalid => :replace) invalid byte sequence in UTF-8
|
737
|
+
#@hdr_data = @hdr_data.encode('UTF-8','binary', :invalid => :replace,:undef => :replace, :replace =>'') #Attribute was supposed to be a Hash, but was a String
|
738
|
+
#@hdr_data = @hdr_data.encode('UTF-8','UTF-8', :invalid => :replace,:undef => :replace, :replace =>'') # invalid byte sequence in UTF-8
|
739
|
+
#@hdr_data.encode('UTF-8','UTF-8', :invalid => :replace,:undef => :replace, :replace =>'') # invalid byte sequence in UTF-8
|
740
|
+
hdr_data_bak = @hdr_data
|
741
|
+
@hdr_data.encode!("ISO-8859-1", :invalid => :replace).encode("UTF-8") #Attribute was supposed to be a Hash, but was a String
|
742
|
+
|
743
|
+
rmr_number_pat =~ @hdr_data
|
744
|
+
@rmr_number = ($1).nil? ? "rmr not found" : ($1).strip.chomp
|
745
|
+
|
746
|
+
source_pat =~ @hdr_data
|
747
|
+
@source = ($1).nil? ? "source not found" : ($1).strip.chomp
|
748
|
+
|
749
|
+
num_slices_pat =~ @hdr_data
|
750
|
+
@num_slices = ($1).to_i
|
751
|
+
|
752
|
+
slice_thickness_pat =~ @hdr_data
|
753
|
+
@slice_thickness = ($1).to_f
|
754
|
+
|
755
|
+
slice_spacing_pat =~ @hdr_data
|
756
|
+
@slice_spacing = ($1).to_f
|
757
|
+
|
758
|
+
date_pat =~ @hdr_data
|
759
|
+
#@timestamp = Time.at($1.to_i).to_datetime # thought summary date was 1969
|
760
|
+
@timestamp = DateTime.parse($1) # --- 2 rows- same start of line- first since epoch, 2nd date stamnp
|
761
|
+
|
762
|
+
gender_pat =~ @hdr_data
|
763
|
+
@gender = $1 == 1 ? "M" : "F"
|
764
|
+
|
765
|
+
acquisition_matrix_x_pat =~ @hdr_data
|
766
|
+
@acquisition_matrix_x = ($1).to_i
|
767
|
+
acquisition_matrix_y_pat =~ @hdr_data
|
768
|
+
@acquisition_matrix_y = ($1).to_i
|
769
|
+
|
770
|
+
series_description_pat =~ @hdr_data
|
771
|
+
@series_description = ($1).strip.chomp
|
772
|
+
|
773
|
+
recon_diam_pat =~ @hdr_data
|
774
|
+
@reconstruction_diameter = ($1).to_i
|
775
|
+
|
776
|
+
bold_reps_pat =~ @hdr_data
|
777
|
+
@bold_reps = ($1).to_i
|
778
|
+
|
779
|
+
rep_time_pat =~ @hdr_data
|
780
|
+
@rep_time = ($1).to_f / 1000000
|
781
|
+
|
782
|
+
study_uid_pat =~ @hdr_data
|
783
|
+
@study_uid = ($1).strip.chomp unless $1.nil?
|
784
|
+
|
785
|
+
series_uid_pat =~ @hdr_data
|
786
|
+
@series_uid = ($1).strip.chomp unless $1.nil?
|
787
|
+
image_uid_pat =~ @hdr_data
|
788
|
+
@image_uid = ($1).strip.chomp unless $1.nil?
|
789
|
+
|
790
|
+
puts "printraw_summary_import rrrrrr @image_uid ="+@image_uid .to_s
|
680
791
|
@hdr_data = nil
|
681
792
|
|
682
793
|
end
|
data/lib/metamri/version.rb
CHANGED
@@ -61,7 +61,7 @@ class VisitRawDataDirectory
|
|
61
61
|
attr_reader :dicom_study_uid
|
62
62
|
|
63
63
|
PREPROCESS_REPOSITORY_DIRECTORY = '/Data/vtrak1/preprocessed/visits' unless defined?(PREPROCESS_REPOSITORY_DIRECTORY)
|
64
|
-
DATAPANDA_SERVER = '
|
64
|
+
DATAPANDA_SERVER = 'https://adrcdev2.dom.wisc.edu' unless defined?(DATAPANDA_SERVER)
|
65
65
|
# DATAPANDA_SERVER = 'http://localhost:3000' unless defined?(DATAPANDA_SERVER)
|
66
66
|
|
67
67
|
|
@@ -99,10 +99,14 @@ class VisitRawDataDirectory
|
|
99
99
|
|
100
100
|
d = Pathname.new(@visit_directory)
|
101
101
|
d.each_subdirectory do |dd|
|
102
|
+
flash "ppppppppp #{dd}" if $LOG.level <= Logger::INFO
|
102
103
|
begin
|
103
104
|
matches = options[:ignore_patterns].collect {|pat| dd.to_s =~ pat ? dd : nil }.compact
|
104
|
-
next unless matches.empty?
|
105
|
-
dd.
|
105
|
+
next unless matches.empty?
|
106
|
+
# if dd is P*.7.bz2 or P*.7 , check for P*.7.summary
|
107
|
+
dd.each_pfile_non_bz2 { |pf| @datasets << import_dataset(pf, dd); @datasets.last.print_scan_status if $LOG.level == Logger::INFO }
|
108
|
+
dd.each_pfile { |pf| # check for p*.7.summary
|
109
|
+
@datasets << import_dataset(pf, dd); @datasets.last.print_scan_status if $LOG.level == Logger::INFO }
|
106
110
|
dd.first_dicom { |fd| @datasets << import_dataset(fd, dd); @datasets.last.print_scan_status if $LOG.level == Logger::INFO }
|
107
111
|
rescue StandardError => e
|
108
112
|
raise(e, "There was an error scaning dataset #{dd}: #{e}")
|
@@ -362,14 +366,23 @@ Returns an array of the created nifti files.
|
|
362
366
|
# Returns a RawImageDataset built from the directory and single rawfile.
|
363
367
|
def import_dataset(rawfile, original_parent_directory)
|
364
368
|
puts "Importing scan session: #{original_parent_directory.to_s} using raw data file: #{rawfile.basename}" if $LOG.level <= Logger::DEBUG
|
365
|
-
|
366
369
|
begin
|
367
|
-
|
370
|
+
# if summary, change rawfile to /mounts/data/raw/[s]/[enum_exam_date]/mri/dir/P*.summary for
|
371
|
+
tmp_filename = File.basename rawfile.to_s
|
372
|
+
tmp_filname_summary_s = (tmp_filename).gsub(/\.bz2/,"").gsub(/\.summary/,"")+".summary"
|
373
|
+
tmp_branch_summary_s = original_parent_directory.to_s+"/"+tmp_filname_summary_s
|
374
|
+
if File.exist?(tmp_branch_summary_s)
|
375
|
+
#branch_summary_pn = Pathname.new(branch_summary_s)
|
376
|
+
rawimagefile = RawImageFile.new(tmp_branch_summary_s)
|
377
|
+
else
|
378
|
+
rawimagefile = RawImageFile.new(rawfile.to_s)
|
379
|
+
end
|
380
|
+
|
368
381
|
# rescue StandardError => e
|
369
382
|
# puts e.backtrace
|
370
383
|
# raise(e, "+++ Trouble reading raw image file #{rawfile}. #{e}")
|
371
384
|
end
|
372
|
-
|
385
|
+
|
373
386
|
return RawImageDataset.new(original_parent_directory.to_s, [rawimagefile])
|
374
387
|
end
|
375
388
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metamri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristopher J. Kosmatka
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dicom
|