Skip to content

Downsampling

I. Downsampling and Conversion to .mat Format

The first step in the CaliAli pipeline is to convert the raw video format into the .mat format used by CaliAli. This step is done together with spatial and temporal downsampling.

Running CaliAli_downsample() would call a file selection windows allowing to process multiple files:
 CaliAli_options=CaliAli_downsample(CaliAli_options);  

Output File

Running this function produces a .mat file with the _ds tag, containing both the video data and the CaliAli_options structure. By default, the output file name matches the input video, and the save path defaults to the location of the input video.

What formats are supported by CaliAli

CaliAli supports .avi / .m4v / .mp4 / .mkv / .tiff / .isdx (Inscopix). However there are some limitations and requirements depending on the operative system that you are using:

Matlab does not have the necessary codecs to process .avi files in windows. You need to download and install the K-lite Codec Pack to be able to run this code.

Inscopix Users: Please note the following system-specific instructions

This requires installing the Inscopix Data Processing software. By default, the function searches for the Inscopix path in C:\Program Files\Inscopix\Data Processing. If that path is not found, a folder selection dialog box will appear.

  • CaliAli cannot convert Inscopix .isdx data on ARM machines—use the Inscopix software to export a compatible format.
  • MATLAB cannot process compressed .avi files—save videos uncompressed or convert them with batchConvertVideos().

We have not tested CaliAli in Linux system yet but it is in our to do list.

What if my video sessions are split into multiple video files (common for UCLA recordings)?

Data acquired with the UCLA Miniscope is often divided into multiple .avi videos—select the entire folder instead of individual files. Lean more here.

Can I automate this process without manually selecting files?

Yes! The CaliAli_options structure contains subfields like input_files and output_files, which allow you to programmatically automate file processing. You can pass a cell array of file paths to input_files and use the cell array from output_files as input for the next module. For example, running:

matlab CaliAli_options.motion_correction.input_files = CaliAli_options.downsampling.output_files;

will automatically set the downsampling output files as the input for the motion correction module, skipping the file selection dialog entirely. This approach is especially useful when processing multiple files overnight 😴.

What if I want to change parameters in the middle of the analysis?

If you want to change parameters in the CaliAli_options structure, you can simply modify its values:

CaliAli_options.motion_correction.input_files = CaliAli_options.downsampling.output_files;

However, note that some parameters are used by different modules. For example, BVsize is utilized during both motion correction and inter-session alignment. To replace all instances of BVsize, you can run:
CaliAli_options = CaliAli_parameters(CaliAli_options, 'BVsize', BVsize);

Now, if you want to change parameters in the CaliAli_options stored in multiple files, you can run CaliAli_update_parameters(), which will update all the selected files.


After finishing downsampling you can proceed to Motion Correction