JuliaIO / NRRD.jl

Julia support for the Nearly Raw Raster Data (NRRD) image file format
Other
10 stars 9 forks source link

Crashes on type error #30

Open ghost opened 5 years ago

ghost commented 5 years ago

The following (depends on teem installed) crashes on:

ERROR: MethodError: Cannot convert an object of type Array{Float64,1} to an object of type NRRD.PTuple{Float64}

using NRRD, FileIO

test_helix_filename="data/test_helix.nnrd"

function make_test_helix()
    if !isfile(test_helix_filename)
        run(`tend helix -s 38 39 40 -r 0.5 -R 1.2 -S 2 -o $test_helix_filename`)
    end
end

function test_helix()
    make_test_helix()
    img = load(test_helix_filename)
    return img
end
ghost commented 5 years ago

Adding (as a copy-paste of the StringPTuple instance)

alloctype(::Type{PTuple{T}}) where {T} = Any

seems to help, however, I also needed to (julia 1.1) explicitly

import FileIO.load
timholy commented 5 years ago

Your alloctype line fixes it for me, without any other shenanigans. Care to submit a PR or do you want me to do it?

Note to self: on Ubuntu machines it's teem-tend.

ghost commented 5 years ago

Please do it. I don't touch git with a stick shorter than the Mercurial bridge.

timholy commented 5 years ago

OK, to do this right is a much bigger project, because we need "masked symmetric 3D matrix" support. Are you willing to help implement this? We'd basically need some types something like this:

struct MaskedSymmetricMatrix{N,T,L} <: StaticMatrix{N,N,T}
    mask::T     # in operations this is converted to Bool, but for mmap purposes retain type T
    data::SSymmetricCompact{N,T,L}
end

where we need someone to push https://github.com/JuliaArrays/StaticArrays.jl/pull/358 over the finish line.

timholy commented 5 years ago

Just a note, we got https://github.com/JuliaArrays/StaticArrays.jl/pull/358 over that finish line, so this is an easier project now.