nifti 0.0.1
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 +6 -0
- data/CHANGELOG +13 -0
- data/COPYING +674 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/README.markdown +126 -0
- data/Rakefile +2 -0
- data/lib/nifti/constants.rb +223 -0
- data/lib/nifti/n_object.rb +155 -0
- data/lib/nifti/n_read.rb +264 -0
- data/lib/nifti/n_write.rb +142 -0
- data/lib/nifti/stream.rb +373 -0
- data/lib/nifti/version.rb +4 -0
- data/lib/nifti.rb +23 -0
- data/nifti.gemspec +24 -0
- data/spec/custom_matchers.rb +13 -0
- data/spec/fixtures/3plLoc.nii +0 -0
- data/spec/interactive/compare.rb +43 -0
- data/spec/nifti/n_object_spec.rb +111 -0
- data/spec/nifti/n_read_spec.rb +89 -0
- data/spec/nifti/n_write_spec.rb +56 -0
- data/spec/nifti/stream_spec.rb +44 -0
- data/spec/spec_helper.rb +13 -0
- metadata +138 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NIFTI::NRead do
|
4
|
+
before :all do
|
5
|
+
@string = File.open(NIFTI_TEST_FILE1, 'rb').read
|
6
|
+
@stream = Stream.new(@string, false)
|
7
|
+
@fixture_image_length = 983040
|
8
|
+
@fixture_afni_extension_length = 5661
|
9
|
+
@valid_header = {
|
10
|
+
"xyzt_units"=>2, "pixdim"=>[1.0, 0.9375, 0.9375, 12.5, 0.0, 0.0, 0.0,
|
11
|
+
0.0], "sform_code"=>1, "aux_file"=>"", "scl_slope"=>0.0,
|
12
|
+
"srow_x"=>[-0.9375, -0.0, -0.0, 119.53125], "glmin"=>0, "freq_dim"=>0,
|
13
|
+
"srow_y"=>[-0.0, -0.9375, -0.0, 159.531005859375], "qform_code"=>1,
|
14
|
+
"slice_duration"=>0.0, "cal_min"=>0.0, "db_name"=>"", "magic"=>"n+1",
|
15
|
+
"srow_z"=>[0.0, 0.0, 12.5, -25.0], "quatern_b"=>0.0, "data_type"=>"",
|
16
|
+
"qform_code_descr"=>"NIFTI_XFORM_SCANNER_ANAT",
|
17
|
+
"sform_code_descr"=>"NIFTI_XFORM_SCANNER_ANAT", "intent_name"=>"",
|
18
|
+
"quatern_c"=>0.0, "slice_end"=>0, "scl_inter"=>0.0, "quatern_d"=>1.0,
|
19
|
+
"slice_code"=>0, "sizeof_hdr"=>348, "slice_dim"=>0,
|
20
|
+
"qoffset_x"=>119.53125, "dim_info"=>0, "phase_dim"=>0,
|
21
|
+
"qoffset_y"=>159.531005859375, "descrip"=>"", "datatype"=>4,
|
22
|
+
"intent_p1"=>0.0, "dim"=>[3, 256, 256, 15, 1, 1, 1, 1],
|
23
|
+
"qoffset_z"=>-25.0, "glmax"=>0, "toffset"=>0.0, "bitpix"=>16,
|
24
|
+
"intent_code"=>0, "intent_p2"=>0.0, "session_error"=>0, "extents"=>0,
|
25
|
+
"cal_max"=>0.0, "vox_offset"=>6032.0, "slice_start"=>0,
|
26
|
+
"intent_p3"=>0.0, "regular"=>"r"
|
27
|
+
}
|
28
|
+
@n_read_obj = NRead.new(@string, :bin => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should read a binary string and correctly return header variables" do
|
32
|
+
NRead.new(@string, :bin => true).hdr.should == @valid_header
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should read a nifti file and correctly return header variables" do
|
36
|
+
NRead.new(NIFTI_TEST_FILE1).hdr.should == @valid_header
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should raise IOError if header size != 348." do
|
40
|
+
str = @string.dup
|
41
|
+
str[0..4] = [0].pack("N*")
|
42
|
+
lambda {
|
43
|
+
NRead.new(str, :bin => true).hdr
|
44
|
+
}.should raise_error IOError, /Header appears to be malformed/
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should raise IOError if magic != ni1 or n+1." do
|
48
|
+
str = @string.dup
|
49
|
+
str[344..348] = ["NOPE"].pack("a*")
|
50
|
+
lambda {
|
51
|
+
NRead.new(str, :bin => true).hdr
|
52
|
+
}.should raise_error IOError, /Header appears to be malformed/
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should read image data correctly if :image option is true" do
|
56
|
+
obj = NRead.new(@string, :bin => true, :image => true)
|
57
|
+
obj.image_rubyarray.class.should == Array
|
58
|
+
obj.image_rubyarray.length.should == @fixture_image_length
|
59
|
+
# Since this is a fixture, we know exactly what the values are.
|
60
|
+
# Pick some from the middle of the string and test them.
|
61
|
+
obj.image_rubyarray[(@fixture_image_length / 2)..(@fixture_image_length/2 + 100)].should == [0, 0, 0, 0, 18, 36, 25, 23, 19, 23, 13, 14, 16, 16, 12, 16, 22, 17, 13, 17, 19, 24, 19, 14, 11, 16, 49, 81, 129, 194, 216, 175, 130, 128, 146, 154, 159, 205, 304, 391, 414, 380, 320, 281, 297, 343, 358, 322, 287, 339, 450, 493, 426, 344, 310, 285, 275, 290, 282, 283, 310, 278, 268, 222, 49, 284, 235, 172, 116, 108, 115, 112, 135, 176, 196, 200, 216, 207, 86, 30, 152, 161, 138, 117, 81, 47, 73, 207, 381, 459, 415, 346, 353, 429, 490, 503, 492, 454, 379, 304, 275]
|
62
|
+
obj.image_narray.should be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return an narray if requested" do
|
66
|
+
obj = NRead.new(@string, :bin => true, :narray => true)
|
67
|
+
obj.image_narray.should_not be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should add an NArray Install message and not set the image_narray if NArray was not available" do
|
71
|
+
Object.send(:remove_const, :NArray)
|
72
|
+
obj = NRead.new(@string, :bin => true, :narray => true)
|
73
|
+
obj.msg.should_not be_empty
|
74
|
+
obj.msg.grep(/Please `gem install narray`/).empty?.should be_false
|
75
|
+
obj.image_narray.should be_nil
|
76
|
+
obj.image_rubyarray.size.should == @fixture_image_length
|
77
|
+
require 'narray'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should read extended header attributes" do
|
81
|
+
@n_read_obj.extended_header.should_not be_empty
|
82
|
+
@n_read_obj.extended_header.first[:esize].should == 5680
|
83
|
+
@n_read_obj.extended_header.first[:ecode].should == 4
|
84
|
+
@n_read_obj.extended_header.first[:data].length.should == @fixture_afni_extension_length
|
85
|
+
@n_read_obj.extended_header.first[:data].should == "<?xml version='1.0' ?>\n<AFNI_attributes\n self_idcode=\"XYZ_Fk5B7fY4srOPxYrGolqMIg\"\n NIfTI_nums=\"256,256,15,1,1,4\"\n ni_form=\"ni_group\" >\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"HISTORY_NOTE\" >\n \"[erik@nelson.medicine.wisc.edu: Fri Jan 21 10:24:14 2011] to3d -prefix 3plLoc.nii I0001.dcm I0002.dcm I0003.dcm ... I0014.dcm I0015.dcm\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"TYPESTRING\" >\n \"3DIM_HEAD_ANAT\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"IDCODE_STRING\" >\n \"XYZ_Fk5B7fY4srOPxYrGolqMIg\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"IDCODE_DATE\" >\n \"Fri Jan 21 10:24:15 2011\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"8\"\n atr_name=\"SCENE_DATA\" >\n 0\n 0\n 0\n -999\n -999\n -999\n -999\n -999\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"LABEL_1\" >\n \"3plLoc.nii+orig\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"LABEL_2\" >\n \"Viggo!\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"DATASET_NAME\" >\n \"./3plLoc.nii+orig\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"3\"\n atr_name=\"ORIENT_SPECIFIC\" >\n 0\n 3\n 4\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"3\"\n atr_name=\"ORIGIN\" >\n -119.531\n -159.531\n -25\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"3\"\n atr_name=\"DELTA\" >\n 0.9375\n 0.9375\n 12.5\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"12\"\n atr_name=\"IJK_TO_DICOM\" >\n 0.9375\n 0.9375\n 0.9375\n -360\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n 0\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"12\"\n atr_name=\"IJK_TO_DICOM_REAL\" >\n 0.9375\n 0\n 0\n -119.531\n 0\n 0.9375\n 0\n -159.531\n 0\n 0\n 12.5\n -25\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"30\"\n atr_name=\"MARKS_XYZ\" >\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n -999999\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"1\"\n atr_name=\"MARKS_LAB\" >\n \"AC superior edge~~~~AC posterior margin~PC inferior edge~~~~First mid-sag pt~~~~Another mid-sag pt~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"String\"\n ni_dimen=\"3\"\n atr_name=\"MARKS_HELP\" >\n \"This is the uppermost point
on the anterior commisure,
in the mid-sagittal plane.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is the rearmost point
on the anterior commisure,
in the mid-sagittal plane.
[Just a couple mm behind and
 below the AC superior edge.]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~This is the bottommost point
on the posterior commissure,
in the mid-sagittal plane.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You must also specify two other points in the
mid-sagittal plane, ABOVE the corpus callosum
(i.e., in the longitudinal fissure). These
points are needed to define the vertical plane.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n \"~~~~~~~~~~~~~~~~~~~~~~~~You must also specify two other points in the
mid-sagittal plane, ABOVE the corpus callosum
(i.e., in the longitudinal fissure). These
points are needed to define the vertical plane.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"8\"\n atr_name=\"MARKS_FLAGS\" >\n 1\n 1\n 0\n 0\n 0\n 0\n 0\n 0\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"2\"\n atr_name=\"BRICK_STATS\" >\n 0\n 2402\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"8\"\n atr_name=\"DATASET_RANK\" >\n 3\n 1\n 0\n 0\n 0\n 0\n 0\n 0\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"5\"\n atr_name=\"DATASET_DIMENSIONS\" >\n 256\n 256\n 15\n 0\n 0\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"int\"\n ni_dimen=\"1\"\n atr_name=\"BRICK_TYPES\" >\n 1\n</AFNI_atr>\n\n<AFNI_atr\n ni_type=\"float\"\n ni_dimen=\"1\"\n atr_name=\"BRICK_FLOAT_FACS\" >\n 0\n</AFNI_atr>\n\n</AFNI_attributes>\n"
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NIFTI::NWrite do
|
4
|
+
before :all do
|
5
|
+
@n_object = NObject.new(NIFTI_TEST_FILE1)
|
6
|
+
@new_fixture_file_name = '5PlLoc.nii'
|
7
|
+
@fixture_image_length = 983040
|
8
|
+
@fixture_afni_extension_length = 5661
|
9
|
+
@valid_header = {
|
10
|
+
"xyzt_units"=>2, "pixdim"=>[1.0, 0.9375, 0.9375, 12.5, 0.0, 0.0, 0.0,
|
11
|
+
0.0], "sform_code"=>1, "aux_file"=>"", "scl_slope"=>0.0,
|
12
|
+
"srow_x"=>[-0.9375, -0.0, -0.0, 119.53125], "glmin"=>0, "freq_dim"=>0,
|
13
|
+
"srow_y"=>[-0.0, -0.9375, -0.0, 159.531005859375], "qform_code"=>1,
|
14
|
+
"slice_duration"=>0.0, "cal_min"=>0.0, "db_name"=>"", "magic"=>"n+1",
|
15
|
+
"srow_z"=>[0.0, 0.0, 12.5, -25.0], "quatern_b"=>0.0, "data_type"=>"",
|
16
|
+
"qform_code_descr"=>"NIFTI_XFORM_SCANNER_ANAT",
|
17
|
+
"sform_code_descr"=>"NIFTI_XFORM_SCANNER_ANAT", "intent_name"=>"",
|
18
|
+
"quatern_c"=>0.0, "slice_end"=>0, "scl_inter"=>0.0, "quatern_d"=>1.0,
|
19
|
+
"slice_code"=>0, "sizeof_hdr"=>348, "slice_dim"=>0,
|
20
|
+
"qoffset_x"=>119.53125, "dim_info"=>0, "phase_dim"=>0,
|
21
|
+
"qoffset_y"=>159.531005859375, "descrip"=>"", "datatype"=>4,
|
22
|
+
"intent_p1"=>0.0, "dim"=>[3, 256, 256, 15, 1, 1, 1, 1],
|
23
|
+
"qoffset_z"=>-25.0, "glmax"=>0, "toffset"=>0.0, "bitpix"=>16,
|
24
|
+
"intent_code"=>0, "intent_p2"=>0.0, "session_error"=>0, "extents"=>0,
|
25
|
+
"cal_max"=>0.0, "vox_offset"=>6032.0, "slice_start"=>0,
|
26
|
+
"intent_p3"=>0.0, "regular"=>"r"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should write a NIfTI file" do
|
31
|
+
obj = NObject.new(NIFTI_TEST_FILE1, :image => true)
|
32
|
+
w = NWrite.new(obj, @new_fixture_file_name)
|
33
|
+
w.write
|
34
|
+
w.msg.should be_empty
|
35
|
+
File.exist? @new_fixture_file_name.should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should write back an identical file if no changes were made" do
|
39
|
+
obj = NObject.new(NIFTI_TEST_FILE1, :image => true)
|
40
|
+
w = NWrite.new(obj, @new_fixture_file_name)
|
41
|
+
w.write
|
42
|
+
@new_fixture_file_name.should be_same_file_as NIFTI_TEST_FILE1
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should write a new image after changing some variables" do
|
46
|
+
obj = NObject.new(NIFTI_TEST_FILE1, :image => true)
|
47
|
+
obj.header['qoffset_x'] = obj.header['qoffset_x'] + 1
|
48
|
+
w = NWrite.new(obj, @new_fixture_file_name)
|
49
|
+
w.write
|
50
|
+
@new_fixture_file_name.should_not be_same_file_as NIFTI_TEST_FILE1
|
51
|
+
end
|
52
|
+
|
53
|
+
after :each do
|
54
|
+
File.delete @new_fixture_file_name if File.exist? @new_fixture_file_name
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NIFTI::Stream do
|
4
|
+
before :each do
|
5
|
+
@string = File.open(NIFTI_TEST_FILE1, 'rb').read
|
6
|
+
@endianess = false
|
7
|
+
@stream = Stream.new(@string, @endianess)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create a well-behaved stream instance given a binary string" do
|
11
|
+
stream = Stream.new(@string, @endianess)
|
12
|
+
stream.index.should == 0
|
13
|
+
stream.string.should == @string
|
14
|
+
stream.errors.should be_empty
|
15
|
+
stream.str_endian.should == @endianess
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should be able to jump around within a string" do
|
19
|
+
@stream.skip 5
|
20
|
+
@stream.index.should == 5
|
21
|
+
@stream.skip -3
|
22
|
+
@stream.index.should == 2
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should read the size of the header as 348" do
|
26
|
+
@stream.decode(4, "UL").should == 348
|
27
|
+
end
|
28
|
+
|
29
|
+
it "unused Analyze header datatype field should be blank" do
|
30
|
+
@stream.skip 4
|
31
|
+
@stream.decode(10, "STR").should == ""
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should read the datatype as something" do
|
35
|
+
@stream.skip 14
|
36
|
+
@stream.decode(18, "STR").should == ""
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should read the dim as something" do
|
40
|
+
@stream.skip 40
|
41
|
+
@stream.decode(16, "US").should == [3, 256, 256, 15, 1, 1, 1, 1]
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/nifti'
|
2
|
+
require 'custom_matchers'
|
3
|
+
|
4
|
+
include NIFTI
|
5
|
+
|
6
|
+
module NIFTI
|
7
|
+
# Fixture file to use for specs/tests
|
8
|
+
NIFTI_TEST_FILE1 = File.join(File.dirname(__FILE__), 'fixtures/3plLoc.nii')
|
9
|
+
end
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.mock_with :mocha
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nifti
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Erik Kastman
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-07 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rspec
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mocha
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: narray
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: A pure Ruby API to the NIfTI Neuroimaging Format
|
64
|
+
email:
|
65
|
+
- ekk@medicine.wisc.edu
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
files:
|
73
|
+
- .gitignore
|
74
|
+
- CHANGELOG
|
75
|
+
- COPYING
|
76
|
+
- Gemfile
|
77
|
+
- Gemfile.lock
|
78
|
+
- README.markdown
|
79
|
+
- Rakefile
|
80
|
+
- lib/nifti.rb
|
81
|
+
- lib/nifti/constants.rb
|
82
|
+
- lib/nifti/n_object.rb
|
83
|
+
- lib/nifti/n_read.rb
|
84
|
+
- lib/nifti/n_write.rb
|
85
|
+
- lib/nifti/stream.rb
|
86
|
+
- lib/nifti/version.rb
|
87
|
+
- nifti.gemspec
|
88
|
+
- spec/custom_matchers.rb
|
89
|
+
- spec/fixtures/3plLoc.nii
|
90
|
+
- spec/interactive/compare.rb
|
91
|
+
- spec/nifti/n_object_spec.rb
|
92
|
+
- spec/nifti/n_read_spec.rb
|
93
|
+
- spec/nifti/n_write_spec.rb
|
94
|
+
- spec/nifti/stream_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
has_rdoc: true
|
97
|
+
homepage: ""
|
98
|
+
licenses: []
|
99
|
+
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project: nifti
|
126
|
+
rubygems_version: 1.4.1
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: A pure Ruby API to the NIfTI Neuroimaging Format
|
130
|
+
test_files:
|
131
|
+
- spec/custom_matchers.rb
|
132
|
+
- spec/fixtures/3plLoc.nii
|
133
|
+
- spec/interactive/compare.rb
|
134
|
+
- spec/nifti/n_object_spec.rb
|
135
|
+
- spec/nifti/n_read_spec.rb
|
136
|
+
- spec/nifti/n_write_spec.rb
|
137
|
+
- spec/nifti/stream_spec.rb
|
138
|
+
- spec/spec_helper.rb
|