cedalion.io.probe_geometry

Module for reading and writing probe geometry files.

Functions

export_to_tsv(tsv_filename, points)

Export optodes, fiducials, landmarks, electrodes, or measurement lists to tsv.

load_tsv(tsv_fname[, crs, units])

Load a tsv file containing optodes or landmarks.

read_digpts(fname[, units])

Read a file containing digitized 3D points.

read_einstar_obj(fname)

Read a textured triangle mesh generated by Einstar 3D scanners.

read_fieldtrip_elc(fname)

Read electrode positions from a FieldTrip .elc file.

read_mrk_json(fname, crs)

Read a JSON file containing landmarks (3D Slicer .mrk.json format).

read_sd(fname[, crs])

Read optode positions from a Homer/AtlasViewer .mat SD file.

save_mrk_json(fname, landmarks, crs)

Save landmarks to a 3D Slicer .mrk.json file.

cedalion.io.probe_geometry.load_tsv(
tsv_fname: str,
crs: str = None,
units: str = None,
) DataArray[source]

Load a tsv file containing optodes or landmarks.

This function reads tsv-files with a column layout that differs from the NIRS-BIDS standard.

Parameters:
  • tsv_fname – Path to the tsv file.

  • crs – Coordinate reference system of the points if not in the file header.

  • units – Units of the points if not in the file header.

Returns:

xr.DataArray containing the optodes or landmarks with label, type, and positional dimensions.

cedalion.io.probe_geometry.export_to_tsv(tsv_filename, points)[source]

Export optodes, fiducials, landmarks, electrodes, or measurement lists to tsv.

This function writes tsv-files with a column layout that differs from the NIRS-BIDS standard.

Parameters:
  • tsv_filename – Path to the output tsv file.

  • points – Points to save. Either an xr.DataArray (optodes / landmarks / electrodes) or a pd.DataFrame (measurement list).

cedalion.io.probe_geometry.read_mrk_json(fname: str, crs: str) DataArray[source]

Read a JSON file containing landmarks (3D Slicer .mrk.json format).

Parameters:
  • fname – Path to the JSON file.

  • crs – Coordinate reference system of the landmarks.

Returns:

xr.DataArray containing landmark positions with label and type coordinates, quantified with pint units.

cedalion.io.probe_geometry.save_mrk_json(fname: str, landmarks: DataArray, crs: str)[source]

Save landmarks to a 3D Slicer .mrk.json file.

Parameters:
  • fname – Path to the output JSON file.

  • landmarks – Landmark positions as an xr.DataArray with label coordinate.

  • crs – Coordinate reference system name to embed in the file.

cedalion.io.probe_geometry.read_digpts(fname: str, units: str = 'mm') DataArray[source]

Read a file containing digitized 3D points.

Each line must have the format label: x y z.

Parameters:
  • fname – Path to the digitized-points file.

  • units – Physical units of the coordinates (default: "mm").

Returns:

xr.DataArray with dimensions ["label", "pos"], quantified with pint units.

cedalion.io.probe_geometry.read_einstar_obj(fname: str) TrimeshSurface[source]

Read a textured triangle mesh generated by Einstar 3D scanners.

Parameters:

fname – Path to the .obj mesh file.

Returns:

TrimeshSurface in the "digitized" CRS with millimetre units.

cedalion.io.probe_geometry.read_fieldtrip_elc(
fname: Path | str,
) Annotated[DataArray, DataArraySchema(dims='label', coords='label', 'label', 'type')][source]

Read electrode positions from a FieldTrip .elc file.

Parameters:

fname – Path to the .elc file.

Returns:

LabeledPoints with electrode positions, label and type coordinates, and pint units derived from the file header.

cedalion.io.probe_geometry.read_sd(
fname: Path | str,
crs='av',
) Annotated[DataArray, DataArraySchema(dims='label', coords='label', 'label', 'type')][source]

Read optode positions from a Homer/AtlasViewer .mat SD file.

Parameters:
  • fname – Path to the .mat SD file.

  • crs – Coordinate reference system label to assign (default: "av").

Returns:

LabeledPoints with source, detector, and landmark positions.