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,65 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
#include <stdbool.h> // Boolean type handling
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
|
|
6
|
+
nifti_image * to_nifti_image(VALUE rb_nifti_image){
|
|
7
|
+
nifti_image *img = NULL;
|
|
8
|
+
|
|
9
|
+
Data_Get_Struct(rb_nifti_image, nifti_image, img);
|
|
10
|
+
|
|
11
|
+
return img;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
VALUE voxel_data_to_value(nifti_image *img, int index){
|
|
15
|
+
// Types nifti1.h
|
|
16
|
+
switch(img->datatype){
|
|
17
|
+
case DT_BINARY: // DT_UINT8
|
|
18
|
+
if (((bool *) img->data)[index]){
|
|
19
|
+
return Qtrue;
|
|
20
|
+
}else{
|
|
21
|
+
return Qfalse;
|
|
22
|
+
}
|
|
23
|
+
case DT_UNSIGNED_CHAR:
|
|
24
|
+
return rb_sprintf("%u", ((unsigned char *) img->data)[index]);
|
|
25
|
+
case DT_SIGNED_SHORT: // DT_INT16
|
|
26
|
+
return INT2NUM((int) ((short *) img->data)[index]);
|
|
27
|
+
case DT_SIGNED_INT: // DT_INT32
|
|
28
|
+
return INT2NUM(((int *) img->data)[index]);
|
|
29
|
+
case DT_FLOAT: // DT_FLOAT32
|
|
30
|
+
return rb_float_new((double) ((float *) img->data)[index]);
|
|
31
|
+
case DT_DOUBLE: // DT_FLOAT64
|
|
32
|
+
return rb_float_new(((double *) img->data)[index]);
|
|
33
|
+
case DT_INT8:
|
|
34
|
+
return rb_sprintf("%c", ((char *) img->data)[index]);
|
|
35
|
+
case DT_UINT16:
|
|
36
|
+
return INT2NUM((int) ((unsigned short *) img->data)[index]);
|
|
37
|
+
case DT_UINT32:
|
|
38
|
+
return INT2NUM((int) ((unsigned int *) img->data)[index]);
|
|
39
|
+
case DT_INT64:
|
|
40
|
+
return INT2NUM((int) ((long long *) img->data)[index]);
|
|
41
|
+
case DT_UINT64:
|
|
42
|
+
return INT2NUM((int) ((unsigned long long *) img->data)[index]);
|
|
43
|
+
case DT_FLOAT128:
|
|
44
|
+
return rb_float_new(((double) ((long double *) img->data)[index]));
|
|
45
|
+
default: // Unsupported types: DT_COMPLEX, DT_RGB, DT_ALL, DT_COMPLEX128, DT_COMPLEX256, DT_RGBA32
|
|
46
|
+
return Qnil;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
VALUE mat44_to_rb_array(mat44 matrix){
|
|
51
|
+
VALUE rb_data = rb_ary_new2(4);
|
|
52
|
+
int x, y;
|
|
53
|
+
|
|
54
|
+
for(x = 0; x < 4; x++){
|
|
55
|
+
VALUE line = rb_ary_new2(4);
|
|
56
|
+
|
|
57
|
+
for(y = 0; y < 4; y++){
|
|
58
|
+
rb_ary_store(line, y, rb_float_new((double) matrix.m[x][y]));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
rb_ary_store(rb_data, x, line);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return rb_data;
|
|
65
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
#include <nifti_image_dimensions.h>
|
|
6
|
+
|
|
7
|
+
VALUE nifti_image_ndim(VALUE self){
|
|
8
|
+
nifti_image *img = to_nifti_image(self);
|
|
9
|
+
|
|
10
|
+
return INT2NUM(img->ndim);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE nifti_image_nvox(VALUE self){
|
|
14
|
+
return INT2NUM(to_nifti_image(self)->nvox);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
VALUE nifti_image_nx(VALUE self){
|
|
18
|
+
nifti_image *img = to_nifti_image(self);
|
|
19
|
+
|
|
20
|
+
return INT2NUM(img->nx);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
VALUE nifti_image_ny(VALUE self){
|
|
24
|
+
nifti_image *img = to_nifti_image(self);
|
|
25
|
+
|
|
26
|
+
return INT2NUM(img->ny);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
VALUE nifti_image_nz(VALUE self){
|
|
30
|
+
nifti_image *img = to_nifti_image(self);
|
|
31
|
+
|
|
32
|
+
return INT2NUM(img->nz);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
VALUE nifti_image_nt(VALUE self){
|
|
36
|
+
nifti_image *img = to_nifti_image(self);
|
|
37
|
+
|
|
38
|
+
return INT2NUM(img->nt);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
VALUE nifti_image_nu(VALUE self){
|
|
42
|
+
nifti_image *img = to_nifti_image(self);
|
|
43
|
+
|
|
44
|
+
return INT2NUM(img->nu);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
VALUE nifti_image_nv(VALUE self){
|
|
48
|
+
nifti_image *img = to_nifti_image(self);
|
|
49
|
+
|
|
50
|
+
return INT2NUM(img->nv);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
VALUE nifti_image_nw(VALUE self){
|
|
54
|
+
nifti_image *img = to_nifti_image(self);
|
|
55
|
+
|
|
56
|
+
return INT2NUM(img->nw);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
VALUE nifti_image_dim(VALUE self){
|
|
60
|
+
int i = 0;
|
|
61
|
+
nifti_image *img = to_nifti_image(self);
|
|
62
|
+
|
|
63
|
+
VALUE rb_data = rb_ary_new2(img->nvox);
|
|
64
|
+
|
|
65
|
+
for(i = 0; i < 8; i++){
|
|
66
|
+
rb_ary_store(rb_data, i, INT2NUM(img->dim[i]));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return rb_data;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
VALUE nifti_image_nbyper(VALUE self){
|
|
73
|
+
nifti_image *img = to_nifti_image(self);
|
|
74
|
+
|
|
75
|
+
return INT2NUM(img->nbyper);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
VALUE nifti_image_datatype(VALUE self){
|
|
79
|
+
nifti_image *img = to_nifti_image(self);
|
|
80
|
+
|
|
81
|
+
return INT2NUM(img->datatype);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
VALUE nifti_image_xyz_units(VALUE self){
|
|
85
|
+
nifti_image *img = to_nifti_image(self);
|
|
86
|
+
|
|
87
|
+
return INT2NUM(img->xyz_units);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
VALUE nifti_image_time_units(VALUE self){
|
|
91
|
+
nifti_image *img = to_nifti_image(self);
|
|
92
|
+
|
|
93
|
+
return INT2NUM(img->time_units);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
VALUE nifti_image_dimensions_init(VALUE klass){
|
|
97
|
+
rb_define_method(klass, "ndim", nifti_image_ndim, 0);
|
|
98
|
+
rb_define_method(klass, "nx", nifti_image_nx, 0);
|
|
99
|
+
rb_define_method(klass, "ny", nifti_image_ny, 0);
|
|
100
|
+
rb_define_method(klass, "nz", nifti_image_nz, 0);
|
|
101
|
+
rb_define_method(klass, "nt", nifti_image_nt, 0);
|
|
102
|
+
rb_define_method(klass, "nu", nifti_image_nu, 0);
|
|
103
|
+
rb_define_method(klass, "nv", nifti_image_nv, 0);
|
|
104
|
+
rb_define_method(klass, "nw", nifti_image_nw, 0);
|
|
105
|
+
rb_define_method(klass, "dim", nifti_image_dim, 0);
|
|
106
|
+
rb_define_method(klass, "nvox", nifti_image_nvox, 0);
|
|
107
|
+
rb_define_method(klass, "nbyper", nifti_image_nbyper, 0);
|
|
108
|
+
rb_define_method(klass, "datatype", nifti_image_datatype, 0);
|
|
109
|
+
rb_define_method(klass, "xyz_units", nifti_image_xyz_units, 0);
|
|
110
|
+
rb_define_method(klass, "time_units", nifti_image_time_units, 0);
|
|
111
|
+
|
|
112
|
+
return klass;
|
|
113
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
#include <nifti_image_intents.h>
|
|
6
|
+
|
|
7
|
+
VALUE nifti_image_intent_code(VALUE self){
|
|
8
|
+
nifti_image *img = to_nifti_image(self);
|
|
9
|
+
|
|
10
|
+
return INT2NUM(img->intent_code);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE nifti_image_intent_p1(VALUE self){
|
|
14
|
+
nifti_image *img = to_nifti_image(self);
|
|
15
|
+
|
|
16
|
+
return rb_float_new((double) img->intent_p1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
VALUE nifti_image_intent_p2(VALUE self){
|
|
20
|
+
nifti_image *img = to_nifti_image(self);
|
|
21
|
+
|
|
22
|
+
return rb_float_new((double) img->intent_p2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
VALUE nifti_image_intent_p3(VALUE self){
|
|
26
|
+
nifti_image *img = to_nifti_image(self);
|
|
27
|
+
|
|
28
|
+
return rb_float_new((double) img->intent_p3);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALUE nifti_image_intent_name(VALUE self){
|
|
32
|
+
nifti_image *img = to_nifti_image(self);
|
|
33
|
+
|
|
34
|
+
return rb_str_new2(img->intent_name);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
VALUE nifti_image_intents_init(VALUE klass){
|
|
38
|
+
rb_define_method(klass, "intent_code", nifti_image_intent_code, 0);
|
|
39
|
+
rb_define_method(klass, "intent_p1", nifti_image_intent_p1, 0);
|
|
40
|
+
rb_define_method(klass, "intent_p2", nifti_image_intent_p2, 0);
|
|
41
|
+
rb_define_method(klass, "intent_p3", nifti_image_intent_p3, 0);
|
|
42
|
+
rb_define_method(klass, "intent_name", nifti_image_intent_name, 0);
|
|
43
|
+
|
|
44
|
+
return klass;
|
|
45
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
#include <nifti_image_intents.h>
|
|
6
|
+
|
|
7
|
+
#define MAX(a,b) (((a)>(b))?(a):(b))
|
|
8
|
+
|
|
9
|
+
/***********/
|
|
10
|
+
/* Getters */
|
|
11
|
+
/***********/
|
|
12
|
+
|
|
13
|
+
VALUE nifti_image_descrip(VALUE self){
|
|
14
|
+
nifti_image *img = to_nifti_image(self);
|
|
15
|
+
|
|
16
|
+
return rb_str_new2(img->descrip);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
VALUE nifti_image_aux_file(VALUE self){
|
|
20
|
+
nifti_image *img = to_nifti_image(self);
|
|
21
|
+
|
|
22
|
+
return rb_str_new2(img->aux_file);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
VALUE nifti_image_fname(VALUE self){
|
|
26
|
+
nifti_image *img = to_nifti_image(self);
|
|
27
|
+
|
|
28
|
+
if(img->fname){
|
|
29
|
+
return rb_str_new2(img->fname);
|
|
30
|
+
}else{
|
|
31
|
+
return Qnil;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
VALUE nifti_image_iname(VALUE self){
|
|
36
|
+
nifti_image *img = to_nifti_image(self);
|
|
37
|
+
|
|
38
|
+
return rb_str_new2(img->iname);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
VALUE nifti_image_iname_offset(VALUE self){
|
|
42
|
+
nifti_image *img = to_nifti_image(self);
|
|
43
|
+
|
|
44
|
+
return INT2NUM(img->iname_offset);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
VALUE nifti_image_swapsize(VALUE self){
|
|
48
|
+
nifti_image *img = to_nifti_image(self);
|
|
49
|
+
|
|
50
|
+
return INT2NUM(img->swapsize);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
VALUE nifti_image_byteorder(VALUE self){
|
|
54
|
+
nifti_image *img = to_nifti_image(self);
|
|
55
|
+
|
|
56
|
+
return INT2NUM(img->byteorder);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
VALUE nifti_image_analyze75_orient(VALUE self){
|
|
60
|
+
nifti_image *img = to_nifti_image(self);
|
|
61
|
+
|
|
62
|
+
return INT2NUM((int) img->analyze75_orient);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/***********/
|
|
66
|
+
/* Setters */
|
|
67
|
+
/***********/
|
|
68
|
+
|
|
69
|
+
VALUE nifti_image_set_descrip(VALUE self, VALUE r_value){
|
|
70
|
+
nifti_image *img = to_nifti_image(self);
|
|
71
|
+
char *value;
|
|
72
|
+
int i = 0;
|
|
73
|
+
|
|
74
|
+
StringValue(r_value);
|
|
75
|
+
value = StringValuePtr(r_value);
|
|
76
|
+
|
|
77
|
+
for(i = 0; i < MAX(80, RSTRING_LEN(r_value)); i++){
|
|
78
|
+
img->descrip[i] = value[i];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return nifti_image_descrip(self);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
VALUE nifti_image_set_aux_file(VALUE self, VALUE r_value){
|
|
85
|
+
nifti_image *img = to_nifti_image(self);
|
|
86
|
+
char *value;
|
|
87
|
+
int i = 0;
|
|
88
|
+
|
|
89
|
+
StringValue(r_value);
|
|
90
|
+
value = StringValuePtr(r_value);
|
|
91
|
+
|
|
92
|
+
for(i = 0; i < MAX(24, RSTRING_LEN(r_value)); i++){
|
|
93
|
+
img->aux_file[i] = value[i];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return nifti_image_aux_file(self);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
VALUE nifti_image_set_filenames(VALUE self, VALUE r_value){
|
|
100
|
+
nifti_image *img = to_nifti_image(self);
|
|
101
|
+
char *value;
|
|
102
|
+
|
|
103
|
+
StringValue(r_value);
|
|
104
|
+
value = StringValuePtr(r_value);
|
|
105
|
+
|
|
106
|
+
nifti_set_filenames(img, value, 1, 1);
|
|
107
|
+
|
|
108
|
+
return r_value;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/********/
|
|
112
|
+
/* Init */
|
|
113
|
+
/********/
|
|
114
|
+
|
|
115
|
+
VALUE nifti_image_metadata_init(VALUE klass){
|
|
116
|
+
// Getters
|
|
117
|
+
rb_define_method(klass, "descrip", nifti_image_descrip, 0);
|
|
118
|
+
rb_define_method(klass, "aux_file", nifti_image_aux_file, 0);
|
|
119
|
+
rb_define_method(klass, "fname", nifti_image_fname, 0);
|
|
120
|
+
rb_define_method(klass, "iname", nifti_image_iname, 0);
|
|
121
|
+
rb_define_method(klass, "iname_offset", nifti_image_iname_offset, 0);
|
|
122
|
+
rb_define_method(klass, "swapsize", nifti_image_swapsize, 0);
|
|
123
|
+
rb_define_method(klass, "byteorder", nifti_image_byteorder, 0);
|
|
124
|
+
rb_define_method(klass, "analyze75_orient", nifti_image_analyze75_orient, 0);
|
|
125
|
+
|
|
126
|
+
// Setters
|
|
127
|
+
// byteorder and swapsize cannot be setted
|
|
128
|
+
rb_define_method(klass, "descrip=", nifti_image_set_descrip, 1);
|
|
129
|
+
rb_define_method(klass, "aux_file=", nifti_image_set_aux_file, 1);
|
|
130
|
+
rb_define_method(klass, "filenames=", nifti_image_set_filenames, 1);
|
|
131
|
+
|
|
132
|
+
return klass;
|
|
133
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
#include <nifti_image_quaternions.h>
|
|
6
|
+
|
|
7
|
+
VALUE nifti_image_quatern_b(VALUE self){
|
|
8
|
+
nifti_image *img = to_nifti_image(self);
|
|
9
|
+
|
|
10
|
+
return rb_float_new((double) img->quatern_b);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE nifti_image_quatern_c(VALUE self){
|
|
14
|
+
nifti_image *img = to_nifti_image(self);
|
|
15
|
+
|
|
16
|
+
return rb_float_new((double) img->quatern_c);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
VALUE nifti_image_quatern_d(VALUE self){
|
|
20
|
+
nifti_image *img = to_nifti_image(self);
|
|
21
|
+
|
|
22
|
+
return rb_float_new((double) img->quatern_d);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
VALUE nifti_image_qoffset_x(VALUE self){
|
|
26
|
+
nifti_image *img = to_nifti_image(self);
|
|
27
|
+
|
|
28
|
+
return rb_float_new((double) img->qoffset_x);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALUE nifti_image_qoffset_y(VALUE self){
|
|
32
|
+
nifti_image *img = to_nifti_image(self);
|
|
33
|
+
|
|
34
|
+
return rb_float_new((double) img->qoffset_y);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
VALUE nifti_image_qoffset_z(VALUE self){
|
|
38
|
+
nifti_image *img = to_nifti_image(self);
|
|
39
|
+
|
|
40
|
+
return rb_float_new((double) img->qoffset_z);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
VALUE nifti_image_qfac(VALUE self){
|
|
44
|
+
nifti_image *img = to_nifti_image(self);
|
|
45
|
+
|
|
46
|
+
return rb_float_new((double) img->qfac);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
VALUE nifti_image_quaternions_init(VALUE klass){
|
|
50
|
+
rb_define_method(klass, "quatern_b", nifti_image_quatern_b, 0);
|
|
51
|
+
rb_define_method(klass, "quatern_c", nifti_image_quatern_c, 0);
|
|
52
|
+
rb_define_method(klass, "quatern_d", nifti_image_quatern_d, 0);
|
|
53
|
+
rb_define_method(klass, "qoffset_x", nifti_image_qoffset_x, 0);
|
|
54
|
+
rb_define_method(klass, "qoffset_y", nifti_image_qoffset_y, 0);
|
|
55
|
+
rb_define_method(klass, "qoffset_z", nifti_image_qoffset_z, 0);
|
|
56
|
+
rb_define_method(klass, "qfac", nifti_image_qfac, 0);
|
|
57
|
+
|
|
58
|
+
return klass;
|
|
59
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#include <ruby.h> // Ruby C extensions
|
|
2
|
+
#include <nifti1_io.h> // standard NIfTI C library
|
|
3
|
+
|
|
4
|
+
#include <nifti_image_converters.h>
|
|
5
|
+
#include <nifti_image_spacings.h>
|
|
6
|
+
|
|
7
|
+
VALUE nifti_image_dx(VALUE self){
|
|
8
|
+
nifti_image *img = to_nifti_image(self);
|
|
9
|
+
|
|
10
|
+
return rb_float_new((double) img->dx);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
VALUE nifti_image_dy(VALUE self){
|
|
14
|
+
nifti_image *img = to_nifti_image(self);
|
|
15
|
+
|
|
16
|
+
return rb_float_new((double) img->dy);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
VALUE nifti_image_dz(VALUE self){
|
|
20
|
+
nifti_image *img = to_nifti_image(self);
|
|
21
|
+
|
|
22
|
+
return rb_float_new((double) img->dz);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
VALUE nifti_image_dt(VALUE self){
|
|
26
|
+
nifti_image *img = to_nifti_image(self);
|
|
27
|
+
|
|
28
|
+
return rb_float_new((double) img->dt);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
VALUE nifti_image_du(VALUE self){
|
|
32
|
+
nifti_image *img = to_nifti_image(self);
|
|
33
|
+
|
|
34
|
+
return rb_float_new((double) img->du);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
VALUE nifti_image_dv(VALUE self){
|
|
38
|
+
nifti_image *img = to_nifti_image(self);
|
|
39
|
+
|
|
40
|
+
return rb_float_new((double) img->dv);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
VALUE nifti_image_dw(VALUE self){
|
|
44
|
+
nifti_image *img = to_nifti_image(self);
|
|
45
|
+
|
|
46
|
+
return rb_float_new((double) img->dw);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
VALUE nifti_image_pixdim(VALUE self){
|
|
50
|
+
int i = 0;
|
|
51
|
+
nifti_image *img = to_nifti_image(self);
|
|
52
|
+
|
|
53
|
+
VALUE rb_data = rb_ary_new2(img->nvox);
|
|
54
|
+
|
|
55
|
+
for(i = 0; i < 8; i++){
|
|
56
|
+
rb_ary_store(rb_data, i, rb_float_new((double) img->pixdim[i]));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return rb_data;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
VALUE nifti_image_qform_code(VALUE self){
|
|
63
|
+
nifti_image *img = to_nifti_image(self);
|
|
64
|
+
|
|
65
|
+
return INT2NUM(img->qform_code);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
VALUE nifti_image_sform_code(VALUE self){
|
|
69
|
+
nifti_image *img = to_nifti_image(self);
|
|
70
|
+
|
|
71
|
+
return INT2NUM(img->sform_code);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
VALUE nifti_image_spacings_init(VALUE klass){
|
|
75
|
+
rb_define_method(klass, "dx", nifti_image_dx, 0);
|
|
76
|
+
rb_define_method(klass, "dy", nifti_image_dy, 0);
|
|
77
|
+
rb_define_method(klass, "dz", nifti_image_dz, 0);
|
|
78
|
+
rb_define_method(klass, "dt", nifti_image_dt, 0);
|
|
79
|
+
rb_define_method(klass, "du", nifti_image_du, 0);
|
|
80
|
+
rb_define_method(klass, "dv", nifti_image_dv, 0);
|
|
81
|
+
rb_define_method(klass, "dw", nifti_image_dw, 0);
|
|
82
|
+
rb_define_method(klass, "pixdim", nifti_image_pixdim, 0);
|
|
83
|
+
rb_define_method(klass, "qform_code", nifti_image_qform_code, 0);
|
|
84
|
+
rb_define_method(klass, "sform_code", nifti_image_sform_code, 0);
|
|
85
|
+
|
|
86
|
+
return klass;
|
|
87
|
+
}
|