From fcda3d2835fc8a59bb62c07dbaf491c96156d588 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 4 Feb 2018 08:49:00 -0600 Subject: [PATCH] Support files that are 2d vs time --- src/ImagineFormat.jl | 13 +++++-------- test/no_z.cam | 1 + test/no_z.imagine | 45 ++++++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 7 +++++++ 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 test/no_z.cam create mode 100644 test/no_z.imagine diff --git a/src/ImagineFormat.jl b/src/ImagineFormat.jl index b90e1d1..966d111 100644 --- a/src/ImagineFormat.jl +++ b/src/ImagineFormat.jl @@ -29,15 +29,12 @@ function load(io::Stream{format"Imagine"}; mode="r") camfilename = basename*".cam" Traw = h["pixel data type"] T = Traw <: Unsigned ? Normed{Traw, h["original image depth"]} : Traw - sz = [h["image width"], h["image height"], h["frames per stack"], h["nStacks"]] - if sz[4] == 1 - sz = sz[1:3] - if sz[3] == 1 - sz = sz[1:2] - end - end havez = h["frames per stack"] > 1 havet = h["nStacks"] > 1 + sz = havez & havet ? [h["image width"], h["image height"], h["frames per stack"], h["nStacks"]] : + havez ? [h["image width"], h["image height"], h["frames per stack"]] : + havet ? [h["image width"], h["image height"], h["nStacks"]] : + [h["image width"], h["image height"]] # Check that the file size is consistent with the expected size if !isfile(camfilename) warn("Cannot open ", camfilename) @@ -228,7 +225,7 @@ const field_key_dict = Dict{AbstractString,Function}( "x translation in pixels" => x->parse(Int,x) != 0, "y translation in pixels" => x->parse(Int,x) != 0, "rotation angle in degree" => x->parse(Float64,x) != 0) - + function parse_header(s::IOStream) headerdict = Dict{String, Any}() diff --git a/test/no_z.cam b/test/no_z.cam new file mode 100644 index 0000000..394bf09 --- /dev/null +++ b/test/no_z.cam @@ -0,0 +1 @@ +cېȢUURF4Ezch ngTy§}!p υkl;U'y[ Nk \ No newline at end of file diff --git a/test/no_z.imagine b/test/no_z.imagine new file mode 100644 index 0000000..35df5b2 --- /dev/null +++ b/test/no_z.imagine @@ -0,0 +1,45 @@ +IMAGINE +[general] +header version=5.1 +app version=0.9, build (Apr 20 2007, 12:24:54) +date and time=2007-05-09T14:46:30 +byte order=l + +[misc params] +stimulus file content= +comment= +ai data file=G:/2007_05_09/vno_baseline.ai +image data file=G:/2007_05_09/vno_baseline.stacks\stack_%1_ +piezo=start position: 0 um;stop position: 0 um;output scan rate: 10000 + +[ai] +nscans=-1 +channel list=0 1 2 3 +label list=piezo$stimuli$camera frame TTL$heartbeat +scan rate=10000 +min sample=-2048 +max sample=2047 +min input=-10 +max input=10 + +[camera] +original image depth=14 +saved image depth=14 +image width=6 +image height=5 +number of frames requested=2 +nStacks=2 +idle time between stacks=3 s +pre amp gain=3.1 +EM gain=0 +exposure time=0.05 s +vertical shift speed=1.9176 us +vertical clock vol amp=0 +readout rate=35 MHz +pixel order=x y z +frame index offset=0 +frames per stack=1 +pixel data type=uint16 +camera=DV8285_BV +um per pixel=-1 +binning=hbin:1;vbin:1;hstart:1;hend:1004;vstart:1;vend:1002 diff --git a/test/runtests.jl b/test/runtests.jl index 2971f7a..24868c9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -73,3 +73,10 @@ B[1,1,1,2] = -1.0 @test A[1,1,4,2] == -1.0 @test all(A[:,:,1:4,[1;3;4;5]] .== A_copy[:,:,1:4,[1;3;4;5]]) #make sure we only changed one index +img = load("no_z.imagine") +@test eltype(img) == N2f14 +@test ndims(img) == 3 +@test size(img) == (6,5,2) +@test timedim(img) == 3 +@test axisnames(img) == (:x, :l, :time) +@test pixelspacing(img) == (-1μm, -1μm)