Month: August 2014

Reading raw data with sbxread()


Raw image data in scanbox is contained in *.sbx files.  To read these data you can use the sbxread() function.

Here is the documentation from its help section–


function x = sbxread(fname,k,N,varargin)

% img = sbxread(fname,k,N,varargin)
%
% Reads from frame k to k+N-1 in file fname
%
% fname - the file name (e.g., 'xx0_000_001')
% k - the index of the first frame to be read. The first index is 0.
% N - the number of consecutive frames to read starting with k.
%
% If N>1 it returns a 4D array of size = [#pmt rows cols N]
% If N=1 it returns a 3D array of size = [#pmt rows cols]
%
% #pmts is the number of pmt channels being sampled (1 or 2)
% rows is the number of lines in the image
% cols is the number of pixels in each line
%
% Note that these images are the raw data, not corrected for motion and
% non-uniform sampling
%
% The function also creates a global 'info' variable with additional
% informationi about the file

So, for example, the following lines of code will read images from 0 to 19 (20 total) and display the average of the first (green) PMT channel:

</pre>
<pre>>> x = sbxread('gd8_000_000',1,20);
>> imagesc(squeeze(mean(x(1,:,:,:),4))), truesize, axis off

And you may get something like this:

spatial raw

Note that these raw data have not yet been corrected for non-uniform sampling.  To correct for non-uniform sampling you can post multiply the image with a sparse interpolant matrix stored in the global variable info.S.  For example, the following lien computes the mean image of the first 20 and corrects for spatial distortion:

imagesc(squeeze(mean(x(1,:,:,:),4))*info.S), truesize, axis off

…and now you get:

spatial compensation

 

The global info variable contains a number of useful information:

              frame: [144x1 double]
               line: [144x1 double]
           event_id: [144x1 double]
            resfreq: 7938
 postTriggerSamples: 5000
   recordsPerBuffer: 512
     bytesPerBuffer: 10240000
           channels: 1
         ballmotion: []
          abort_bit: 0
             config: [1x1 struct]
           messages: {72x1 cell}
            aligned: [1x1 struct]
                  S: [1250x796 double]
              nchan: 2
                fid: 7
            max_idx: 9028

The variables frame, line and event_id, contain the description of TTL events that arrived during the experiment as described here. The variable S, contains the sparse interpolant matrix you can use to correct for non-uniform sampling. The other variables are used internally by sbxread() to understand how the *.sbx file is organized.

Non-rigid deformation for calcium imaging frame alignment

xcorr: comp neuro

Oh yeah!

It’s been a while since I last updated the blog – I graduated from McGill, went on a trip to Indonesia where I did a lot of diving (above), came back to Montreal for 16 hours to gather my coffee machine and about three shirts – all I need to survive, really – then moved to sunny California to do a postdoc in Dr. Dario Ringach’s lab at UCLA. Living the dream.

We’ve been doing calcium imaging – GCamp6 – in mice via a custom-built microscope – you can read more about the microscope over at the Scanbox blog.

If you’re used to working with single electrode or even MUAs, calcium imaging will blow your freaking mind – you can get more than a hundred shiny neurons in a given field of view, so you can realistically ask and answer questions about how a local circuit works knowing that you’re not massively undersampling the population.

Inter-frame motion is an issue in awake…

View original post 515 more words