This code provides for reading .SPE files (v2+), typically produced with Princeton Instruments camera systems. Its counterpart also allows for writing data into a valid SPE (v2) container.
Both functions are implemented similar to the build in MATLAB-functions: 'VideoReader' and 'VideoWriter'.
i'm trying to convert a multiple Tiff file into a multiple spe file.
The output file contains the good number of frames but (1) they is a rotation and (2) the data don't conrrespond to the original one...
Thanks for your help.
I'm using this code:
vidObj = SpeWriter('MyOutputFile.spe');
info = imfinfo('MyInputFile.tif');
[img_size1 img_size2 img_size3]=size(imread('MyInputFile.tif', 1, 'Info', info));
num_images = numel(info);
xyt_stack=zeros([img_size1 img_size2 num_images img_size3], img_type);
%preallocate array of correct type and size to improve speed
for k = 1:num_images
A = imread('MyInputFile.tif', k, 'Info', info);
Really useful, thanks!
I believe that the bug in which the image shifts with increasing frame number is a result of the code not accounting for the presence of metadata after each frame in a .SPE v3 file. I got rid of my offset by changing the line
seekstart = seekstart + frameskip*width*height*databytes;
seekstart = seekstart + frameskip*(width*height*databytes + 8*numMetaDataTypes);
where numMetaDataTypes is the integer number of metadata types stored for each frame - these can be seen by looking at the 'file information' of the .spe file in LightField.
I can not read the wavelength information (only number of counts can be read). Is it the way I call the function incorrect, or it is not supported?
Thanks, the reader component is very useful. But for multi-frame-SPE I encounter the same "bug" as Nick Sinclair. There is an images shift with increasing frame number (Matlab 2014a)
- edit: Seems like this problem occurs only, when there are timestamps in the spe-file itself
Thanks. This has been very useful. I have only used the reader component, though.
I have encountered a bug in reading multi-frame SPE files. The images are being shifted off to the right with increasing frame#, by about 4 pixels per frame. This is for SpeFormat version 3.0, Matlab version 2014b.
And @239 change frameWidth <-> frameHeight, like that:
[frameWidth, frameHeight] = SpeWriter.getFrameSize(frame);
Apologize for spam, but I can't edit my previous post.
Probably I found a bug.
In SpeWriter, @function writeFrames @351 line should be:
height = size(frames,2) % change 1 -> 2
and @359 line:
width = size(frames,1); % change 2 -> 1
now (in my case) is OK.
This does not work. SOpa