geff.convert
_dataframes_to_memory_geff
_dataframes_to_memory_geff(
node_df: DataFrame,
edge_df: DataFrame,
directed: bool = True,
node_id_col: str = "id",
edge_source_col: str = "source",
edge_target_col: str = "target",
) -> InMemoryGeff
Convert pandas DataFrames to an InMemoryGeff representation.
Takes a node DataFrame and an edge DataFrame and converts them into the InMemoryGeff dict format. Missing values (NaN/None) are handled via boolean missing masks with correct dtypes preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_df
|
DataFrame
|
DataFrame with node data. Must contain a node ID column and any number of property columns. |
required |
edge_df
|
DataFrame
|
DataFrame with edge data. Must contain source and target ID columns and any number of property columns. |
required |
directed
|
bool
|
Whether the graph is directed. Defaults to True. |
True
|
node_id_col
|
str
|
Name of the node ID column in node_df. Defaults to "id". |
'id'
|
edge_source_col
|
str
|
Name of the source node column in edge_df. Defaults to "source". |
'source'
|
edge_target_col
|
str
|
Name of the target node column in edge_df. Defaults to "target". |
'target'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If node_df is missing the node_id_col column, or edge_df is missing the edge_source_col or edge_target_col columns. |
Returns:
| Name | Type | Description |
|---|---|---|
InMemoryGeff |
InMemoryGeff
|
A dict with metadata, node_ids, edge_ids, node_props, and edge_props. |
csv_to_geff
csv_to_geff(
node_csv: Path | str,
edge_csv: Path | str,
store: StoreLike,
directed: bool = True,
node_id_col: str = "id",
edge_source_col: str = "source",
edge_target_col: str = "target",
zarr_format: Literal[2, 3] = 2,
) -> None
Convert node and edge CSV files to a geff store.
The CSVs are expected to have a header row.
The node CSV must contain a column with node IDs (default "id"). All other
columns are stored as node properties. The edge CSV must contain columns for
source and target node IDs (default "source" and "target"). All other columns
are stored as edge properties. Missing values (empty cells / NaN) are recorded
in the GEFF missing mask. Columns starting with "Unnamed:" are ignored (e.g.
pandas index columns written by df.to_csv()).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_csv
|
Path | str
|
Path to the node CSV file. |
required |
edge_csv
|
Path | str
|
Path to the edge CSV file. |
required |
store
|
StoreLike
|
The zarr store to write to. |
required |
directed
|
bool
|
Whether the graph is directed. Defaults to True. |
True
|
node_id_col
|
str
|
Name of the node ID column in the node CSV. Defaults to "id". |
'id'
|
edge_source_col
|
str
|
Name of the source node column in the edge CSV. Defaults to "source". |
'source'
|
edge_target_col
|
str
|
Name of the target node column in the edge CSV. Defaults to "target". |
'target'
|
zarr_format
|
Literal[2, 3]
|
The zarr specification to use when writing. Defaults to 2. |
2
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If required columns are missing from the CSVs. |
ctc_tiffs_to_zarr
ctc_tiffs_to_zarr(
ctc_path: Path,
output_store: StoreLike,
ctzyx: bool = False,
overwrite: bool = False,
zarr_format: Literal[2, 3] = 2,
) -> None
Convert a CTC file to a Zarr file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctc_path
|
Path
|
The path to the CTC file. |
required |
output_store
|
StoreLike
|
The path to the Zarr file. |
required |
ctzyx
|
(optional, bool)
|
Expand data to make it (T, C, Z, Y, X) otherwise it's (T,) + Frame shape. Defaults to False. |
False
|
overwrite
|
(optional, bool)
|
Whether to overwrite the Zarr file if it already exists. Defaults to False. |
False
|
zarr_format
|
(optional, Literal[2, 3])
|
The zarr specification to use when writing the zarr. Defaults to 2. |
2
|
dataframes_to_geff
dataframes_to_geff(
node_df: DataFrame,
edge_df: DataFrame,
store: StoreLike,
directed: bool = True,
node_id_col: str = "id",
edge_source_col: str = "source",
edge_target_col: str = "target",
zarr_format: Literal[2, 3] = 2,
) -> None
Convert node and edge pandas DataFrames to a geff store.
The node DataFrame must contain a column with node IDs (default "id"). All other columns are stored as node properties. The edge DataFrame must contain columns for source and target node IDs (default "source" and "target"). All other columns are stored as edge properties. NaN values are considered missing and are recorded in the GEFF missing mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_df
|
DataFrame
|
DataFrame with node data. Must contain a node ID column and any number of property columns. |
required |
edge_df
|
DataFrame
|
DataFrame with edge data. Must contain source and target ID columns and any number of property columns. |
required |
store
|
StoreLike
|
The zarr store to write to. |
required |
directed
|
bool
|
Whether the graph is directed. Defaults to True. |
True
|
node_id_col
|
str
|
Name of the node ID column in node_df. Defaults to "id". |
'id'
|
edge_source_col
|
str
|
Name of the source node column in edge_df. Defaults to "source". |
'source'
|
edge_target_col
|
str
|
Name of the target node column in edge_df. Defaults to "target". |
'target'
|
zarr_format
|
Literal[2, 3]
|
The zarr specification to use when writing. Defaults to 2. |
2
|
from_ctc_to_geff
from_ctc_to_geff(
ctc_path: Path,
geff_path: Path,
segmentation_store: StoreLike | None = None,
tczyx: bool = False,
overwrite: bool = False,
zarr_format: Literal[2, 3] = 2,
) -> None
Convert a CTC file to a GEFF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctc_path
|
Path
|
The path to the CTC file. |
required |
geff_path
|
Path
|
The path to the GEFF file. |
required |
segmentation_store
|
StoreLike | None
|
The path or store to save the segmentation to. If not provided, it won't be exported. |
None
|
tczyx
|
bool
|
Expand data to make it (T, C, Z, Y, X) otherwise it's (T,) + Frame shape. |
False
|
overwrite
|
bool
|
Whether to overwrite the GEFF file if it already exists. |
False
|
zarr_format
|
Literal[2, 3]
|
The zarr specification to use when writing the zarr. Defaults to 2. |
2
|
from_trackmate_xml_to_geff
from_trackmate_xml_to_geff(
xml_path: Path | str,
geff_path: Path | str,
discard_filtered_spots: bool = False,
discard_filtered_tracks: bool = False,
overwrite: bool = False,
zarr_format: Literal[2, 3] = 2,
) -> None
Convert a TrackMate XML file to a GEFF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_path
|
Path | str
|
The path to the TrackMate XML file. |
required |
geff_path
|
Path | str
|
The path to the GEFF file. |
required |
discard_filtered_spots
|
bool
|
True to discard the spots filtered out in TrackMate, False otherwise. False by default. |
False
|
discard_filtered_tracks
|
bool
|
True to discard the tracks filtered out in TrackMate, False otherwise. False by default. |
False
|
overwrite
|
bool
|
Whether to overwrite the GEFF file if it already exists. |
False
|
zarr_format
|
Literal[2, 3]
|
The version of zarr to write. Defaults to 2. |
2
|
Warns:
| Type | Description |
|---|---|
UserWarning
|
If the XML file does not contain specific metadata tags or if there are issues with the TrackMate metadata. |
geff_to_csv
geff_to_csv(
store: StoreLike,
outpath: Path | str,
overwrite: bool = False,
) -> None
Convert a geff store to two csvs of nodes and edges
Properties with more than 2 dimensions cannot be exported and will be skipped. Properties with two dimensions where the second dimension is > 1 will be unpacked into separate columns with the name "{prop_name}_{dim_index}"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
StoreLike
|
Path to store or StoreLike object |
required |
outpath
|
Path | str
|
Path to save output csvs. Any file extension will be stripped and replaced with "-nodes.csv" and "-edges.csv" |
required |
overwrite
|
bool
|
If true, existing csvs will be overwritten |
False
|
geff_to_dataframes
geff_to_dataframes(
store: StoreLike,
) -> tuple[pd.DataFrame, pd.DataFrame]
Convert a GEFF store to a pandas DataFrame.
Properties with more than 2 dimensions cannot be converted and will be skipped. Properties with two dimensions where the second dimension is > 1 will be unpacked into separate columns with the name "{prop_name}_{dim_index}"
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
StoreLike
|
The store to convert. |
required |
Returns:
| Type | Description |
|---|---|
tuple[DataFrame, DataFrame]
|
tuple[pd.DataFrame, pd.DataFrame]: The nodes and edges dataframes. |