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
data/COPYING.lesser
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# CNifti
|
|
2
|
+
|
|
3
|
+
Currently under development and not realeased yet! But should be ready for reading NIfTI image and header
|
|
4
|
+
|
|
5
|
+
CNifti is a wrapper for the standard C NIfTI 1 library found at http://afni.nimh.nih.gov/pub/dist/src/nifti/
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile (not working before release):
|
|
10
|
+
|
|
11
|
+
gem 'c_nifti'
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as (not working before release):
|
|
18
|
+
|
|
19
|
+
$ gem install c_nifti
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
image_path = "image.nii.gz"
|
|
24
|
+
img = CNifti::Image.open(image_path)
|
|
25
|
+
|
|
26
|
+
img.header.ndim
|
|
27
|
+
img.header.nx
|
|
28
|
+
img.header.ny
|
|
29
|
+
img.header.nz
|
|
30
|
+
img.header.nt
|
|
31
|
+
img.header.nu
|
|
32
|
+
img.header.nv
|
|
33
|
+
img.header.nw
|
|
34
|
+
img.header.dim
|
|
35
|
+
img.header.nvox
|
|
36
|
+
img.header.nbyper
|
|
37
|
+
img.header.datatype
|
|
38
|
+
img.header.dx
|
|
39
|
+
img.header.dy
|
|
40
|
+
img.header.dz
|
|
41
|
+
img.header.dt
|
|
42
|
+
img.header.du
|
|
43
|
+
img.header.dv
|
|
44
|
+
img.header.dw
|
|
45
|
+
img.header.pixdim
|
|
46
|
+
img.header.scl_slope
|
|
47
|
+
img.header.scl_inter
|
|
48
|
+
img.header.cal_min
|
|
49
|
+
img.header.cal_max
|
|
50
|
+
img.header.qform_code
|
|
51
|
+
img.header.sform_code
|
|
52
|
+
img.header.freq_dim
|
|
53
|
+
img.header.phase_dim
|
|
54
|
+
img.header.slice_dim
|
|
55
|
+
img.header.slice_code
|
|
56
|
+
img.header.slice_start
|
|
57
|
+
img.header.slice_end
|
|
58
|
+
img.header.slice_duration
|
|
59
|
+
img.header.quatern_b
|
|
60
|
+
img.header.quatern_c
|
|
61
|
+
img.header.quatern_d
|
|
62
|
+
img.header.qoffset_x
|
|
63
|
+
img.header.qoffset_y
|
|
64
|
+
img.header.qoffset_z
|
|
65
|
+
img.header.qfac
|
|
66
|
+
img.header.qto_xyz
|
|
67
|
+
img.header.qto_ijk
|
|
68
|
+
img.header.sto_xyz
|
|
69
|
+
img.header.sto_ijk
|
|
70
|
+
img.header.toffset
|
|
71
|
+
img.header.xyz_units
|
|
72
|
+
img.header.time_units
|
|
73
|
+
img.header.nifti_type
|
|
74
|
+
img.header.intent_code
|
|
75
|
+
img.header.intent_p1
|
|
76
|
+
img.header.intent_p2
|
|
77
|
+
img.header.intent_p3
|
|
78
|
+
img.header.intent_name
|
|
79
|
+
img.header.descrip
|
|
80
|
+
img.header.aux_file
|
|
81
|
+
img.header.file_name
|
|
82
|
+
img.header.image_name
|
|
83
|
+
img.header.image_name_offset
|
|
84
|
+
img.header.swapsize
|
|
85
|
+
img.header.byteorder
|
|
86
|
+
img.header.analyze75_orient
|
|
87
|
+
|
|
88
|
+
img.header.description = "description"
|
|
89
|
+
img.header.aux_file = "aux_file"
|
|
90
|
+
img.header.file_name = "new_image.nii.gz" # resets the fname, iname and iname_offset of NIfTI
|
|
91
|
+
|
|
92
|
+
img.data.raw # returns the data into a unidimensional array
|
|
93
|
+
img.data.get_raw(0) # returns the data at index 0 from the unidimensional array
|
|
94
|
+
img.data.set_raw(0,1) # sets the data at index 0 from the unidimensional array to 1
|
|
95
|
+
img.data.shape # like img.header.dim but without the first element
|
|
96
|
+
img.data[0][0][0] # Supposing the data has 3 dimensions, returns its value
|
|
97
|
+
img.data[0][0][0] = 1 # Supposing the data has 3 dimensions, sets its value at position (0,0,0) to 1
|
|
98
|
+
|
|
99
|
+
img.save_as("out_#{image_path})
|
|
100
|
+
|
|
101
|
+
### Not supported data types
|
|
102
|
+
* DT_COMPLEX
|
|
103
|
+
* DT_RGB
|
|
104
|
+
* DT_ALL
|
|
105
|
+
* DT_COMPLEX128
|
|
106
|
+
* DT_COMPLEX256
|
|
107
|
+
* DT_RGBA32
|
|
108
|
+
|
|
109
|
+
### NIfTI extensions are not supported
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
1. Fork it ( https://github.com/rafamanzo/c_nifti/fork )
|
|
114
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
115
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
116
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
117
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/c_nifti.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'c_nifti/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "c_nifti"
|
|
8
|
+
spec.version = CNifti::VERSION
|
|
9
|
+
spec.authors = ["Rafael Reggiani Manzo"]
|
|
10
|
+
spec.email = ["rr.manzo@gmail.com"]
|
|
11
|
+
spec.summary = "NIfTI 1 and ANALYZE 7.5 medical image formats IO"
|
|
12
|
+
spec.description = "CNifti is a wrapper for the standard C NIfTI 1 library found at http://afni.nimh.nih.gov/pub/dist/src/nifti/"
|
|
13
|
+
spec.homepage = "https://github.com/rafamanzo/c_nifti"
|
|
14
|
+
spec.license = "LGPLv3"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.extensions = %w[ext/nifticlib/extconf.rb]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
24
|
+
spec.add_development_dependency "rake"
|
|
25
|
+
spec.add_development_dependency "rake-compiler"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
|
27
|
+
spec.add_development_dependency "mocha", "~> 1.1.0"
|
|
28
|
+
spec.add_development_dependency "simplecov"
|
|
29
|
+
spec.add_development_dependency "factory_girl", "~> 4.4.0"
|
|
30
|
+
spec.add_development_dependency "cucumber", "~> 1.3.16"
|
|
31
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'mkmf'
|
|
2
|
+
|
|
3
|
+
find_executable('make')
|
|
4
|
+
find_executable('csh')
|
|
5
|
+
|
|
6
|
+
puts "Compiling standard C NIfTI library..."
|
|
7
|
+
Dir.chdir("#{File.dirname(__FILE__)}/nifticlib-2.0.0") do
|
|
8
|
+
`patch -p0 < ../patches/nifticlib_fpic.patch`
|
|
9
|
+
`make all`
|
|
10
|
+
end
|
|
11
|
+
puts "Compiling standard C NIfTI library... Compiled!"
|
|
12
|
+
|
|
13
|
+
find_library('niftiio', nil, "#{File.dirname(__FILE__)}/nifticlib-2.0.0/lib")
|
|
14
|
+
find_library('znz', nil, "#{File.dirname(__FILE__)}/nifticlib-2.0.0/lib")
|
|
15
|
+
have_library('m')
|
|
16
|
+
have_library('z')
|
|
17
|
+
find_header('nifti1_io.h', "#{File.dirname(__FILE__)}/nifticlib-2.0.0/include")
|
|
18
|
+
find_header('nifti_image.h', "#{File.dirname(__FILE__)}/include")
|
|
19
|
+
find_header('nifti_image_converters.h', "#{File.dirname(__FILE__)}/include")
|
|
20
|
+
find_header('nifti_image_dimensions.h', "#{File.dirname(__FILE__)}/include")
|
|
21
|
+
find_header('nifti_image_spacings.h', "#{File.dirname(__FILE__)}/include")
|
|
22
|
+
find_header('nifti_image_timings.h', "#{File.dirname(__FILE__)}/include")
|
|
23
|
+
find_header('nifti_image_quaternions.h', "#{File.dirname(__FILE__)}/include")
|
|
24
|
+
find_header('nifti_image_transforms.h', "#{File.dirname(__FILE__)}/include")
|
|
25
|
+
find_header('nifti_image_intents.h', "#{File.dirname(__FILE__)}/include")
|
|
26
|
+
find_header('nifti_image_metadata.h', "#{File.dirname(__FILE__)}/include")
|
|
27
|
+
|
|
28
|
+
$LIBS << " -lznz" # For some reason znz is not linked without this
|
|
29
|
+
|
|
30
|
+
create_makefile 'nifticlib/nifticlib'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_dimensions_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_intents_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_metadata_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_quaternions_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_spacings_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_timings_init(VALUE klass);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VALUE nifti_image_transforms_init(VALUE klass);
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
#include <stdbool.h> // Boolean type handling
|
|
4
|
+
|
|
5
|
+
#include <nifti_image.h>
|
|
6
|
+
#include <nifti_image_converters.h>
|
|
7
|
+
#include <nifti_image_dimensions.h>
|
|
8
|
+
#include <nifti_image_spacings.h>
|
|
9
|
+
#include <nifti_image_timings.h>
|
|
10
|
+
#include <nifti_image_quaternions.h>
|
|
11
|
+
#include <nifti_image_transforms.h>
|
|
12
|
+
#include <nifti_image_intents.h>
|
|
13
|
+
#include <nifti_image_metadata.h>
|
|
14
|
+
|
|
15
|
+
/***********/
|
|
16
|
+
/* Scaling */
|
|
17
|
+
/***********/
|
|
18
|
+
|
|
19
|
+
VALUE nifti_image_scl_slope(VALUE self){
|
|
20
|
+
nifti_image *img = to_nifti_image(self);
|
|
21
|
+
|
|
22
|
+
return rb_float_new((double) img->scl_slope);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
VALUE nifti_image_scl_inter(VALUE self){
|
|
26
|
+
nifti_image *img = to_nifti_image(self);
|
|
27
|
+
|
|
28
|
+
return rb_float_new((double) img->scl_inter);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/***************/
|
|
32
|
+
/* Calibration */
|
|
33
|
+
/***************/
|
|
34
|
+
|
|
35
|
+
VALUE nifti_image_cal_min(VALUE self){
|
|
36
|
+
nifti_image *img = to_nifti_image(self);
|
|
37
|
+
|
|
38
|
+
return rb_float_new((double) img->cal_min);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
VALUE nifti_image_cal_max(VALUE self){
|
|
42
|
+
nifti_image *img = to_nifti_image(self);
|
|
43
|
+
|
|
44
|
+
return rb_float_new((double) img->cal_max);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/********/
|
|
48
|
+
/* Data */
|
|
49
|
+
/********/
|
|
50
|
+
|
|
51
|
+
VALUE nifti_image_data(VALUE self){
|
|
52
|
+
int i = 0;
|
|
53
|
+
nifti_image *img = to_nifti_image(self);
|
|
54
|
+
|
|
55
|
+
VALUE rb_data = rb_ary_new2(img->nvox);
|
|
56
|
+
|
|
57
|
+
for(i = 0; i < ((int) img->nvox); i++){
|
|
58
|
+
rb_ary_store(rb_data, i, voxel_data_to_value(img, i));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return rb_data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
VALUE nifti_image_set_data(VALUE self, VALUE r_index, VALUE r_value){
|
|
65
|
+
char *str_value;
|
|
66
|
+
nifti_image *img = to_nifti_image(self);
|
|
67
|
+
int index = NUM2INT(r_index);
|
|
68
|
+
|
|
69
|
+
// Types nifti1.h
|
|
70
|
+
switch(img->datatype){
|
|
71
|
+
case DT_BINARY: // DT_UINT8
|
|
72
|
+
if (r_value == Qtrue){
|
|
73
|
+
((bool *) img->data)[index] = true;
|
|
74
|
+
}else{
|
|
75
|
+
((bool *) img->data)[index] = false;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case DT_UNSIGNED_CHAR:
|
|
79
|
+
Check_Type(r_value, T_STRING);
|
|
80
|
+
StringValue(r_value);
|
|
81
|
+
str_value = StringValuePtr(r_value);
|
|
82
|
+
|
|
83
|
+
((unsigned char *) img->data)[index] = ((unsigned char) str_value[0]);
|
|
84
|
+
break;
|
|
85
|
+
case DT_SIGNED_SHORT: // DT_INT16
|
|
86
|
+
((short *) img->data)[index] = ((short) NUM2INT(r_value));
|
|
87
|
+
break;
|
|
88
|
+
case DT_SIGNED_INT: // DT_INT32
|
|
89
|
+
((int *) img->data)[index] = NUM2INT(r_value);
|
|
90
|
+
break;
|
|
91
|
+
case DT_FLOAT: // DT_FLOAT32
|
|
92
|
+
((float *) img->data)[index] = ((float) NUM2DBL(r_value));
|
|
93
|
+
break;
|
|
94
|
+
case DT_DOUBLE: // DT_FLOAT64
|
|
95
|
+
((double *) img->data)[index] = NUM2DBL(r_value);
|
|
96
|
+
break;
|
|
97
|
+
case DT_INT8:
|
|
98
|
+
Check_Type(r_value, T_STRING);
|
|
99
|
+
StringValue(r_value);
|
|
100
|
+
str_value = StringValuePtr(r_value);
|
|
101
|
+
|
|
102
|
+
((char *) img->data)[index] = ((char) str_value[0]);
|
|
103
|
+
break;
|
|
104
|
+
case DT_UINT16:
|
|
105
|
+
((unsigned short *) img->data)[index] = ((unsigned short) NUM2INT(r_value));
|
|
106
|
+
break;
|
|
107
|
+
case DT_UINT32:
|
|
108
|
+
((unsigned int *) img->data)[index] = ((unsigned int) NUM2INT(r_value));
|
|
109
|
+
break;
|
|
110
|
+
case DT_INT64:
|
|
111
|
+
((long long *) img->data)[index] = ((long long) NUM2LONG(r_value));
|
|
112
|
+
break;
|
|
113
|
+
case DT_UINT64:
|
|
114
|
+
((unsigned long long *) img->data)[index] = ((unsigned long long) NUM2LONG(r_value));
|
|
115
|
+
break;
|
|
116
|
+
case DT_FLOAT128:
|
|
117
|
+
((long double *) img->data)[index] = ((long double) NUM2DBL(r_value));
|
|
118
|
+
break;
|
|
119
|
+
default: // Unsupported types: DT_COMPLEX, DT_RGB, DT_ALL, DT_COMPLEX128, DT_COMPLEX256, DT_RGBA32
|
|
120
|
+
rb_raise(rb_eTypeError, "Unsupported datatype");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return r_value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
VALUE nifti_image_get_data(VALUE self, VALUE r_index){
|
|
127
|
+
nifti_image *img = to_nifti_image(self);
|
|
128
|
+
|
|
129
|
+
return voxel_data_to_value(img, NUM2INT(r_index));
|
|
130
|
+
}
|
|
131
|
+
/********/
|
|
132
|
+
/* Type */
|
|
133
|
+
/********/
|
|
134
|
+
|
|
135
|
+
VALUE nifti_image_nifti_type(VALUE self){
|
|
136
|
+
nifti_image *img = to_nifti_image(self);
|
|
137
|
+
|
|
138
|
+
return INT2NUM(img->nifti_type);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/********/
|
|
142
|
+
/* Init */
|
|
143
|
+
/********/
|
|
144
|
+
|
|
145
|
+
VALUE init_nifti_image(VALUE module){
|
|
146
|
+
VALUE cNIfTIImage = rb_define_class_under(module, "NIfTIImage", rb_cObject);
|
|
147
|
+
|
|
148
|
+
cNIfTIImage = nifti_image_dimensions_init(cNIfTIImage);
|
|
149
|
+
cNIfTIImage = nifti_image_spacings_init(cNIfTIImage);
|
|
150
|
+
// Scaling methods
|
|
151
|
+
rb_define_method(cNIfTIImage, "scl_slope", nifti_image_scl_slope, 0);
|
|
152
|
+
rb_define_method(cNIfTIImage, "scl_inter", nifti_image_scl_inter, 0);
|
|
153
|
+
// Calibration methods
|
|
154
|
+
rb_define_method(cNIfTIImage, "cal_min", nifti_image_cal_min, 0);
|
|
155
|
+
rb_define_method(cNIfTIImage, "cal_max", nifti_image_cal_max, 0);
|
|
156
|
+
cNIfTIImage = nifti_image_timings_init(cNIfTIImage);
|
|
157
|
+
cNIfTIImage = nifti_image_quaternions_init(cNIfTIImage);
|
|
158
|
+
cNIfTIImage = nifti_image_transforms_init(cNIfTIImage);
|
|
159
|
+
// Data methods
|
|
160
|
+
rb_define_method(cNIfTIImage, "data", nifti_image_data, 0);
|
|
161
|
+
rb_define_method(cNIfTIImage, "set_data", nifti_image_set_data, 2);
|
|
162
|
+
rb_define_method(cNIfTIImage, "get_data", nifti_image_get_data, 1);
|
|
163
|
+
// Type methods
|
|
164
|
+
rb_define_method(cNIfTIImage, "nifti_type", nifti_image_nifti_type, 0);
|
|
165
|
+
cNIfTIImage = nifti_image_intents_init(cNIfTIImage);
|
|
166
|
+
cNIfTIImage = nifti_image_metadata_init(cNIfTIImage);
|
|
167
|
+
|
|
168
|
+
return cNIfTIImage;
|
|
169
|
+
}
|