metamri 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
@@ -1,10 +1,4 @@
1
- #!/usr/bin/env ruby
2
-
3
- =begin rdoc
4
- Builds Nifti files from Dicoms.
5
- =end
6
-
7
-
1
+ # Builds Nifti files from Dicoms.
8
2
  module UnknownImageDataset
9
3
  # Always set AFNI GE DICOM Fix to "No" before conversion with to3d.
10
4
  ENV['AFNI_SLICE_SPACING_IS_GAP'] = "NO"
@@ -26,7 +20,7 @@ module UnknownImageDataset
26
20
 
27
21
  nifti_output_file = File.join(nifti_output_directory, nifti_filename)
28
22
 
29
- File.makedirs(nifti_output_directory) unless File.directory?(nifti_output_directory)
23
+ FileUtils.makedirs(nifti_output_directory) unless File.directory?(nifti_output_directory)
30
24
  raise(IOError, "Cannot write to #{nifti_output_directory}") unless File.writable?(nifti_output_directory)
31
25
 
32
26
  nifti_conversion_command = "to3d -session #{nifti_output_directory} -prefix #{[nifti_filename, functional_args, input_files].compact.join(' ')}"
@@ -338,6 +338,18 @@ Returns a path to the created dataset as a string if successful.
338
338
  @raw_image_files.first.dicom?
339
339
  end
340
340
 
341
+ # Helper predicate method to check whether the dataset is a DICOM dataset or not.
342
+ # This just sends dicom? to the first raw file in the dataset.
343
+ def pfile?
344
+ @raw_image_files.first.pfile?
345
+ end
346
+
347
+ # Helper predicate method to check whether the dataset is a DICOM dataset or not.
348
+ # This just sends dicom? to the first raw file in the dataset.
349
+ def geifile?
350
+ @raw_image_files.first.geifile?
351
+ end
352
+
341
353
  private
342
354
 
343
355
  # Gets the earliest timestamp among the raw image files in this dataset.
@@ -577,6 +577,8 @@ private
577
577
  rmr_number_pat = /Patient ID for this exam: ([[:graph:]]+)/i
578
578
  bold_reps_pat = /Number of excitations: ([0-9]+)/i
579
579
  rep_time_pat = /Pulse repetition time \(usec\): ([0-9]+)/i
580
+ study_uid_pat = /Study entity unique ID: ([[:graph:]]+)/i
581
+ series_uid_pat = /Series entity unique ID: ([[:graph:]]+)/i
580
582
 
581
583
  rmr_number_pat =~ @hdr_data
582
584
  @rmr_number = ($1).nil? ? "rmr not found" : ($1).strip.chomp
@@ -615,6 +617,12 @@ private
615
617
 
616
618
  rep_time_pat =~ @hdr_data
617
619
  @rep_time = ($1).to_f / 1000000
620
+
621
+ study_uid_pat =~ @hdr_data
622
+ @dicom_study_uid = ($1).strip.chomp
623
+
624
+ series_uid_pat =~ @hdr_data
625
+ @dicom_series_uid = ($1).strip.chomp
618
626
  end
619
627
 
620
628
  end
@@ -111,7 +111,7 @@ class VisitRawDataDirectory
111
111
  @rmr_number = get_rmr_number
112
112
  @scanner_source = get_scanner_source
113
113
  @study_id = get_study_id
114
- @dicom_study_uid = get_dicom_study_uid
114
+ @dicom_study_uid = get_dicom_study_uid unless dicom_datasets.empty?
115
115
  flash "Completed scanning #{@visit_directory}" if $LOG.level <= Logger::DEBUG
116
116
  else
117
117
  raise(IndexError, "No datasets could be scanned for directory #{@visit_directory}")
@@ -472,6 +472,12 @@ Returns an array of the created nifti files.
472
472
  end
473
473
  end
474
474
 
475
+ def dicom_datasets
476
+ dicom_sets ||= []
477
+ datasets.each {|ds| dicom_sets << ds if ds.dicom?}
478
+ return dicom_sets
479
+ end
480
+
475
481
  def initialize_log
476
482
  # If a log hasn't been created, catch that here and go to STDOUT.
477
483
  unless $LOG
data/lib/metamri.rb CHANGED
@@ -15,6 +15,7 @@ require 'metamri/raw_image_dataset_resource'
15
15
  require 'metamri/visit_raw_data_directory_resource'
16
16
  require 'metamri/image_dataset_quality_check_resource'
17
17
  require 'metamri/dicom_additions'
18
+ require 'fileutils'
18
19
 
19
20
  # require 'metamri/raw_image_dataset_thumbnail'
20
21
  # TODO Move raw_image_dataset_thumbnail out of metamri.
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.4"
8
+ s.version = "0.2.5"
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{2011-03-07}
12
+ s.date = %q{2011-03-14}
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"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metamri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kristopher J. Kosmatka
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 -06:00
18
+ date: 2011-03-14 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency