├── simpleitk-1.1.0-0.rockspec ├── simpleitk-1.2.0-0.rockspec ├── simpleitk-1.2.2-0.rockspec ├── simpleitk-2.0.0-0.rockspec ├── simpleitk-2.1.0-0.rockspec ├── simpleitk-2.2.0-0.rockspec ├── .circleci └── config.yml ├── docs └── making-a-custom-rock.md ├── examples └── SimpleDerivative.lua ├── CMakeLists.txt └── README.md /simpleitk-1.1.0-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '1.1.0-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v1.1.0.zip', 7 | dir = 'SimpleITKLuaRock-1.1.0', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "1.1.0" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /simpleitk-1.2.0-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '1.2.0-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v1.2.0.zip', 7 | dir = 'SimpleITKLuaRock-1.2.0', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "1.2.0" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /simpleitk-1.2.2-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '1.2.2-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v1.2.2.zip', 7 | dir = 'SimpleITKLuaRock-1.2.2', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "1.2.2" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /simpleitk-2.0.0-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '2.0.0-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v2.0.0.zip', 7 | dir = 'SimpleITKLuaRock-2.0.0', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "2.0.0" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /simpleitk-2.1.0-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '2.1.0-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v2.1.0.zip', 7 | dir = 'SimpleITKLuaRock-2.1.0', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "2.1.0" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /simpleitk-2.2.0-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'simpleitk' 4 | version = '2.2.0-0' 5 | source = { 6 | url = 'https://github.com/SimpleITK/SimpleITKLuaRock/archive/v2.2.0.zip', 7 | dir = 'SimpleITKLuaRock-2.2.0', 8 | } 9 | description = { 10 | summary = "A Lua binding to SimpleITK.", 11 | detailed = '', 12 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 13 | license = 'BSD', 14 | } 15 | dependencies = { 16 | 'lua >= 5.1' 17 | } 18 | build = { 19 | type = 'cmake', 20 | modules = { 21 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 22 | }, 23 | variables = { 24 | INSTALL_CMOD = "$(LIBDIR)", 25 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 26 | ["CFLAGS:STRING"] = "$(CFLAGS)", 27 | SimpleITK_VERSION = "2.2.0" 28 | }, 29 | copy_directories = { "doc", "examples" } 30 | } 31 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/python:2.7 6 | working_directory: ~/ 7 | resource_class: large 8 | environment: 9 | R_LIBS: /home/circleci/Rlibs 10 | ExternalData_OBJECT_STORES: /home/circleci/.ExternalData 11 | steps: 12 | - checkout: 13 | path : ~/SimpleITKLuaRock 14 | - run: 15 | name: System Dependencies 16 | command: | 17 | sudo apt-get remove cmake swig2.0 18 | sudo apt-get install -y lua5.1 luarocks rsync 19 | sudo pip install numpy scikit-ci-addons 20 | ci_addons circle/install_cmake.py 3.10.0 21 | - run: 22 | name: Build Lua Package 23 | environment: 24 | MAKEFLAGS: "-j4" 25 | command: | 26 | cd ~/SimpleITKLuaRock 27 | sed "s/url.*/url = ''/; /dir/d; s/version.*/version = 'x.0-0'/" simpleitk-1.2.0-0.rockspec > simpleitk-x.0-0.rockspec 28 | luarocks make --local --pack-binary-rock simpleitk-x.0-0.rockspec 29 | - run: 30 | name: Install and Test 31 | environment: 32 | SITK_NOSHOW: "1" 33 | command: | 34 | cd ~/SimpleITKLuaRock 35 | sudo luarocks install simpleitk-x.0-0.linux-x86_64.rock 36 | lua examples/SimpleDerivative.lua 37 | mkdir /tmp/artifacts 38 | cp sitk-lua-test.png /tmp/artifacts 39 | - store_artifacts: 40 | path: /tmp/artifacts 41 | -------------------------------------------------------------------------------- /docs/making-a-custom-rock.md: -------------------------------------------------------------------------------- 1 | 2 | Making a custom rock 3 | ==================== 4 | 5 | Each release of the SimpleITK Luarock is tied to a specific release of 6 | SimpleITK. For example the 1.2 SimpleITK Luarock downloads v1.2 of 7 | SimpleITK from GitHub. 8 | 9 | If you would prefer to build a different version of SimpleITK, you need 10 | a custom version of the rockspec file. Here is what such a rockspec 11 | file would look like. 12 | 13 | #!/usr/bin/env lua 14 | 15 | package = 'SimpleITK' 16 | version = 'x.0-0' 17 | source = { 18 | url = 'file://SimpleITKLuarock.tgz', 19 | dir = 'SimpleITKLuarock', 20 | } 21 | description = { 22 | summary = "A Lua binding to SimpleITK.", 23 | detailed = '', 24 | homepage = 'https://github.com/SimpleITK/SimpleITKLuaRock', 25 | license = 'BSD', 26 | } 27 | dependencies = { 28 | 'lua >= 5.1' 29 | } 30 | build = { 31 | type = 'cmake', 32 | modules = { 33 | SimpleITK = "SimpleITK-build/Wrapping/Lua/lib/SimpleITK.so", 34 | }, 35 | variables = { 36 | INSTALL_CMOD = "$(LIBDIR)", 37 | CMAKE_BUILD_TYPE = "$(CMAKE_BUILD_TYPE)", 38 | ["CFLAGS:STRING"] = "$(CFLAGS)", 39 | }, 40 | copy_directories = { "doc", "examples" } 41 | } 42 | 43 | The main difference between this rockspec and the standard version is the 44 | **source** section. In this rockspec the source points to a local tar 45 | file. 46 | 47 | Also, this rockspec does not have the SimpleITK_VERSION variable 48 | in the build/variables section that the v1.2 rockspec does. So the v1.2 49 | rockspec tells CMake to use SimpleITK version 1.2. Because this custom 50 | rockspec does not have the SimpleITK_VERSION set, cmake will use the 51 | latest version from GitHub's master branch of SimpleITK. 52 | 53 | If you wanted to test build a newer version of the SimpleITK Lua rock, 54 | just create a custom rockspec with SimpleITK_VERSION set to the newer 55 | version. 56 | 57 | -------------------------------------------------------------------------------- /examples/SimpleDerivative.lua: -------------------------------------------------------------------------------- 1 | 2 | --========================================================================= 3 | -- 4 | -- Copyright Insight Software Consortium 5 | -- 6 | -- Licensed under the Apache License, Version 2.0 (the "License"); 7 | -- you may not use this file except in compliance with the License. 8 | -- You may obtain a copy of the License at 9 | -- 10 | -- http://www.apache.org/licenses/LICENSE-2.0.txt 11 | -- 12 | -- Unless required by applicable law or agreed to in writing, software 13 | -- distributed under the License is distributed on an "AS IS" BASIS, 14 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | -- See the License for the specific language governing permissions and 16 | -- limitations under the License. 17 | -- 18 | --========================================================================= 19 | 20 | require "SimpleITK" 21 | 22 | local sitk = {}; 23 | sitk = SimpleITK; 24 | 25 | outfile = "sitk-lua-test.png"; 26 | 27 | -- parse the command line options 28 | n = #arg; 29 | for i=1,n do 30 | if ( (arg[i] == "--help") or (arg[i] == "-h") ) then 31 | print ("Usage: SimpleDerivative.lua [--help|-h] [output_image]"); 32 | os.exit(); 33 | else 34 | outfile = arg[i]; 35 | end 36 | end 37 | 38 | -- setup the parameters for the Gaussian source image 39 | -- pixel dimensions of the Gaussian image image 40 | size = sitk.VectorUInt32(); 41 | size:push_back(128); 42 | size:push_back(128); 43 | 44 | -- sigma of the Gaussian 45 | sigma = sitk.VectorDouble(); 46 | sigma:push_back(32.0); 47 | sigma:push_back(32.0); 48 | 49 | -- center of the Gaussian 50 | center = sitk.VectorDouble(); 51 | center:push_back(64.0); 52 | center:push_back(64.0); 53 | 54 | -- create Gaussian image 55 | gauss = sitk.GaussianSource (sitk.sitkFloat32, size, sigma, center); 56 | 57 | -- take the first derivative in the X direction of the Gaussian 58 | deriv = sitk.Derivative(gauss); 59 | 60 | -- rescale the intensities to [0, 255] 61 | result = sitk.RescaleIntensity(deriv, 0, 255.0); 62 | 63 | -- convert the float image pixels to unsigned char 64 | result = sitk.Cast(result, sitk.sitkUInt8); 65 | 66 | -- write the resulting image 67 | sitk.WriteImage(result, outfile); 68 | 69 | -- display the image via the Show function, which invokes ImageJ, by default. 70 | if (os.getenv("SITK_NOSHOW") == nil) then 71 | sitk.Show(result); 72 | end 73 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.3) 3 | 4 | project(SimpleITKLuaRockspec) 5 | 6 | set(proj SimpleITKSuperbuild) 7 | 8 | # compile with multiple processors 9 | include(ProcessorCount) 10 | ProcessorCount(NPROC) 11 | if (NOT NPROC EQUAL 0) 12 | set( ENV{MAKEFLAGS} "-j${NPROC}" ) 13 | endif() 14 | 15 | 16 | if (NOT SimpleITK_VERSION) 17 | message(FATAL_ERROR "SimpleITK_VERSION variable not set") 18 | if (NOT BUILD_NUMBER) 19 | set (BUILD_NUMBER "0") 20 | endif() 21 | set(SimpleITK_GIT_TAG "v${SimpleITK_GIT_TAG}") 22 | set(LUA_SIMPLE_ITK_VERSION "${SimpleITK_VERSION}-${BUILD_NUMBERS}") 23 | endif() 24 | 25 | include(ExternalProject) 26 | 27 | 28 | set( SimpleITK_REPOSITORY http://github.com/SimpleITK/SimpleITK.git ) 29 | 30 | set( EP_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} ) 31 | set( EP_BINARY_DIR ${CMAKE_BINARY_DIR}/${proj}-build ) 32 | set( EP_INSTALL_DIR ${CMAKE_BINARY_DIR}/${proj}-install ) 33 | 34 | 35 | # A separate project is used to download SimpleITK, so that the SuperBuild 36 | # subdirectory can be use for SimpleITK's SuperBuild to build the 37 | # required Lua, GTest etc. 38 | ExternalProject_add( ${proj}-download 39 | SOURCE_DIR ${EP_SOURCE_DIR} 40 | GIT_REPOSITORY ${SimpleITK_REPOSITORY} 41 | GIT_TAG ${SimpleITK_GIT_TAG} 42 | CONFIGURE_COMMAND "" 43 | INSTALL_COMMAND "" 44 | BUILD_COMMAND "" 45 | ) 46 | 47 | if ( $ENV{CMAKE_USE_DISTCC} ) 48 | set(C_LAUNCHER "-DCMAKE_C_COMPILER_LAUNCHER:STRING=distcc") 49 | set(CXX_LAUNCHER "-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=distcc") 50 | endif () 51 | 52 | # The actual SimpleITK Superbuild project that build all the tools 53 | # needed (GTest, PCRE, Swig, Lua & GTest) and then SimpleITK itself. 54 | ExternalProject_add( ${proj} 55 | ${${proj}_EP_ARGS} 56 | SOURCE_DIR ${EP_SOURCE_DIR}/SuperBuild 57 | BINARY_DIR ${EP_BINARY_DIR} 58 | INSTALL_DIR ${EP_INSTALL_DIR} 59 | DOWNLOAD_COMMAND "" 60 | UPDATE_COMMAND "" 61 | CMAKE_CACHE_ARGS 62 | -DBUILD_EXAMPLES:BOOL=OFF 63 | -DBUILD_TESTING:BOOL=OFF 64 | -DBUILD_DOXYGEN:BOOL=OFF 65 | -DWRAP_DEFAULT:BOOL=OFF 66 | -DWRAP_LUA:BOOL=ON 67 | -DSimpleITK_BUILD_STRIP:BOOL=ON 68 | -DSimpleITK_BUILD_DISTRIBUTE:BOOL=ON 69 | ${C_LAUNCHER} 70 | ${CXX_LAUNCHER} 71 | INSTALL_COMMAND "" 72 | DEPENDS ${proj}-download ${${proj}_DEPENDENCIES} 73 | ) 74 | 75 | if ( DEFINED INSTALL_CMOD ) 76 | set( INSTALL_DEST ${INSTALL_CMOD} ) 77 | else () 78 | set( INSTALL_DEST ${CMAKE_INSTALL_PREFIX}/lib/luarocks/rocks/simpleitk/${LUA_SIMPLEITK_VERSION} ) 79 | endif () 80 | 81 | 82 | # install the SimpleITK shared library. 83 | set( SITK_BUILD_DIR ${CMAKE_BINARY_DIR}/${proj}-build/SimpleITK-build ) 84 | install( FILES ${SITK_BUILD_DIR}/Wrapping/Lua/lib/SimpleITK.so 85 | DESTINATION ${INSTALL_DEST} 86 | ) 87 | 88 | set( SITK_SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} ) 89 | 90 | # copy the LICENCE, NOTICE and Readme.md from SimpleITK's source tree to this directory 91 | install( FILES ${SITK_SOURCE_DIR}/LICENSE ${SITK_SOURCE_DIR}/NOTICE ${SITK_SOURCE_DIR}/Readme.md 92 | DESTINATION ${CMAKE_SOURCE_DIR}/doc 93 | ) 94 | 95 | set(_lib_subdir lib) 96 | if(WIN32) 97 | set(_lib_subdir bin) 98 | endif() 99 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimpleITKLuaRock 2 | 3 | We are archiving this package because of a lack of interest or usage. SimpleITK itself remains actively in development, 4 | and users will continue to be able to build SimpleITK for Lua themselves. 5 | 6 | 7 | [![CircleCI Status](https://circleci.com/gh/SimpleITK/SimpleITKLuaRock.svg?&style=shield&circle-token)](https://circleci.com/gh/SimpleITK/SimpleITKLuaRock) 8 | 9 | This package is a rockspec file that will build and install a SimpleITK module for Lua via [LuaRocks](https://luarocks.org), a package manager for Lua modules. [SimpleITK](http://www.simpleitk.org) is a simplified, open source interface to the [Insight Segmentation and Registration Toolkit](https://itk.org) (ITK). ITK is an open-source, cross-platform toolkit that provides developers with an extensive suite of software tools for image analysis and is widely used in academia and industry. 10 | 11 | ## Building the SimpleITK Lua module 12 | Building the module requires Lua v5.1.5, LuaRocks v2.2 and [CMake](https://cmake.org) v3.10. Because SimpleITK is built as a CMake-type build in LuaRocks, this module will only build on Linux and OS X. Currently cmake builds are not supported on Windows in Luarocks. 13 | 14 | Building SimpleITK requires a sizeable amount of computing power. We recommend a multi-core system with a sizable amount of memory. Also, to facilitate multi-processing, the environment variable MAKEFLAGS should be set to something like "-jN", where N is the number of cores. For example, on an 8 core system, use the following: 15 | ``` 16 | export MAKEFLAGS="-j8" 17 | ``` 18 | Build the SimpleITK Lua module with the following command: 19 | ``` 20 | luarocks install simpleitk-1.2.2-0.rockspec 21 | ``` 22 | ## SimpleDerivative.lua example 23 | When building the module, an example progam is installed into the SimpleITK rock, [SimpleDerivative.lua](https://github.com/SimpleITK/SimpleITK/blob/master/Examples/Lua/SimpleDerivative.lua). It is copied from the [SimpleITK repository](https://github.com/SimpleITK/SimpleITK) . 24 | 25 | This example demonstrates a basic progam that uses SimpleITK to create an image of a Gaussian and then performs some operations on that image. First it applies the first derivative in the X direction on the Gaussian, then it rescales the pixel intensities and converts the pixel types from float32 to uint8. Finally the result is written out as a PNG file, and the image is displayed with the [Show function](https://itk.org/SimpleITKDoxygen/html/namespaceitk_1_1simple.html#ac8416e6e7f02dedfe8373b83dbea411d), which invokes [Fiji/ImageJ](http://fiji.sc). 26 | 27 | ## Custom builds 28 | The rockspec in this package is tied to a particular version of SimpleITK. So simpleitk-1.2.2-0.rockspec will build SimpleITK v1.2.2. 29 | To build a custom version of SimpleITK consult the [Building a Custom Version of the SimpleITK Luarock](https://github.com/SimpleITK/SimpleITKLuaRock/wiki/Building-a-custom-version-of-a-SimpleITK-rock) page. 30 | 31 | ## Miscellaneous 32 | Written by David T. Chen from the [National Institute of Allergy and Infectious Diseases](https://www.niaid.nih.gov), dchen@nih.gov. It is covered by the Apache License, Version 2.0: 33 | 34 | http://www.apache.org/licenses/LICENSE-2.0 35 | 36 | For more information about SimpleITK, visit https://simpleitk.readthedocs.io/ 37 | 38 | For more information about ITK, visit http://itk.org 39 | --------------------------------------------------------------------------------