read_table#

crispy.grid_ridge.read_table(fname, useDict=False)[source]#

Read filament skeleton data from a file.

Reads the skeleton coordinates identified by the SCMS algorithm from a text file. It can return the data as either a NumPy array or a dictionary, depending on the user’s preference.

Parameters:
  • fname (str) – Path to the text file containing the skeleton data.

  • useDict (bool, optional, default=False) – If True, returns the skeleton data as a dictionary with coordinate labels (‘xind, yind, zind’ for 3D or ‘xind, yind’ for 2D). Otherwise, returns a NumPy array.

Returns:

  • If useDict is False: A NumPy array containing the skeleton coordinates.

  • If useDict is True: A dictionary with labeled coordinates.

Return type:

ndarray or dict

Notes

  • The skeleton file is expected to have columns representing coordinate indices.

  • If the data is 3D, the dictionary keys will be ‘xind, yind, zind’.

  • For 2D data, the dictionary keys will be ‘xind, yind’.

Examples

Read skeleton data as a NumPy array:

>>> from crispy import grid_ridge
>>> data = grid_ridge.read_table("skeleton_data.txt")
>>> print(data.shape)

Read skeleton data as a dictionary:

>>> data_dict = grid_ridge.read_table("skeleton_data.txt", useDict=True)
>>> print(data_dict.keys())