Skip to content

Commit

Permalink
Merge pull request #19 from timholy/teh/no_z
Browse files Browse the repository at this point in the history
Support files that are 2d vs time
  • Loading branch information
timholy committed Feb 4, 2018
2 parents 8e540ed + fcda3d2 commit 46d5509
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/ImagineFormat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}()
Expand Down
1 change: 1 addition & 0 deletions test/no_z.cam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c��ې�Ȣ�U��U���RF4�Ez<�X��L����#�&�ڒߖf�d#���p�67�9z�>ch� ng�Ty§�}�!��p�����υ��kl;��U�����'��y���[ N��k��
Expand Down
45 changes: 45 additions & 0 deletions test/no_z.imagine
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 46d5509

Please sign in to comment.