diff --git a/.travis.yml b/.travis.yml index f4d930c..383cb8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,10 @@ language: julia os: - linux - osx + - windows julia: - - 0.7 - 1.0 + - 1 - nightly notifications: email: false diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..1adecd4 --- /dev/null +++ b/Project.toml @@ -0,0 +1,40 @@ +name = "NRRD" +uuid = "9bb6cfbd-7763-5393-b1b5-1c8e09872146" +authors = ["Tim Holy "] +version = "0.6.0" + +[deps] +AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" +ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4" +FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +ImageAxes = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac" +ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" +Libz = "2ec943e9-cfe8-584d-b93d-64dcb6d567b7" +MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900" +Mmap = "a63ad114-7e13-5084-954f-fe012c677804" +Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +Quaternions = "94ee1d12-ae83-5a48-8b1c-48b8ff168ae0" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" + +[compat] +AxisArrays = "0.3, 0.4" +ColorVectorSpace = "0.7, 0.8" +FileIO = "1" +ImageAxes = "0.6" +ImageCore = "0.8.1" +Libz = "1" +MappedArrays = "0.2" +Quaternions = "0.4" +StaticArrays = "0.11, 0.12" +Unitful = "0.14, 0.15, 0.16, 0.17, 0.18" +julia = "1" + +[extras] +ImageMetadata = "bc367c6b-8a6b-528e-b4bd-a4b897500b49" +SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Statistics", "Test", "SimpleTraits", "ImageMetadata"] diff --git a/README.md b/README.md index 260ca71..b643aaa 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # NRRD -[![NRRD](http://pkg.julialang.org/badges/NRRD_0.4.svg)](http://pkg.julialang.org/?pkg=NRRD) -[![NRRD](http://pkg.julialang.org/badges/NRRD_0.5.svg)](http://pkg.julialang.org/?pkg=NRRD) [![Build Status](https://travis-ci.org/JuliaIO/NRRD.jl.svg?branch=master)](https://travis-ci.org/JuliaIO/NRRD.jl) [![codecov.io](http://codecov.io/github/JuliaIO/NRRD.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaIO/NRRD.jl?branch=master) +[![PkgEval][pkgeval-img]][pkgeval-url] Package for reading NRRD files. Implements the [FileIO](https://github.com/JuliaIO/FileIO.jl) interface. @@ -25,7 +24,7 @@ just the header. Assuming you want to save "rich" axis information, a low-level approach using AxisArrays is the following: ```julia -using NRRD, FileIO, FixedPointNumbers, AxisArrays, Unitful +using NRRD, FileIO, ImageCore, AxisArrays, Unitful using Unitful: μm, s # For a 480x640x200 image with time as the third axis, @@ -42,3 +41,6 @@ open("mydata.nhdr", "w") do io NRRD.write_header(io, "0004", header) end ``` + +[pkgeval-img]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/N/NRRD.svg +[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html diff --git a/REQUIRE b/REQUIRE deleted file mode 100644 index 52cccbd..0000000 --- a/REQUIRE +++ /dev/null @@ -1,13 +0,0 @@ -julia 0.7 -FixedPointNumbers 0.3.0 -Colors -ColorVectorSpace -StaticArrays -Quaternions -ImageCore -Unitful -Libz -FileIO -AxisArrays -ImageAxes -MappedArrays diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index c2588f1..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,43 +0,0 @@ -environment: - matrix: - - julia_version: 0.7 - - julia_version: 1 - - julia_version: nightly - -platform: - - x86 # 32-bit - - x64 # 64-bit - -# # Uncomment the following lines to allow failures on nightly julia -# # (tests will run but not make your overall status red) -# matrix: -# allow_failures: -# - julia_version: nightly - -branches: - only: - - master - - /release-.*/ - -notifications: - - provider: Email - on_build_success: false - on_build_failure: false - on_build_status_changed: false - -install: - - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1")) - -build_script: - - echo "%JL_BUILD_SCRIPT%" - - C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%" - -test_script: - - echo "%JL_TEST_SCRIPT%" - - C:\julia\bin\julia -e "%JL_TEST_SCRIPT%" - -# # Uncomment to support code coverage upload. Should only be enabled for packages -# # which would have coverage gaps without running on Windows -# on_success: -# - echo "%JL_CODECOV_SCRIPT%" -# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%" diff --git a/src/NRRD.jl b/src/NRRD.jl index 9760705..ef0f1cb 100644 --- a/src/NRRD.jl +++ b/src/NRRD.jl @@ -2,17 +2,15 @@ module NRRD using Mmap, Printf # Packages needed to return the possible range of element types -using FixedPointNumbers, Colors, ColorVectorSpace, StaticArrays, Quaternions +using ImageCore, ColorVectorSpace, StaticArrays, Quaternions # Other packages using AxisArrays, ImageAxes, Unitful, MappedArrays using FileIO import Libz -import FixedPointNumbers -using Colors: AbstractGray using AxisArrays: HasAxes -string2type = Dict( +const string2type = Dict( "signed char" => Int8, "int8" => Int8, "int8_t" => Int8, @@ -66,7 +64,7 @@ type2string(::Type{T}) where {T} = type2string(eltype(T), T) type2string(::Type{T}, ::Type{T}) where {T} = error("type $T unrecognized") type2string(::Type{T1}, ::Type{T2}) where {T1,T2} = type2string(T1) -space2axes = Dict( +const space2axes = Dict( "right-anterior-superior" => (3,(:R,:A,:S)), "ras" => (3,(:R,:A,:S)), "left-anterior-superior" => (3,(:L,:A,:S)), @@ -104,9 +102,9 @@ const axes2space = Dict( # We put these in a dict so that we don't eval untrusted # strings. Please submit PRs to add to this list if you need # additional unit support. -unit_string_dict = Dict("" => 1, "m" => u"m", "mm" => u"mm", "s" => u"s", - "um" => u"μm", "μm" => u"μm", "microns" => u"μm", - "pixel" => 1) +const unit_string_dict = Dict("" => 1, "m" => u"m", "mm" => u"mm", "s" => u"s", + "um" => u"μm", "μm" => u"μm", "microns" => u"μm", + "pixel" => 1) struct QString end # string with quotes around it: "mm" VTuple{T} = Tuple{Vararg{T}} # space-delimited tuple: 80 150 @@ -620,7 +618,7 @@ struct UnknownColor{T,N} <: Color{T,N} end """ - outer_eltype!(header, Traw) -> T, nd, perm + T, nd, perm = outer_eltype!(header, Traw) Extract the julia array `eltype` `T`, the number of dimensions `nd` **excluding** color/complex/vector/matrix element data, and any @@ -1055,6 +1053,7 @@ nrrd_format(io, ::Type{StringPTuple{T}}, s::AbstractString) where {T} = nrrd_for nrrd_format(io, ::Type{StringPTuple{T}}, container) where {T} = nrrd_format(io, PTuple{T}, container) alloctype(::Type{T}) where {T} = T +alloctype(::Type{PTuple{T}}) where {T} = Any alloctype(::Type{StringPTuple{T}}) where {T} = Any # Union{String,Vector{T}} alloctype(::Type{IntFloat}) = Union{Int,Float64} diff --git a/test/REQUIRE b/test/REQUIRE deleted file mode 100644 index 194d701..0000000 --- a/test/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -SimpleTraits -ImageMetadata 0.5.2 diff --git a/test/io/test_helix.nrrd b/test/io/test_helix.nrrd new file mode 100644 index 0000000..85c806f Binary files /dev/null and b/test/io/test_helix.nrrd differ diff --git a/test/make_ufixed.jl b/test/make_ufixed.jl index e23bec2..9494c7c 100644 --- a/test/make_ufixed.jl +++ b/test/make_ufixed.jl @@ -1,4 +1,4 @@ -using FileIO, NRRD, FixedPointNumbers, Colors +using FileIO, NRRD, ImageCore Alast = nothing for (A, name) in ((rand(UInt8, 3, 5), "uint8"), diff --git a/test/readremote.jl b/test/readremote.jl index 48cc6fe..37e5c7d 100644 --- a/test/readremote.jl +++ b/test/readremote.jl @@ -1,4 +1,4 @@ -using FileIO, FixedPointNumbers, Colors, ImageCore, Test, Statistics +using FileIO, ImageCore, Test, Statistics workdir = joinpath(tempdir(), "ImagesNRRD") isdir(workdir) || mkdir(workdir) diff --git a/test/runtests.jl b/test/runtests.jl index cfed718..74bb97f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using FileIO, FixedPointNumbers, ColorTypes, Unitful, AxisArrays, ImageAxes, ImageMetadata +using FileIO, ImageCore, Unitful, AxisArrays, ImageAxes, ImageMetadata using Test, Base.CoreLogging include("unu-make.jl") @@ -180,6 +180,11 @@ include("unu-make.jl") end end + @testset "Extended eltype" begin + img = load(joinpath(dirname(@__FILE__), "io", "test_helix.nrrd")) + @test axisnames(img)[end-2:end] == (:R, :A, :S) + end + GC.gc() # to close any mmapped files try rm(workdir, recursive=true) diff --git a/test/unu-make.jl b/test/unu-make.jl index 0f9419e..8e367fb 100644 --- a/test/unu-make.jl +++ b/test/unu-make.jl @@ -1,5 +1,5 @@ # Test headers written by `unu make` -using NRRD, FileIO, Colors, AxisArrays, ImageAxes, Unitful, SimpleTraits +using NRRD, FileIO, ImageCore, AxisArrays, ImageAxes, Unitful, SimpleTraits using Test headerpath = joinpath(dirname(@__FILE__), "headers")