-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V1.0fixes #6
V1.0fixes #6
Conversation
For some reason |
should be fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this. Just small stuff and then I think this can be merged.
|
||
pixels = read(io, Float32, width, height, frames) | ||
# two additional lines? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only part that seems concerning, assuming that it nominally worked before. (I've never tested this myself.) Since it's "weird," is there way to do a sanity check and make sure you're not accidentally consuming offset
(below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including either one or both lines yields non-integer values for the test files I have at hand. Also, the data looks correct and if I remember correctly, I checked it against tif files generated alongside the sif files.
src/AndorSIF.jl
Outdated
prop = Compat.@compat Dict( | ||
"colorspace" => "Gray", | ||
"spatialorder" => ["y", "x"], | ||
"spatialorder" => ["x", "y"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty outdated now. I'd use permuteddimsview
from ImageCore.jl. Likewise, returning Gray{Float32}
takes care of the colorspace field. Finally, [1, 1]
is the default pixelspacing, better not to include it since folks may want to provide the correct answer (e.g., in microns) using Unitful.jl and AxisArrays.jl. So the only need for the ImageMeta
is the ixon
header.
src/AndorSIF.jl
Outdated
"ixon" => ixon, | ||
"suppress" => Set{Any}(("ixon",)), | ||
"pixelspacing" => [1, 1] | ||
) | ||
if frames > 1 | ||
prop["timedim"] = 3 | ||
end | ||
Image(float64(pixels), prop) | ||
ImageMeta(pixelmatrix .|> Float64, prop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that it's important to return Float64
, Gray{Float32}
seems entirely appropriate.
Bump. Given #7, best to get this merged a new version tagged. If there are some things you're uncertain of, just give it your best shot and I'll merge. |
Thanks for continuing to take a crack at this. In |
src/AndorSIF.jl
Outdated
numbytes = 4 * frames * width * height # number of bytes to read | ||
pixelbytes = read(io, numbytes) | ||
pixelarray = reinterpret(Gray{Float32}, pixelbytes) | ||
pixelmatrix = reshape(pixelarray, (height, width)) |> collect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is a good idea to collect the reshaped array. But returning the Reshaped
type looked a bit messy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do this:
pixelmatrix = Matrix{Gray{Float32}}(undef, height, width)
read!(io, pixelmatrix)
and then it will immediately be in the shape and element type you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice trick! That made me realize that there currently was no support for multiple frames. Returning a 3D array would be a solution. I don't know if that's the best, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's continuous on disk, that would be best. Even better would be to use Mmap.mmap
: https://docs.julialang.org/en/latest/stdlib/Mmap/, since it would allow you to "load" a terabyte-sized file without saturating your memory. You can see examples in https://github.com/JuliaIO/NRRD.jl/blob/9202ea1d01c69413104e2e7328f2cbaca06f5ee2/src/NRRD.jl#L242-L243.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks largely ready to go, thanks!
src/AndorSIF.jl
Outdated
numbytes = 4 * frames * width * height # number of bytes to read | ||
pixelbytes = read(io, numbytes) | ||
pixelarray = reinterpret(Gray{Float32}, pixelbytes) | ||
pixelmatrix = reshape(pixelarray, (height, width)) |> collect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do this:
pixelmatrix = Matrix{Gray{Float32}}(undef, height, width)
read!(io, pixelmatrix)
and then it will immediately be in the shape and element type you want.
I think we could merge this as-is, unless you want to do the Mmap thing now. It could be a separate PR if you prefer. Just let me know. |
With Mmap thing you mean the |
Well, the That's what memory-mapping does: it "fakes" a giant array, without requiring that you be able to load the whole thing at once. Instead, data are loaded on-demand, but you get the convenience of not having to worry about that and getting to treat the array as if it's just a regular array. |
Hmm, got this error: ef3d444#commitcomment-41335099 From here you can see that even 0.0.3 was released. I've changed this to v0.1.0 and submitted a registration, see JuliaRegistries/General#19264. Because this is now counted as a new package, it will take 3 days before that is merged. |
I had to change quite a lot for the part where the reader was just skipping lines in the header of the file. I could only test with the files I have at hand. I included these in the test folder. I'm not sure if that's the right way to do it though.