10. Knowledge Base

One common pitfall of using the MCAM is good data management. Each raw image from the MCAM can be as large as 700 MegaBytes and came be acquired up to 5 times per second. A 5 minute recording session can be as large as 1 TB.

MCAM™ Behavior Mode Video Acquisition Best Practices

Multiple video acquisition modes exist within the Ramona Optics MCAM™ and choosing the best method for your application will ensure that data is acquired efficiently to streamline your workflow. The quantity of data streaming through the MCAM™ is extremely high and we need to consider multiple factors including the workstation hardware such as the central processing unit (CPU), random access memory (RAM), solid state drive (SSD) and graphics processing unit (GPU) to ensure that data is successfully processed and saved but additionally the parameters of the camera sensors that sense the data such as resolution, binning, and number of color channels.

First we need to consider the camera sensor size that we are acquiring data from. Specifically, for use with imaging a 96-well plate we recommend 2048x2048 images while for a 24-well plate we recommend a 3072x3072 sensor size. These sensor shapes will ensure that each camera sees four wells of a 96-well plate or one well of a 24-well plate.

Within the video acquisition panels of the MCAM™ user interface three save formats exist, Save to Single MP4, Save to RAM, and Save to Disk. Some details about each of these imaging modes are listed below. We are attempting to maximize frame rate in behavior mode acquisitions, so here we will only consider acquisitions using high frame rate mode.

Save to Single MP4

With this acquisition mode, videos are streamed and compressed to MP4 format to save data space both temporarily in system RAM but also in the final saved file. Data is saved in parallel to data acquisition. This is the recommended acquisition mode for most video acquisitions however we are limited by the rate that the datastream can be compressed by the GPU encoder. Currently the maximum frame rate for this acquisition mode is

  • 60 fps for 2048x2048 sensor size.

  • 30 fps for 3072x3072 sensor size.

Save to Uncompressed NC:

In this acquisition mode data is streamed to RAM and once the entire video has been acquired it is then saved to the SSD in a second step. This mode allows for higher frame rate acquisitions and data is saved in a raw (.NC) file format. Maximum frame rates in this mode are

  • 160 fps for a 96-well plate at 2048x2048.

  • 120 fps for a 24-well plate at 3072x3072.

Duration of these recordings is limited by the quantity of RAM in your MCAM™ workstation. Please note that to use these videos with tracking workflows, the raw NC video files need to be compressed to MP4 format before they enter the tracking pipeline (See Compressing NC Datasets in the MCAM Workflow Manual).

Save to Disk

In this acquisition mode data is streamed through the workstation RAM and saved directly to the SSD. We do not recommend using this save mode because it does not efficiently use system RAM and may put extra strain on the SSD, however we have left it as an option to allow for longer duration recordings. Maximum frame rates in this mode are

  • 160 fps for a 96-well plate at 2048x2048.

  • 120 fps for a 24-well plate at 3072x3072.

Duration of these recordings is limited by the SSD capacity in your MCAM™ workstation. Please note that to use these videos with tracking workflows, the raw NC video files need to be compressed to MP4 format before they enter the tracking pipeline (See Compressing NC Datasets in the MCAM Workflow Manual).

SSDs Choice

While many solid state drives (SSDs) have very fast read speeds, often they fail at the sustained writing tasks that are required by the MCAM.

We strongly encourage the use of the following two NVMe SSDs:

  • The Samsung 970 Pro SSD (up to 1TB). Sustained write speeds of 2 GB/s.

  • Kioxia CD6-R (up to 15 TB). Sustained write speeds up to 2 GB/s.

We strongly encourage the use of NVMe SSDs. However, even many expensive NVMe SSDs start to slowdown under sustained workloads. When formatting an SSD, we recommend leaving the following partition sizes for the following SSD sizes:

  • 4 TB SSDs should be formatted to a 3.25 TB partition.

  • 8 TB SSD formatted to a 6 TB partition.

  • 15 TB SSD formatted to a 14 TB partition.

The addition space on the SSD is used by the SSD firmware to ensure that the fast write speeds are maintained during data acquisition.

USB vs Internal Storage Drives

Both Windows and Linux operating systems optimize for external storage drives differently than they do for internal storage. For writing live MCAM data, we suggest that an internal solid state drive be used, connected directly to SATA ports, or dedicated NVME lanes to the CPU.

Should you have any questions about how to optimize your hardware for use with the MCAM, do not hesitate to contact info@ramonaoptics.com.

Data saving optimization

At Ramona Optics, we believe in sound scientific experiments. This means keeping track of not only the acquired data, but also how it was acquired. Natively, the data is stored as an xarray Dataset. Stills can be exported as a collection of images with a single metadata file. While exporting images might not preserve all metadata correctly, it can be useful to use the export functionality when working with other pieces of software.

For exported data, the metadata.json files created with the owl.mcam_data.save function provide the minimum metadata we believe one should keep about their data.

Certain datasets can benefit from the use of optimized save and load routines. In addition to the standard backends provided by xarray, Ramona supports the use of the "ramona" backend in the load and save operations. This backend is optimized for loading large datasets such as those generated by videos or focal stacks.

To use the "ramona" engine backend, provide it as a parameter to the function that load and save data.

Loading and saving speed of images

Many MCAM operations tend to be memory bound problems. The sheer size of the files ensures that data can usually be processed as fast as you can supply it to the processor. That said, the typical loading and saving operations will be done in a serial fashion.

While the MCAM acquires images, many libraries are either specifically tuned for standard 3 color images, or unable to load the large datasets generated by the MCAM. For example, a standard call to opencv’s imread function will automatically produce a color-like image from grayscale images generated by the MCAM. This can significantly increase the memory requirement of the system (by a factor of 3!). For example a grayscale image loaded with:

>>> cv2.imread('cam0_0.bmp').shape
(2432, 4320, 3)

Will produce a 30 MB dataset in RAM. The true size of the data, is a 2D grayscale image and should in most cases be read with:

>>> cv2.imread('cam0_0.bmp', cv2.IMREAD_UNCHANGED).shape
(2432, 4320)

The owl.mcam_data.load and owl.mcam_data.export attempt to provide good defaults that can be used with the scientific data produced by with the MCAM. They can also be used to load and save data from all the micro-cameras in the array with a single function call. This avoids the need to write many of the loops involved in loading and saving the large datasets.

As an added bonus, they can also be used to lazily-load the data, allowing one to analyze image data-sets that are much larger than the system’s available RAM.

Setting up a Samba Drive on the MCAM computer

The MCAM computer can be configured to act as a Samba server. This allows one to access the data on the MCAM computer from other devices on the network. This is a useful feature if you want to access the data from a Windows computer or from an automated data pipeline.

It is recommended to always connect the MCAM computer to the networking using the same port on the MCAM Computer. Different ports are often treated differently by the network administrators.

We provide these instructions for convenience without any guarantee of security. Please consult your network administrator for best security practices.

  1. Install samba

sudo apt update
sudo apt install samba
  1. Create directory for Samba share. This step can typically be skipped for Ramona Optics supplied computers since this directory will already exist.

mkdir -p /MCAM_data
echo The current User and Group are: "${USER}:$(groups | cut -d ' ' -f 1)"
echo /MCAM_data reports that the current user and group are $(stat -c '%U:%G' /MCAM_data)
sudo chown -R ramona:ramona /MCAM_data
  1. Edit Samba config and list the created /MCAM_data directory

sudo nano /etc/samba/smb.conf

and add the following to the bottom

[MCAM_data]
    comment = MCAM Data Drive
    path = /MCAM_data
    read only = no
    browsable = yes
    public = yes
    create mask = 0660
    directory mask = 0770
    force user = ramona
  1. Restart Samba service for the changes to take effect

sudo service smbd restart
  1. Update firewall rules

sudo ufw allow samba

You should also verify locally that this setup was successful by trying to connect to the local samba server with the MCAM computer’s file browser. The Samba server can be reached by specifying the following below location in the file browser. The browser should show the same files that are available in the /MCAM_data directory.

smb://localhost/MCAM_data
  1. Settings up a password for login. Your network security policies will disallow anonymous login to Samba servers. In this case, you will need to setup a password to enable the ramona user to access the samba server. This password is typically unrelated to the login username and password. Without setting this password, most clients will attempt to fallback to passwordless (or anonymous) login. To change the password to the samba use the command

sudo smbpasswd -a ramona

Connecting to Samba server from Windows

  1. Open File Explorer from the taskbar or by pressing the Windows logo key + E.

  2. Select This PC from the left pane. Then, on the File Explorer ribbon, select More > Map Network Drive.

  3. Pick a letter and enter \\<ip-address>\MCAM_data in the Map Network Drive dialog

Map Network Drive Dialog

If guest / anonymous access is disabled by your organization, connect using credentials.

This is the same username and password that you use to log into the MCAM computer.

Map Network Drive Credentials Dialog
  1. The drive should now be listed in This PC

Drive mapped to Y in This PC explorer on windows

Connecting to Samba server from Linux

  1. Connect to SMB server

sudo apt install smbclient
  1. In the file explorer type Ctrl + L and enter

smb://<ip.address>/MCAM_data

Creating a persistent mount to the Samba server from Linux

  1. Connect to SMB server and input your credentials when prompted.

This will save them into Gnome Keyring for future use.

nautilus file explorer smb connection save credentials prompt in nautilus file explorer
  1. Open “Startup Applications Preferences” from the application menu

  2. Click on “Add”

  3. In the command field, enter the following command replacing the server IP and share information with your own

gio mount smb://<ip.address>/<share_path>
adding a startup application command to mount a samba share

Data Management Tips

As with any imaging device, the MCAM generates a large amount of data. Here we outline 5 different techniques that you can use to manage your data.

Empty the Trash Bin

Often, many files are left over in the trash bin. Its always good to check if anything is in there and pruge it periodically. To have this done automatically, you can open the File History & Trash settings in Ubuntu and set the trash bin to empty automatically as shown in the image below.

Empty Trash Automatically in Ubuntu

Visualize What Files are the Largest

Often focusing on the largest files can have the most benefit. During the exploration phase of using a new imaging device, it is often useful to experiment with different imaging parameters until the most appropriate one is found. This can lead to a large number of files being generated. To find the largest files, we recommend you use the Disk Usage Analyzer tool that is included with Ubuntu. This tool will allow you to quickly identify the largest using some neat visualizations. To start, press on the Ubuntu Logo on the lower left hand corner of the screen and type in Disk Usage Analyzer. Press enter to start the application.

Disk Usage Analyzer Icon in Ubuntu

Once the application is started, you will want to scan a custom folder. You’ll want to scan the /MCAM_data folder as this is where the high performance SSD is typically mounted.

Disk Usage Analyzer Results for /MCAM_data

The pie chart visualization can be useful to quickly identify the largest folders. In the example above, we can see that that there is a large amount of data being used by a user called James. You can click on any part of the pie chart to focus the visualization on that folder. To open the folder externally, right click on the portion of the Pie Chart of interest and select Open Externally.

Disk Usage Analyzer Open Externally Menu Option

You can use this to identify and delete any data that is no longer relevant.

Compress Brightfield Video Datasets

While saving data in the .NC format is useful for preserving the raw data, brightfield video data acquired for behavioral analysis can be readily compressed. In fact, our 8 keypoint tracking algorithm works best with compressed brightfield data. To compress your video data, follow the instructions laid out in our MCAM Workflows Manual <./pdfs/MCAM Workflows Manual.pdf>. Typically, we’ve found that a 10-20x compression factor can be obtained!!!!

Delete Unnecessary Data From Well Plate Acquisitions

When volumetric scans are acquired with the MCAM and saved with the TIFF format, individual images can be deleted from the acquisition. Delete any wells that are not needed (often these are wells that are completely empty!!!!). For example, if a scan of a 96 well plate does not contain the wells in the outer perimeter (36 wells!!), this can accumulate to an extra 37% of data that is not needed. This can be done by using the nautilus file browser that is included with Ubuntu.

Navigate to where you saved your acquisition, and simply start typing to search for images that are not needed. For example, to delete all of row A, you can search for well_A and you will find all of the images that are in row A. Once you are in the directory of the acquisition just type well_A. You can then select all the images and delete them. This can be repeated for as many rows or columns that you wish to delete.

Use a Network Attached Storage

All MCAM Acquisition workstations are equipped with at least 4 TB of usable high performance storage. However, this can be easily exceeded once multiple users start to use the system for their experiments. In this case, we recommend using a Network Attached Storage (NAS) to store the data. We recommend at least 20 TB of redundant storage. This can be accomplished with a 4 bay NAS with 8~TB drives in a RAID 5 configuration. For users that expect to generate a large amount of data, we recommend a 8 bay NAS with 16 TB drives. Depending on the RAID configuration, this can provide up to 96 TB of redundant storage.

We recommend that the NAS be configured to share the data using the SMB protocol. We recommend users refer to Creating a persistent mount to the Samba server from Linux to learn how to mount the NAS on the MCAM computer.