Hi,
I’m trying to port over some C++ & IDL code to Julia, the code basically opens up a binary file which has a 512 byte header described by a c++ struct. The reaminder of the file is a stack of 8-bit greyscale images, the details of the stack are given in elements of the header.
I can create a struct in Julia to hold the header data, but trying to read in the file fails. This is the code I’m trying.
mutable struct tomheader
xsize::UInt16
ysize::UInt16
zsize::UInt16
lmarg::UInt16
rmarg::UInt16
tmarg::UInt16
bmarg::UInt16
tzmarg::UInt16
bzmarg::UInt16
num_samples::UInt16
num_proj::UInt16
num_blocks::UInt16
num_slices::UInt16
bin::UInt16
gain::UInt16
speed::UInt16
pepper::UInt16
calibrationissue::UInt16
num_frames::UInt16
machine::UInt16
spare_int::Array{UInt16,12}
scale::Float32
offset::Float32
voltage::Float32
current::Float32
thickness::Float32
pixel_size::Float32
distance::Float32
exposure::Float32
mag_factor::Float32
filterb::Float32
correction_factor::Float32
spare_float::Array{Float32,2}
z_shift::UInt32
z::UInt32
theta::UInt32
time::Array{UInt8,26}
duration::Array{UInt8,12}
owner::Array{UInt8,21}
user::Array{UInt8,5}
specimen::Array{UInt8,32}
scan::Array{UInt8,32}
comment::Array{UInt8,64}
spare_char::Array{UInt8,192}
end
f = open(“testfile.tom”,“r”)
th = Ref{tomheader}() // fails with Base.RefValue{tomheader}(#undef)
read!(f, th,512)
Can anyone point me at what I’m doing wrong?
cheers,
David
4 posts - 3 participants