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.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/COPYING +621 -0
- data/COPYING.lesser +166 -0
- data/Gemfile +4 -0
- data/README.md +117 -0
- data/Rakefile +6 -0
- data/c_nifti.gemspec +31 -0
- data/ext/nifticlib/extconf.rb +30 -0
- data/ext/nifticlib/include/nifti_image.h +2 -0
- data/ext/nifticlib/include/nifti_image_converters.h +3 -0
- data/ext/nifticlib/include/nifti_image_dimensions.h +1 -0
- data/ext/nifticlib/include/nifti_image_intents.h +1 -0
- data/ext/nifticlib/include/nifti_image_metadata.h +1 -0
- data/ext/nifticlib/include/nifti_image_quaternions.h +1 -0
- data/ext/nifticlib/include/nifti_image_spacings.h +1 -0
- data/ext/nifticlib/include/nifti_image_timings.h +1 -0
- data/ext/nifticlib/include/nifti_image_transforms.h +1 -0
- data/ext/nifticlib/nifti_image.c +169 -0
- data/ext/nifticlib/nifti_image_converters.c +65 -0
- data/ext/nifticlib/nifti_image_dimensions.c +113 -0
- data/ext/nifticlib/nifti_image_intents.c +45 -0
- data/ext/nifticlib/nifti_image_metadata.c +133 -0
- data/ext/nifticlib/nifti_image_quaternions.c +59 -0
- data/ext/nifticlib/nifti_image_spacings.c +87 -0
- data/ext/nifticlib/nifti_image_timings.c +66 -0
- data/ext/nifticlib/nifti_image_transforms.c +38 -0
- data/ext/nifticlib/nifticlib-2.0.0/CMakeLists.txt +140 -0
- data/ext/nifticlib/nifticlib-2.0.0/CTestConfig.cmake +13 -0
- data/ext/nifticlib/nifticlib-2.0.0/LICENSE +9 -0
- data/ext/nifticlib/nifticlib-2.0.0/Makefile +265 -0
- data/ext/nifticlib/nifticlib-2.0.0/Makefile.cross_mingw32 +94 -0
- data/ext/nifticlib/nifticlib-2.0.0/README +79 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/CMakeLists.txt +7 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/Data/ATestReferenceImageForReadingAndWriting.nii.gz +0 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/Makefile +21 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/README_regress +50 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/@show.diffs +33 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/@test +80 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/CMakeLists.txt +47 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/bricks_test.sh +32 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/comment_test.sh +65 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dci_test.sh +46 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dsets_test.sh +61 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/dts_test.sh +75 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/fetch_data_test.sh +45 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/mod_header_test.sh +60 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/cmake_testscripts/newfiles_test.sh +36 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c01.versions +10 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c02.nt.help +5 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c03.hist +5 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c04.disp.anat0.info +7 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c05.mod.hdr +9 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c06.add.ext +22 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c07.cbl.4bricks +8 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c08.dts.19.36.11 +4 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c09.dts4.compare +9 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c10.dci.ts4 +15 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c10a.dci.run.210 +16 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c11.add.comment +8 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c12.check.comments +7 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c13.check.hdrs +5 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c14.make.dsets +21 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c15.new.files +21 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c16.rand.swap +35 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/nifti_regress_test/commands/c17.file.case +34 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/CMakeLists.txt +15 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/nifti_test.c +690 -0
- data/ext/nifticlib/nifticlib-2.0.0/Testing/niftilib/nifti_test2.c +32 -0
- data/ext/nifticlib/nifticlib-2.0.0/Updates.txt +110 -0
- data/ext/nifticlib/nifticlib-2.0.0/bin/.gitkeep +0 -0
- data/ext/nifticlib/nifticlib-2.0.0/docs/Doxy_nifti.txt +123 -0
- data/ext/nifticlib/nifticlib-2.0.0/docs/Doxyfile.ORIG +746 -0
- data/ext/nifticlib/nifticlib-2.0.0/examples/CMakeLists.txt +15 -0
- data/ext/nifticlib/nifticlib-2.0.0/examples/Makefile +48 -0
- data/ext/nifticlib/nifticlib-2.0.0/examples/clib_01_read_write.c +94 -0
- data/ext/nifticlib/nifticlib-2.0.0/examples/fsl_api_driver.c +142 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/CMakeLists.txt +32 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/Makefile +29 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/fslio.c +2426 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/fslio.tcl +83 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imcp +65 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imglob +59 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imln +37 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/immv +64 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imrm +29 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/imtest +53 -0
- data/ext/nifticlib/nifticlib-2.0.0/fsliolib/remove_ext +33 -0
- data/ext/nifticlib/nifticlib-2.0.0/include/.gitkeep +0 -0
- data/ext/nifticlib/nifticlib-2.0.0/nifticdf/CMakeLists.txt +28 -0
- data/ext/nifticlib/nifticlib-2.0.0/nifticdf/Makefile +28 -0
- data/ext/nifticlib/nifticlib-2.0.0/nifticdf/nifticdf.c +11107 -0
- data/ext/nifticlib/nifticlib-2.0.0/niftilib/CMakeLists.txt +33 -0
- data/ext/nifticlib/nifticlib-2.0.0/niftilib/Makefile +31 -0
- data/ext/nifticlib/nifticlib-2.0.0/niftilib/nifti1_io.c +7509 -0
- data/ext/nifticlib/nifticlib-2.0.0/packaging/DevPackage.template +18 -0
- data/ext/nifticlib/nifticlib-2.0.0/packaging/nifticlib.spec +62 -0
- data/ext/nifticlib/nifticlib-2.0.0/real_easy/nifti1_read_write.c +361 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/CMakeLists.txt +73 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/Makefile +55 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/nifti1_test.c +95 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_stats.c +95 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_tool.c +4193 -0
- data/ext/nifticlib/nifticlib-2.0.0/utils/nifti_tool.h +163 -0
- data/ext/nifticlib/nifticlib-2.0.0/znzlib/CMakeLists.txt +31 -0
- data/ext/nifticlib/nifticlib-2.0.0/znzlib/Makefile +33 -0
- data/ext/nifticlib/nifticlib-2.0.0/znzlib/znzlib.c +322 -0
- data/ext/nifticlib/nifticlib.c +107 -0
- data/ext/nifticlib/patches/nifticlib_fpic.patch +13 -0
- data/features/read_modify_write.feature +11 -0
- data/features/step_definitions/nifti_image_steps.rb +16 -0
- data/features/support/env.rb +14 -0
- data/features/support/fixtures/sample.nii.gz +0 -0
- data/lib/c_nifti.rb +9 -0
- data/lib/c_nifti/data.rb +70 -0
- data/lib/c_nifti/header.rb +16 -0
- data/lib/c_nifti/header_element.rb +13 -0
- data/lib/c_nifti/header_element/datatype.rb +49 -0
- data/lib/c_nifti/header_element/datatype/base.rb +9 -0
- data/lib/c_nifti/header_element/datatype/binary.rb +11 -0
- data/lib/c_nifti/header_element/datatype/double.rb +11 -0
- data/lib/c_nifti/header_element/datatype/float.rb +11 -0
- data/lib/c_nifti/header_element/datatype/long_double.rb +11 -0
- data/lib/c_nifti/header_element/datatype/long_long.rb +11 -0
- data/lib/c_nifti/header_element/datatype/signed_char.rb +11 -0
- data/lib/c_nifti/header_element/datatype/signed_int.rb +11 -0
- data/lib/c_nifti/header_element/datatype/signed_short.rb +11 -0
- data/lib/c_nifti/header_element/datatype/unsigned_char.rb +11 -0
- data/lib/c_nifti/header_element/datatype/unsigned_int.rb +11 -0
- data/lib/c_nifti/header_element/datatype/unsigned_long_long.rb +11 -0
- data/lib/c_nifti/header_element/datatype/unsigned_short.rb +11 -0
- data/lib/c_nifti/header_element/dimensions.rb +53 -0
- data/lib/c_nifti/header_element/intents.rb +25 -0
- data/lib/c_nifti/header_element/metadata.rb +49 -0
- data/lib/c_nifti/header_element/miscellaneous.rb +25 -0
- data/lib/c_nifti/header_element/quaternions.rb +33 -0
- data/lib/c_nifti/header_element/spacings.rb +45 -0
- data/lib/c_nifti/header_element/timings.rb +37 -0
- data/lib/c_nifti/header_element/transforms.rb +21 -0
- data/lib/c_nifti/image.rb +31 -0
- data/lib/c_nifti/version.rb +3 -0
- data/lib/nifticlib.rb +1 -0
- data/spec/data_spec.rb +112 -0
- data/spec/factories/nifti_images.rb +9 -0
- data/spec/header_element/datatype/base_spec.rb +9 -0
- data/spec/header_element/datatype/binary_spec.rb +9 -0
- data/spec/header_element/datatype/double_spec.rb +9 -0
- data/spec/header_element/datatype/float_spec.rb +9 -0
- data/spec/header_element/datatype/long_double_spec.rb +9 -0
- data/spec/header_element/datatype/long_long_spec.rb +9 -0
- data/spec/header_element/datatype/signed_char_spec.rb +9 -0
- data/spec/header_element/datatype/signed_int_spec.rb +9 -0
- data/spec/header_element/datatype/signed_short_spec.rb +9 -0
- data/spec/header_element/datatype/unsigned_char_spec.rb +9 -0
- data/spec/header_element/datatype/unsigned_int_spec.rb +9 -0
- data/spec/header_element/datatype/unsigned_long_long.rb +9 -0
- data/spec/header_element/datatype/unsigned_short_spec.rb +9 -0
- data/spec/header_element/datatype_spec.rb +109 -0
- data/spec/header_element/dimensions_spec.rb +105 -0
- data/spec/header_element/intents_spec.rb +48 -0
- data/spec/header_element/metadata_spec.rb +96 -0
- data/spec/header_element/miscellaneous_spec.rb +48 -0
- data/spec/header_element/quaternions_spec.rb +64 -0
- data/spec/header_element/spacings_spec.rb +88 -0
- data/spec/header_element/timings_spec.rb +72 -0
- data/spec/header_element/transforms_spec.rb +64 -0
- data/spec/image_spec.rb +39 -0
- data/spec/spec_helper.rb +85 -0
- metadata +363 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Dimensions
|
|
4
|
+
def ndim
|
|
5
|
+
@nifti_image.ndim
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def nvox
|
|
9
|
+
@nifti_image.nvox
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def nx
|
|
13
|
+
@nifti_image.nx
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def ny
|
|
17
|
+
@nifti_image.ny
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def nz
|
|
21
|
+
@nifti_image.nz
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def nt
|
|
25
|
+
@nifti_image.nt
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def nu
|
|
29
|
+
@nifti_image.nu
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def nv
|
|
33
|
+
@nifti_image.nv
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def nw
|
|
37
|
+
@nifti_image.nw
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def dim
|
|
41
|
+
@nifti_image.dim
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def nbyper
|
|
45
|
+
@nifti_image.nbyper
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def datatype
|
|
49
|
+
CNifti::HeaderElement::Datatype.to_datatype(@nifti_image.datatype)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Intents
|
|
4
|
+
def intent_code
|
|
5
|
+
@nifti_image.intent_code
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def intent_p1
|
|
9
|
+
@nifti_image.intent_p1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def intent_p2
|
|
13
|
+
@nifti_image.intent_p2
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def intent_p3
|
|
17
|
+
@nifti_image.intent_p3
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def intent_name
|
|
21
|
+
@nifti_image.intent_name
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Metadata
|
|
4
|
+
def description
|
|
5
|
+
@nifti_image.descrip
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def description=(value)
|
|
9
|
+
@nifti_image.descrip = value
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def aux_file
|
|
13
|
+
@nifti_image.aux_file
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def aux_file=(value)
|
|
17
|
+
@nifti_image.aux_file = value
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def file_name
|
|
21
|
+
@nifti_image.fname
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def file_name=(value)
|
|
25
|
+
@nifti_image.filenames = value # This actually sets iname and iname_offset as well
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def image_name
|
|
29
|
+
@nifti_image.iname
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def image_name_offset
|
|
33
|
+
@nifti_image.iname_offset
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def swapsize
|
|
37
|
+
@nifti_image.swapsize
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def byteorder
|
|
41
|
+
@nifti_image.byteorder
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def analyze75_orient
|
|
45
|
+
@nifti_image.analyze75_orient
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Miscellaneous
|
|
4
|
+
def scl_slope
|
|
5
|
+
@nifti_image.scl_slope
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def scl_inter
|
|
9
|
+
@nifti_image.scl_inter
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def cal_min
|
|
13
|
+
@nifti_image.cal_min
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def cal_max
|
|
17
|
+
@nifti_image.cal_max
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def type
|
|
21
|
+
@nifti_image.nifti_type
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Quaternions
|
|
4
|
+
def quatern_b
|
|
5
|
+
@nifti_image.quatern_b
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def quatern_c
|
|
9
|
+
@nifti_image.quatern_c
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def quatern_d
|
|
13
|
+
@nifti_image.quatern_d
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def qoffset_x
|
|
17
|
+
@nifti_image.qoffset_x
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def qoffset_y
|
|
21
|
+
@nifti_image.qoffset_y
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def qoffset_z
|
|
25
|
+
@nifti_image.qoffset_z
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def qfac
|
|
29
|
+
@nifti_image.qfac
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Spacings
|
|
4
|
+
def dx
|
|
5
|
+
@nifti_image.dx
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def dy
|
|
9
|
+
@nifti_image.dy
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def dz
|
|
13
|
+
@nifti_image.dz
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def dt
|
|
17
|
+
@nifti_image.dt
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def du
|
|
21
|
+
@nifti_image.du
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def dv
|
|
25
|
+
@nifti_image.dv
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def dw
|
|
29
|
+
@nifti_image.dw
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def pixel_dimensions
|
|
33
|
+
@nifti_image.pixdim
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def qform_code
|
|
37
|
+
@nifti_image.qform_code
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def sform_code
|
|
41
|
+
@nifti_image.sform_code
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Timings
|
|
4
|
+
def freq_dim
|
|
5
|
+
@nifti_image.freq_dim
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def phase_dim
|
|
9
|
+
@nifti_image.phase_dim
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def slice_dim
|
|
13
|
+
@nifti_image.slice_dim
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def slice_code
|
|
17
|
+
@nifti_image.slice_code
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def slice_start
|
|
21
|
+
@nifti_image.slice_start
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def slice_end
|
|
25
|
+
@nifti_image.slice_end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def slice_duration
|
|
29
|
+
@nifti_image.slice_duration
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def toffset
|
|
33
|
+
@nifti_image.toffset
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module CNifti
|
|
2
|
+
module HeaderElement
|
|
3
|
+
module Transforms
|
|
4
|
+
def qto_xyz
|
|
5
|
+
@nifti_image.qto_xyz
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def qto_ijk
|
|
9
|
+
@nifti_image.qto_ijk
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def sto_xyz
|
|
13
|
+
@nifti_image.sto_xyz
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def sto_ijk
|
|
17
|
+
@nifti_image.sto_ijk
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'nifticlib'
|
|
2
|
+
|
|
3
|
+
module CNifti
|
|
4
|
+
class Image
|
|
5
|
+
attr_reader :header, :data
|
|
6
|
+
|
|
7
|
+
def initialize(attributes={dimensions: [1, 1], datatype: HeaderElement::Datatype::SignedInt})
|
|
8
|
+
@nifti_image = NIfTICLib::NIfTIImage.new(([attributes[:dimensions].count] + attributes[:dimensions]), # The first element is the dimensions count which is concatenated to the actual dimensions
|
|
9
|
+
attributes[:datatype].to_i, # Integer datatype
|
|
10
|
+
1) # Always initialize the data
|
|
11
|
+
|
|
12
|
+
@header = Header.new(@nifti_image)
|
|
13
|
+
@data = Data.new(@nifti_image)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def open(path)
|
|
17
|
+
@nifti_image = NIfTICLib.read(path)
|
|
18
|
+
|
|
19
|
+
@header = Header.new(@nifti_image)
|
|
20
|
+
@data = Data.new(@nifti_image)
|
|
21
|
+
|
|
22
|
+
self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def save_as(path)
|
|
26
|
+
NIfTICLib.write(@nifti_image, path)
|
|
27
|
+
|
|
28
|
+
return true
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/nifticlib.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'nifticlib/nifticlib'
|
data/spec/data_spec.rb
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe CNifti::Data do
|
|
4
|
+
let!(:nifti_image) { FactoryGirl.build(:nifti_image) }
|
|
5
|
+
subject { CNifti::Data.new(nifti_image) }
|
|
6
|
+
|
|
7
|
+
describe 'raw' do
|
|
8
|
+
it 'is expected call the data method from NIfTICLib::NIfTIImage' do
|
|
9
|
+
nifti_image.expects(:data).returns([4])
|
|
10
|
+
|
|
11
|
+
expect(subject.raw).to eq([4])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'get_raw' do
|
|
16
|
+
it 'is expected call the get_data method from NIfTICLib::NIfTIImage' do
|
|
17
|
+
nifti_image.expects(:get_data).with(0).returns(4)
|
|
18
|
+
|
|
19
|
+
expect(subject.get_raw(0)).to eq(4)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'set_raw' do
|
|
24
|
+
it 'is expected call the set_data method from NIfTICLib::NIfTIImage' do
|
|
25
|
+
nifti_image.expects(:set_data).with(0, 4).returns(4)
|
|
26
|
+
|
|
27
|
+
expect(subject.set_raw(0,4)).to eq(4)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe 'shape' do
|
|
32
|
+
let!(:dim) { [2, 3, 3] }
|
|
33
|
+
|
|
34
|
+
before :each do
|
|
35
|
+
nifti_image.stubs(:dim).returns(dim)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'is expected call the set_data method from NIfTICLib::NIfTIImage' do
|
|
39
|
+
expect(subject.shape).to eq(dim[1..-1])
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '[]' do
|
|
44
|
+
let!(:shape) { [3, 3] }
|
|
45
|
+
|
|
46
|
+
before :each do
|
|
47
|
+
nifti_image.stubs(:shape).returns(shape)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'with an index over bounds' do
|
|
51
|
+
let(:index) {3}
|
|
52
|
+
|
|
53
|
+
it 'is expected to raise a IndexError' do
|
|
54
|
+
expect{ subject[index] }.to raise_error(IndexError)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'with valid index' do
|
|
59
|
+
context 'with the last dimension' do
|
|
60
|
+
context 'with a Range' do
|
|
61
|
+
let(:index) { 0..1 }
|
|
62
|
+
|
|
63
|
+
it 'is expected to return a array' do
|
|
64
|
+
expect(subject[0][index]).to be_a(Array)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context 'with a Fixnum' do
|
|
69
|
+
let(:index) {2}
|
|
70
|
+
|
|
71
|
+
it 'is expected to return a Value' do
|
|
72
|
+
expect(subject[0][index]).to eq(0)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context 'with a intermediary dimension' do
|
|
78
|
+
let(:index) {2}
|
|
79
|
+
|
|
80
|
+
it 'is expected to return a Data instance' do
|
|
81
|
+
expect(subject[index]).to be_a(CNifti::Data)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe '[]=' do
|
|
88
|
+
let!(:shape) { [3, 3] }
|
|
89
|
+
|
|
90
|
+
before :each do
|
|
91
|
+
nifti_image.stubs(:shape).returns(shape)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context 'with the last dimension' do
|
|
95
|
+
context 'with a Fixnum' do
|
|
96
|
+
let(:index) {2}
|
|
97
|
+
|
|
98
|
+
it 'is expected to return a Value' do
|
|
99
|
+
expect(subject[0][index] = 2).to eq(2)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context 'with a intermediary dimension' do
|
|
105
|
+
let(:index) {2}
|
|
106
|
+
|
|
107
|
+
it 'is expected to raise a IndexError' do
|
|
108
|
+
expect{ subject[index] = 2 }.to raise_error(IndexError)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|