Skip to content

Uncertainty Regarding Output Structure of MAP-tracks in BNP-Track Analysis #5

@Michael-shannon

Description

@Michael-shannon

Hiya!

I am using the BNP-Track tool and analyzing the output MAT file, with the goal of importing it to a pandas dataframe to continue in python, with the goal of comparing to my existing tracking workflow. I see the clear benefits based on your benchmarking in the paper.

Having generated the MAP-track file and exported it from the GUI, I see that the .mat file contains several variables including t (time), X, Y, and Z. Three things are unclear to me:

  1. What the Z variable represents and how I should handle it. From the paper, its seems like for 2D data like mine, the Z might be an estimated axial position based on shape of the PSF. Is that right and if so, should I apply some filter to remove totally out of focus points, or should I keep them in as tracks? Or alternatively, should I estimate some measure of uncertainty from this Z coordinate, and filter the data based on that?

  2. If the rows of the X, Y and Z variables represent the timepoint (which I suspect they do) then why do all of the tracks have the same (full) number of elements and therefore the same length? Each point seems to be registered in every frame, which is unexpected for me in heterogeneous single-particle tracking (SPT) data, particularly in a small region of interest (ROI) within a cell. Is this because the data has not been filtered/thresholded as per (1)?

  3. There are always 25 columns in each of X, Y and Z, no matter what data I process. I presume the different columns represent different particle tracks, but its strange that there are always the same number. Could it be that there is some arbitrary limit for this, or am I doing something wrong in my mat to pandas function in python? (below).

`def mat_to_pandas(file_path):
mat = scipy.io.loadmat(file_path)

# Extract the relevant data fields
x_data = mat['X']
y_data = mat['Y']
z_data = mat['Z']
time_data = mat['t'].flatten()

# Initialize an empty list to collect data rows
data_rows = []

# Iterate over each frame
for frame_idx, time_value in enumerate(time_data):
    for particle_idx in range(x_data.shape[1]):  # Loop over each particle
        
        # Extract x, y, and z positions
        x_pos = x_data[frame_idx, particle_idx]
        y_pos = y_data[frame_idx, particle_idx]
        z_pos = z_data[frame_idx, particle_idx]
        
        # Only include valid data (non-NaN or non-placeholder values)
        if not np.isnan(x_pos) and not np.isnan(y_pos):  # Assuming NaN means not tracked
            data_rows.append({
                'x_um': x_pos,
                'y_um': y_pos,
                'z': z_pos,
                'time_s': time_value,
                'particle': particle_idx + 1  # Assign particle ID
            })

# Convert list of rows into a DataFrame
df = pd.DataFrame(data_rows)

return df`

Thanks for anything you can help me with!

p.s. Although I was unable to attend SMLMS this year, I discovered BNP-track through it - it looks like a very promising tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions