c_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.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/COPYING +621 -0
  7. data/COPYING.lesser +166 -0
  8. data/Gemfile +4 -0
  9. data/README.md +117 -0
  10. data/Rakefile +6 -0
  11. data/c_nifti.gemspec +31 -0
  12. data/ext/nifticlib/extconf.rb +30 -0
  13. data/ext/nifticlib/include/nifti_image.h +2 -0
  14. data/ext/nifticlib/include/nifti_image_converters.h +3 -0
  15. data/ext/nifticlib/include/nifti_image_dimensions.h +1 -0
  16. data/ext/nifticlib/include/nifti_image_intents.h +1 -0
  17. data/ext/nifticlib/include/nifti_image_metadata.h +1 -0
  18. data/ext/nifticlib/include/nifti_image_quaternions.h +1 -0
  19. data/ext/nifticlib/include/nifti_image_spacings.h +1 -0
  20. data/ext/nifticlib/include/nifti_image_timings.h +1 -0
  21. data/ext/nifticlib/include/nifti_image_transforms.h +1 -0
  22. data/ext/nifticlib/nifti_image.c +169 -0
  23. data/ext/nifticlib/nifti_image_converters.c +65 -0
  24. data/ext/nifticlib/nifti_image_dimensions.c +113 -0
  25. data/ext/nifticlib/nifti_image_intents.c +45 -0
  26. data/ext/nifticlib/nifti_image_metadata.c +133 -0
  27. data/ext/nifticlib/nifti_image_quaternions.c +59 -0
  28. data/ext/nifticlib/nifti_image_spacings.c +87 -0
  29. data/ext/nifticlib/nifti_image_timings.c +66 -0
  30. data/ext/nifticlib/nifti_image_transforms.c +38 -0
  31. data/ext/nifticlib/nifticlib-2.0.0/CMakeLists.txt +140 -0
  32. data/ext/nifticlib/nifticlib-2.0.0/CTestConfig.cmake +13 -0
  33. data/ext/nifticlib/nifticlib-2.0.0/LICENSE +9 -0
  34. data/ext/nifticlib/nifticlib-2.0.0/Makefile +265 -0
  35. data/ext/nifticlib/nifticlib-2.0.0/Makefile.cross_mingw32 +94 -0
  36. data/ext/nifticlib/nifticlib-2.0.0/README +79 -0
  37. data/ext/nifticlib/nifticlib-2.0.0/Testing/CMakeLists.txt +7 -0
  38. data/ext/nifticlib/nifticlib-2.0.0/Testing/Data/ATestReferenceImageForReadingAndWriting.nii.gz +0 -0
  39. data/ext/nifticlib/nifticlib-2.0.0/Testing/Makefile +21 -0
  40. data/ext/nifticlib/nifticlib-2.0.0/Testing/README_regress +50 -0
  41. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/@show.diffs +33 -0
  42. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/@test +80 -0
  43. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/CMakeLists.txt +47 -0
  44. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/bricks_test.sh +32 -0
  45. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/comment_test.sh +65 -0
  46. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dci_test.sh +46 -0
  47. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dsets_test.sh +61 -0
  48. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dts_test.sh +75 -0
  49. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/fetch_data_test.sh +45 -0
  50. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/mod_header_test.sh +60 -0
  51. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/newfiles_test.sh +36 -0
  52. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c01.versions +10 -0
  53. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c02.nt.help +5 -0
  54. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c03.hist +5 -0
  55. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c04.disp.anat0.info +7 -0
  56. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c05.mod.hdr +9 -0
  57. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c06.add.ext +22 -0
  58. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c07.cbl.4bricks +8 -0
  59. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c08.dts.19.36.11 +4 -0
  60. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c09.dts4.compare +9 -0
  61. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c10.dci.ts4 +15 -0
  62. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c10a.dci.run.210 +16 -0
  63. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c11.add.comment +8 -0
  64. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c12.check.comments +7 -0
  65. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c13.check.hdrs +5 -0
  66. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c14.make.dsets +21 -0
  67. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c15.new.files +21 -0
  68. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c16.rand.swap +35 -0
  69. data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c17.file.case +34 -0
  70. data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/CMakeLists.txt +15 -0
  71. data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/nifti_test.c +690 -0
  72. data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/nifti_test2.c +32 -0
  73. data/ext/nifticlib/nifticlib-2.0.0/Updates.txt +110 -0
  74. data/ext/nifticlib/nifticlib-2.0.0/bin/.gitkeep +0 -0
  75. data/ext/nifticlib/nifticlib-2.0.0/docs/Doxy_nifti.txt +123 -0
  76. data/ext/nifticlib/nifticlib-2.0.0/docs/Doxyfile.ORIG +746 -0
  77. data/ext/nifticlib/nifticlib-2.0.0/examples/CMakeLists.txt +15 -0
  78. data/ext/nifticlib/nifticlib-2.0.0/examples/Makefile +48 -0
  79. data/ext/nifticlib/nifticlib-2.0.0/examples/clib_01_read_write.c +94 -0
  80. data/ext/nifticlib/nifticlib-2.0.0/examples/fsl_api_driver.c +142 -0
  81. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/CMakeLists.txt +32 -0
  82. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/Makefile +29 -0
  83. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/fslio.c +2426 -0
  84. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/fslio.tcl +83 -0
  85. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imcp +65 -0
  86. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imglob +59 -0
  87. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imln +37 -0
  88. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/immv +64 -0
  89. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imrm +29 -0
  90. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imtest +53 -0
  91. data/ext/nifticlib/nifticlib-2.0.0/fsliolib/remove_ext +33 -0
  92. data/ext/nifticlib/nifticlib-2.0.0/include/.gitkeep +0 -0
  93. data/ext/nifticlib/nifticlib-2.0.0/nifticdf/CMakeLists.txt +28 -0
  94. data/ext/nifticlib/nifticlib-2.0.0/nifticdf/Makefile +28 -0
  95. data/ext/nifticlib/nifticlib-2.0.0/nifticdf/nifticdf.c +11107 -0
  96. data/ext/nifticlib/nifticlib-2.0.0/niftilib/CMakeLists.txt +33 -0
  97. data/ext/nifticlib/nifticlib-2.0.0/niftilib/Makefile +31 -0
  98. data/ext/nifticlib/nifticlib-2.0.0/niftilib/nifti1_io.c +7509 -0
  99. data/ext/nifticlib/nifticlib-2.0.0/packaging/DevPackage.template +18 -0
  100. data/ext/nifticlib/nifticlib-2.0.0/packaging/nifticlib.spec +62 -0
  101. data/ext/nifticlib/nifticlib-2.0.0/real_easy/nifti1_read_write.c +361 -0
  102. data/ext/nifticlib/nifticlib-2.0.0/utils/CMakeLists.txt +73 -0
  103. data/ext/nifticlib/nifticlib-2.0.0/utils/Makefile +55 -0
  104. data/ext/nifticlib/nifticlib-2.0.0/utils/nifti1_test.c +95 -0
  105. data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_stats.c +95 -0
  106. data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_tool.c +4193 -0
  107. data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_tool.h +163 -0
  108. data/ext/nifticlib/nifticlib-2.0.0/znzlib/CMakeLists.txt +31 -0
  109. data/ext/nifticlib/nifticlib-2.0.0/znzlib/Makefile +33 -0
  110. data/ext/nifticlib/nifticlib-2.0.0/znzlib/znzlib.c +322 -0
  111. data/ext/nifticlib/nifticlib.c +107 -0
  112. data/ext/nifticlib/patches/nifticlib_fpic.patch +13 -0
  113. data/features/read_modify_write.feature +11 -0
  114. data/features/step_definitions/nifti_image_steps.rb +16 -0
  115. data/features/support/env.rb +14 -0
  116. data/features/support/fixtures/sample.nii.gz +0 -0
  117. data/lib/c_nifti.rb +9 -0
  118. data/lib/c_nifti/data.rb +70 -0
  119. data/lib/c_nifti/header.rb +16 -0
  120. data/lib/c_nifti/header_element.rb +13 -0
  121. data/lib/c_nifti/header_element/datatype.rb +49 -0
  122. data/lib/c_nifti/header_element/datatype/base.rb +9 -0
  123. data/lib/c_nifti/header_element/datatype/binary.rb +11 -0
  124. data/lib/c_nifti/header_element/datatype/double.rb +11 -0
  125. data/lib/c_nifti/header_element/datatype/float.rb +11 -0
  126. data/lib/c_nifti/header_element/datatype/long_double.rb +11 -0
  127. data/lib/c_nifti/header_element/datatype/long_long.rb +11 -0
  128. data/lib/c_nifti/header_element/datatype/signed_char.rb +11 -0
  129. data/lib/c_nifti/header_element/datatype/signed_int.rb +11 -0
  130. data/lib/c_nifti/header_element/datatype/signed_short.rb +11 -0
  131. data/lib/c_nifti/header_element/datatype/unsigned_char.rb +11 -0
  132. data/lib/c_nifti/header_element/datatype/unsigned_int.rb +11 -0
  133. data/lib/c_nifti/header_element/datatype/unsigned_long_long.rb +11 -0
  134. data/lib/c_nifti/header_element/datatype/unsigned_short.rb +11 -0
  135. data/lib/c_nifti/header_element/dimensions.rb +53 -0
  136. data/lib/c_nifti/header_element/intents.rb +25 -0
  137. data/lib/c_nifti/header_element/metadata.rb +49 -0
  138. data/lib/c_nifti/header_element/miscellaneous.rb +25 -0
  139. data/lib/c_nifti/header_element/quaternions.rb +33 -0
  140. data/lib/c_nifti/header_element/spacings.rb +45 -0
  141. data/lib/c_nifti/header_element/timings.rb +37 -0
  142. data/lib/c_nifti/header_element/transforms.rb +21 -0
  143. data/lib/c_nifti/image.rb +31 -0
  144. data/lib/c_nifti/version.rb +3 -0
  145. data/lib/nifticlib.rb +1 -0
  146. data/spec/data_spec.rb +112 -0
  147. data/spec/factories/nifti_images.rb +9 -0
  148. data/spec/header_element/datatype/base_spec.rb +9 -0
  149. data/spec/header_element/datatype/binary_spec.rb +9 -0
  150. data/spec/header_element/datatype/double_spec.rb +9 -0
  151. data/spec/header_element/datatype/float_spec.rb +9 -0
  152. data/spec/header_element/datatype/long_double_spec.rb +9 -0
  153. data/spec/header_element/datatype/long_long_spec.rb +9 -0
  154. data/spec/header_element/datatype/signed_char_spec.rb +9 -0
  155. data/spec/header_element/datatype/signed_int_spec.rb +9 -0
  156. data/spec/header_element/datatype/signed_short_spec.rb +9 -0
  157. data/spec/header_element/datatype/unsigned_char_spec.rb +9 -0
  158. data/spec/header_element/datatype/unsigned_int_spec.rb +9 -0
  159. data/spec/header_element/datatype/unsigned_long_long.rb +9 -0
  160. data/spec/header_element/datatype/unsigned_short_spec.rb +9 -0
  161. data/spec/header_element/datatype_spec.rb +109 -0
  162. data/spec/header_element/dimensions_spec.rb +105 -0
  163. data/spec/header_element/intents_spec.rb +48 -0
  164. data/spec/header_element/metadata_spec.rb +96 -0
  165. data/spec/header_element/miscellaneous_spec.rb +48 -0
  166. data/spec/header_element/quaternions_spec.rb +64 -0
  167. data/spec/header_element/spacings_spec.rb +88 -0
  168. data/spec/header_element/timings_spec.rb +72 -0
  169. data/spec/header_element/transforms_spec.rb +64 -0
  170. data/spec/image_spec.rb +39 -0
  171. data/spec/spec_helper.rb +85 -0
  172. metadata +363 -0
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Header do
4
+ let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
5
+ subject { CNifti::Header.new(nifti_image) }
6
+
7
+ describe 'miscellaneous' do
8
+ describe 'scl_slope' do
9
+ it 'is expected call the scl_slope method from NIfTICLib::NIfTIImage' do
10
+ nifti_image.expects(:scl_slope).returns(1.4)
11
+
12
+ expect(subject.scl_slope).to eq(1.4)
13
+ end
14
+ end
15
+
16
+ describe 'scl_inter' do
17
+ it 'is expected call the scl_inter method from NIfTICLib::NIfTIImage' do
18
+ nifti_image.expects(:scl_inter).returns(1.4)
19
+
20
+ expect(subject.scl_inter).to eq(1.4)
21
+ end
22
+ end
23
+
24
+ describe 'cal_min' do
25
+ it 'is expected call the cal_min method from NIfTICLib::NIfTIImage' do
26
+ nifti_image.expects(:cal_min).returns(1.4)
27
+
28
+ expect(subject.cal_min).to eq(1.4)
29
+ end
30
+ end
31
+
32
+ describe 'cal_max' do
33
+ it 'is expected call the cal_max method from NIfTICLib::NIfTIImage' do
34
+ nifti_image.expects(:cal_max).returns(1.4)
35
+
36
+ expect(subject.cal_max).to eq(1.4)
37
+ end
38
+ end
39
+
40
+ describe 'type' do
41
+ it 'is expected call the nifti_type method from NIfTICLib::NIfTIImage' do
42
+ nifti_image.expects(:nifti_type).returns(1)
43
+
44
+ expect(subject.type).to eq(1)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Header do
4
+ let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
5
+ subject { CNifti::Header.new(nifti_image) }
6
+
7
+ describe 'quaternions' do
8
+ describe 'quatern_b' do
9
+ it 'is expected call the quatern_b method from NIfTICLib::NIfTIImage' do
10
+ nifti_image.expects(:quatern_b).returns(1.4)
11
+
12
+ expect(subject.quatern_b).to eq(1.4)
13
+ end
14
+ end
15
+
16
+ describe 'quatern_c' do
17
+ it 'is expected call the quatern_c method from NIfTICLib::NIfTIImage' do
18
+ nifti_image.expects(:quatern_c).returns(1.4)
19
+
20
+ expect(subject.quatern_c).to eq(1.4)
21
+ end
22
+ end
23
+
24
+ describe 'quatern_d' do
25
+ it 'is expected call the quatern_d method from NIfTICLib::NIfTIImage' do
26
+ nifti_image.expects(:quatern_d).returns(1.4)
27
+
28
+ expect(subject.quatern_d).to eq(1.4)
29
+ end
30
+ end
31
+
32
+ describe 'qoffset_x' do
33
+ it 'is expected call the qoffset_x method from NIfTICLib::NIfTIImage' do
34
+ nifti_image.expects(:qoffset_x).returns(1.4)
35
+
36
+ expect(subject.qoffset_x).to eq(1.4)
37
+ end
38
+ end
39
+
40
+ describe 'qoffset_y' do
41
+ it 'is expected call the qoffset_y method from NIfTICLib::NIfTIImage' do
42
+ nifti_image.expects(:qoffset_y).returns(1.4)
43
+
44
+ expect(subject.qoffset_y).to eq(1.4)
45
+ end
46
+ end
47
+
48
+ describe 'qoffset_z' do
49
+ it 'is expected call the qoffset_z method from NIfTICLib::NIfTIImage' do
50
+ nifti_image.expects(:qoffset_z).returns(1.4)
51
+
52
+ expect(subject.qoffset_z).to eq(1.4)
53
+ end
54
+ end
55
+
56
+ describe 'qfac' do
57
+ it 'is expected call the qfac method from NIfTICLib::NIfTIImage' do
58
+ nifti_image.expects(:qfac).returns(1.4)
59
+
60
+ expect(subject.qfac).to eq(1.4)
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Header do
4
+ let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
5
+ subject { CNifti::Header.new(nifti_image) }
6
+
7
+ describe 'spacings' do
8
+ describe 'dx' do
9
+ it 'is expected call the dx method from NIfTICLib::NIfTIImage' do
10
+ nifti_image.expects(:dx).returns(1.4)
11
+
12
+ expect(subject.dx).to eq(1.4)
13
+ end
14
+ end
15
+
16
+ describe 'dy' do
17
+ it 'is expected call the dy method from NIfTICLib::NIfTIImage' do
18
+ nifti_image.expects(:dy).returns(1.4)
19
+
20
+ expect(subject.dy).to eq(1.4)
21
+ end
22
+ end
23
+
24
+ describe 'dz' do
25
+ it 'is expected call the dz method from NIfTICLib::NIfTIImage' do
26
+ nifti_image.expects(:dz).returns(1.4)
27
+
28
+ expect(subject.dz).to eq(1.4)
29
+ end
30
+ end
31
+
32
+ describe 'dt' do
33
+ it 'is expected call the dt method from NIfTICLib::NIfTIImage' do
34
+ nifti_image.expects(:dt).returns(1.4)
35
+
36
+ expect(subject.dt).to eq(1.4)
37
+ end
38
+ end
39
+
40
+ describe 'du' do
41
+ it 'is expected call the du method from NIfTICLib::NIfTIImage' do
42
+ nifti_image.expects(:du).returns(1.4)
43
+
44
+ expect(subject.du).to eq(1.4)
45
+ end
46
+ end
47
+
48
+ describe 'dv' do
49
+ it 'is expected call the dv method from NIfTICLib::NIfTIImage' do
50
+ nifti_image.expects(:dv).returns(1.4)
51
+
52
+ expect(subject.dv).to eq(1.4)
53
+ end
54
+ end
55
+
56
+ describe 'dw' do
57
+ it 'is expected call the dw method from NIfTICLib::NIfTIImage' do
58
+ nifti_image.expects(:dw).returns(1.4)
59
+
60
+ expect(subject.dw).to eq(1.4)
61
+ end
62
+ end
63
+
64
+ describe 'pixel_dimensions' do
65
+ it 'is expected call the pixdim method from NIfTICLib::NIfTIImage' do
66
+ nifti_image.expects(:pixdim).returns([1.4])
67
+
68
+ expect(subject.pixel_dimensions).to eq([1.4])
69
+ end
70
+ end
71
+
72
+ describe 'qform_code' do
73
+ it 'is expected call the qform_code method from NIfTICLib::NIfTIImage' do
74
+ nifti_image.expects(:qform_code).returns(1.4)
75
+
76
+ expect(subject.qform_code).to eq(1.4)
77
+ end
78
+ end
79
+
80
+ describe 'sform_code' do
81
+ it 'is expected call the sform_code method from NIfTICLib::NIfTIImage' do
82
+ nifti_image.expects(:sform_code).returns(1.4)
83
+
84
+ expect(subject.sform_code).to eq(1.4)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Header do
4
+ let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
5
+ subject { CNifti::Header.new(nifti_image) }
6
+
7
+ describe 'timings' do
8
+ describe 'freq_dim' do
9
+ it 'is expected call the freq_dim method from NIfTICLib::NIfTIImage' do
10
+ nifti_image.expects(:freq_dim).returns(4)
11
+
12
+ expect(subject.freq_dim).to eq(4)
13
+ end
14
+ end
15
+
16
+ describe 'phase_dim' do
17
+ it 'is expected call the phase_dim method from NIfTICLib::NIfTIImage' do
18
+ nifti_image.expects(:phase_dim).returns(4)
19
+
20
+ expect(subject.phase_dim).to eq(4)
21
+ end
22
+ end
23
+
24
+ describe 'slice_dim' do
25
+ it 'is expected call the slice_dim method from NIfTICLib::NIfTIImage' do
26
+ nifti_image.expects(:slice_dim).returns(4)
27
+
28
+ expect(subject.slice_dim).to eq(4)
29
+ end
30
+ end
31
+
32
+ describe 'slice_code' do
33
+ it 'is expected call the slice_code method from NIfTICLib::NIfTIImage' do
34
+ nifti_image.expects(:slice_code).returns(4)
35
+
36
+ expect(subject.slice_code).to eq(4)
37
+ end
38
+ end
39
+
40
+ describe 'slice_start' do
41
+ it 'is expected call the slice_start method from NIfTICLib::NIfTIImage' do
42
+ nifti_image.expects(:slice_start).returns(4)
43
+
44
+ expect(subject.slice_start).to eq(4)
45
+ end
46
+ end
47
+
48
+ describe 'slice_end' do
49
+ it 'is expected call the slice_end method from NIfTICLib::NIfTIImage' do
50
+ nifti_image.expects(:slice_end).returns(4)
51
+
52
+ expect(subject.slice_end).to eq(4)
53
+ end
54
+ end
55
+
56
+ describe 'slice_duration' do
57
+ it 'is expected call the slice_duration method from NIfTICLib::NIfTIImage' do
58
+ nifti_image.expects(:slice_duration).returns(1.4)
59
+
60
+ expect(subject.slice_duration).to eq(1.4)
61
+ end
62
+ end
63
+
64
+ describe 'toffset' do
65
+ it 'is expected call the toffset method from NIfTICLib::NIfTIImage' do
66
+ nifti_image.expects(:toffset).returns(1.4)
67
+
68
+ expect(subject.toffset).to eq(1.4)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Header do
4
+ let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
5
+ subject { CNifti::Header.new(nifti_image) }
6
+
7
+ describe 'transforms' do
8
+ describe 'qto_xyz' do
9
+ it 'is expected call the qto_xyz method from NIfTICLib::NIfTIImage' do
10
+ nifti_image.expects(:qto_xyz).returns([[1,0,0,0],
11
+ [0,1,0,0],
12
+ [0,0,1,0],
13
+ [0,0,0,1]])
14
+
15
+ expect(subject.qto_xyz).to eq([[1,0,0,0],
16
+ [0,1,0,0],
17
+ [0,0,1,0],
18
+ [0,0,0,1]])
19
+ end
20
+ end
21
+
22
+ describe 'qto_ijk' do
23
+ it 'is expected call the qto_ijk method from NIfTICLib::NIfTIImage' do
24
+ nifti_image.expects(:qto_ijk).returns([[1,0,0,0],
25
+ [0,1,0,0],
26
+ [0,0,1,0],
27
+ [0,0,0,1]])
28
+
29
+ expect(subject.qto_ijk).to eq([[1,0,0,0],
30
+ [0,1,0,0],
31
+ [0,0,1,0],
32
+ [0,0,0,1]])
33
+ end
34
+ end
35
+
36
+ describe 'sto_xyz' do
37
+ it 'is expected call the sto_xyz method from NIfTICLib::NIfTIImage' do
38
+ nifti_image.expects(:sto_xyz).returns([[1,0,0,0],
39
+ [0,1,0,0],
40
+ [0,0,1,0],
41
+ [0,0,0,1]])
42
+
43
+ expect(subject.sto_xyz).to eq([[1,0,0,0],
44
+ [0,1,0,0],
45
+ [0,0,1,0],
46
+ [0,0,0,1]])
47
+ end
48
+ end
49
+
50
+ describe 'sto_ijk' do
51
+ it 'is expected call the sto_ijk method from NIfTICLib::NIfTIImage' do
52
+ nifti_image.expects(:sto_ijk).returns([[1,0,0,0],
53
+ [0,1,0,0],
54
+ [0,0,1,0],
55
+ [0,0,0,1]])
56
+
57
+ expect(subject.sto_ijk).to eq([[1,0,0,0],
58
+ [0,1,0,0],
59
+ [0,0,1,0],
60
+ [0,0,0,1]])
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe CNifti::Image do
4
+ describe 'new' do
5
+ let(:dims) { [3,3,3] }
6
+
7
+ before :each do
8
+ CNifti::HeaderElement::Datatype::Base.expects(:to_i).returns(0)
9
+ end
10
+
11
+ it 'is expected call the new method from NIfTICLib::NIfTIImage' do
12
+ NIfTICLib::NIfTIImage.expects(:new).with(([3] + dims), 0, 1)
13
+
14
+ CNifti::Image.new(dimensions: dims, datatype: CNifti::HeaderElement::Datatype::Base)
15
+ end
16
+ end
17
+
18
+ describe 'open' do
19
+ let(:path) { 'test/test.nii.gz' }
20
+ let(:nifti_image) { FactoryGirl.build(:nifti_image) }
21
+
22
+ it 'is expected to read from path and set the header and data' do
23
+ NIfTICLib.expects(:read).with(path).returns(nifti_image)
24
+
25
+ expect(subject.open(path)).to be_a(CNifti::Image)
26
+ end
27
+ end
28
+
29
+ describe 'save_as' do
30
+ let(:path) { 'test/test.nii.gz' }
31
+ let(:nifti_image) { FactoryGirl.build(:nifti_image) }
32
+
33
+ it 'is expected to read from path and set the header and data' do
34
+ NIfTICLib.expects(:write).returns(nifti_image)
35
+
36
+ expect(subject.save_as(path)).to be_truthy
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,85 @@
1
+ require 'mocha/api'
2
+
3
+ # Test coverage report
4
+ require 'simplecov'
5
+
6
+ SimpleCov.start do
7
+ add_filter "/spec/"
8
+ add_filter "/features/"
9
+
10
+ coverage_dir 'coverage/rspec'
11
+ end
12
+
13
+ require 'c_nifti'
14
+
15
+ require 'factory_girl'
16
+ FactoryGirl.find_definitions
17
+
18
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
19
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
20
+ # The generated `.rspec` file contains `--require rails_helper` which will cause this
21
+ # file to always be loaded, without a need to explicitly require it in any files.
22
+ #
23
+ # Given that it is always loaded, you are encouraged to keep this file as
24
+ # light-weight as possible. Requiring heavyweight dependencies from this file
25
+ # will add to the boot time of your test suite on EVERY test run, even for an
26
+ # individual file that may not need all of that loaded. Instead, make a
27
+ # separate helper file that requires this one and then use it only in the specs
28
+ # that actually need it.
29
+ #
30
+ # The `.rspec` file also contains a few flags that are not defaults but that
31
+ # users commonly want.
32
+ #
33
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
34
+ RSpec.configure do |config|
35
+ # The settings below are suggested to provide a good initial experience
36
+ # with RSpec, but feel free to customize to your heart's content.
37
+
38
+ # These two settings work together to allow you to limit a spec run
39
+ # to individual examples or groups you care about by tagging them with
40
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
41
+ # get run.
42
+ config.filter_run :focus
43
+ config.run_all_when_everything_filtered = true
44
+
45
+ # Many RSpec users commonly either run the entire suite or an individual
46
+ # file, and it's useful to allow more verbose output when running an
47
+ # individual spec file.
48
+ if config.files_to_run.one?
49
+ # Use the documentation formatter for detailed output,
50
+ # unless a formatter has already been configured
51
+ # (e.g. via a command-line flag).
52
+ config.default_formatter = 'doc'
53
+ end
54
+
55
+ # Print the 10 slowest examples and example groups at the
56
+ # end of the spec run, to help surface which specs are running
57
+ # particularly slow.
58
+ config.profile_examples = 10
59
+
60
+ # Run specs in random order to surface order dependencies. If you find an
61
+ # order dependency and want to debug it, you can fix the order by providing
62
+ # the seed, which is printed after each run.
63
+ # --seed 1234
64
+ config.order = :random
65
+
66
+ # Seed global randomization in this process using the `--seed` CLI option.
67
+ # Setting this allows you to use `--seed` to deterministically reproduce
68
+ # test failures related to randomization by passing the same `--seed` value
69
+ # as the one that triggered the failure.
70
+ Kernel.srand config.seed
71
+
72
+ # rspec-expectations config goes here. You can use an alternate
73
+ # assertion/expectation library such as wrong or the stdlib/minitest
74
+ # assertions if you prefer.
75
+ config.expect_with :rspec do |expectations|
76
+ # Enable only the newer, non-monkey-patching expect syntax.
77
+ # For more details, see:
78
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
79
+ expectations.syntax = :expect
80
+ end
81
+
82
+ # rspec-mocks config goes here. You can use an alternate test double
83
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
84
+ config.mock_with :mocha
85
+ end