Skip to content

Transposition and 3d data #2

Open

Description

I've been playing around with DS9.jl for a while now and figured a couple things could be addressed.

In particular the way array data is transferred between XPA and Julia permutes each dimension, since Julia is column-ordered. Using PyDS9 through PyCall will correctly orient the data (something in PyCall makes sure arrays show up in python knowing they are column-oriented), but the same image put through DS9.jl will be transposed.

At a low-level, I'm not sure if there is an appropriate way to write things in XPA.jl to make sure when the array pointers are given they are column ordered, if that's even a thing. At a higher level, within this library when set encounters an array, it should permute it appropriately to become row-ordered.


I also work with 3d data frequently, and it seems pretty trivial to add the feature here. I've coded up a version that seems to work-

function set(arr::DenseArray{T,3};
             endian::Symbol=:native,
             mask::Bool=false,
             new::Bool=false) where {T<:PixelTypes}
    !new && set("frame delete all"); set("frame new")
    args = String[]
    push!(args, "array")
    if mask; push!(args, "mask"); end
    parr = permutedims(arr, (3, 2, 1))
    set(args..., _arraydescriptor(parr; endian=endian); data=parr)
end

function _arraydescriptor(arr::DenseArray{T,3};
                          endian::Symbol=:native) where {T}
    bp = bitpix_of(T)
    bp != 0 || error("unsupported data type")
    return string("[xdim=",size(arr,1),",ydim=",size(arr,2),",zdim=",size(arr,3),
                  ",bitpix=",bp,",endian=",endian,"]")
end

I'm happy to wrap this up in a PR, but I wanted to discuss the transposition issue first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions