readFrames_fromBin.m 1.1 KB

1234567891011121314151617181920212223
  1. function frame_data = readFrames_fromBin(binFile,allsignalsFile,firstFrame,numFrames)
  2. % input
  3. % binFile = full file path to binary file for the experiment.f
  4. % matFile = full file path to the 'allsignals.mat' file.
  5. % firstFrame = position of the first frame to be read. For example, if
  6. % you want to pull one of the files, you can enter one of the values in
  7. % config.fileInfo.starFrame.
  8. % numFrames = number of frames from the firstFrame to be read.
  9. % output
  10. % frame_data = matrix of intensity values for the frames that was
  11. % specificed. The first two dimensions are the size of the field of view
  12. % in pixels, and the third dimension is the frames. The format of the
  13. % data is in unsigned 16-bit integer.
  14. %
  15. load(allsignalsFile)
  16. fid = fopen(binFile);
  17. Ly = config.imageDimension(2);
  18. Lx = config.imageDimension(1);
  19. fseek(fid,Ly*Lx*(firstFrame-1)*2,'bof'); % position the data cursor right before the first of the frame to be read
  20. frame_data = fread(fid,Ly*Lx*numFrames,'*uint16');% read the specified frames from the binary
  21. frame_data = reshape(frame_data,Ly,Lx,[]);% reshape the data into final form;
  22. fclose(fid);% close the file before exiting