Skip to content

poreflow.io.annotations

Annotation

Bases: File

has_events property

Checks if events are stored in on disk.

Returns:

Name Type Description
bool bool

True if events dataset exists in annotation, False otherwise.

has_ios property

Checks if the file contains open state current fit data.

Returns:

Name Type Description
bool bool

True if steps dataset exists in annotation, False otherwise.

has_steps property

Checks if the file contains steps.

Returns:

Name Type Description
bool bool

True if steps dataset exists in annotation, False otherwise.

ios_degree property

Order of the open state fits stored in the table

ios_n_coef property

Number of open state fit coefficients in the table

ios_table property

Retrieves the polynomial coefficients for the open state current fits on disk.

Retrieves the open state currents, expressed as a polynomial of degree N, on disk. The returned table is N x M table, where M is the number of channels. This table contains the coefficients of the polynomial of the open state fit of the various channels of the measurement.

Returns:

Type Description
DataFrame | None

pd.DataFrame: DataFrame containing open state current polynomial fits for each channel. None if no data on disk.

New(fname, describes) classmethod

Construct a new annotation.

Parameters:

Name Type Description Default
fname PathLike
required
describes PathLike

Must be just the filename, annotation is supposed to be next to the file.

required

__init__(fname, mode='r+', **kwargs)

Parameters:

Name Type Description Default
fname
required
mode
'r+'
**kwargs
{}

get_events()

Reads events from disk.

Returns:

Type Description
DataFrame | None

pandas.DataFrame: DataFrame containing events.

get_ios(channel=0)

Gets the polynomial fit of a channel's open state current fit

Parameters:

Name Type Description Default
channel int

Which channel to retrieve the open state fit for. Defaults to 0.

0

Returns:

Type Description
Polynomial | None

np.polynomial.Polynomial: Polynomial describing open state current polynomial fits for a channel.

get_steps()

Reads events from disk.

Returns:

Type Description
DataFrame | None

pf.StepsDataFrame: DataFrame containing events.

remove_events(channels=None, events=None, include_steps=True)

Removes events from specific channels or all events.

Parameters:

Name Type Description Default
include_steps
True
events int | list[int] | None
None
channels int | list[int] | None
  • If int: Remove events from the specified channel only.
  • If list[int]: Remove events from the specified channels.
  • If None: Remove all events from all channels.
None
include_ios bool

Whether to also delete the ios fit for the specified channels.

required

Returns:

Type Description
None

None

Todo: Docs

remove_ios(channels=None)

Removes open state current fits from specific channels or all channels.

Instead of deleting the entries, sets the polynomial coefficients to NaN to preserve the dataset structure.

Parameters:

Name Type Description Default
channels int | list[int] | None
  • If int: Remove IOS fit from the specified channel only.
  • If list[int]: Remove IOS fits from the specified channels.
  • If None: Remove IOS fits from all channels.
None

Returns:

Type Description
None

None

set_events(df_events, mode='w')

Saves events to disk.

Parameters:

Name Type Description Default
df_events DataFrame

Events to save. Set None to delete all events store on disk.

required
mode str

Whether to replace ('w') or append ('a') to existing events on disk.

'w'

set_ios(p, channel=0)

Stores the open state current for a channel on disk.

Stores the open state current, expressed as a polynomial of degree N, on disk. Creates an N x M array on disk, where M is the number of channels and stores the coefficients of the polynomial in this table.

Parameters:

Name Type Description Default
p Polynomial

A polynomial describing the open state current for a channel.

required
channel int

Which channel the polynomial describes.

0
Todo

Raise an error if the existing table if for a different degree than the input polynomial p.

set_steps(df_steps, mode='w')

Saves steps to disk.

Parameters:

Name Type Description Default
df_steps StepsDataFrame

Steps to save. Set None to delete all events store on disk.

required
mode str

Whether to replace ('w') or append ('a') to existing steps on disk.

'w'

get_default_annotations_filename(fname)

Gets the default annotation filename for a data file.

Parameters:

Name Type Description Default
fname str | PathLike

Data file path.

required

Returns:

Type Description
Path

pathlib.Path: Default annotation file path.

get_stem(fname)

Get stem twice to remove double extensions.

Parameters:

Name Type Description Default
fname str

File path to process.

required

Returns:

Name Type Description
str str

File stem with double extensions removed.

is_annotation(fname)

Checks if a file is an annotation file.

Parameters:

Name Type Description Default
fname str | PathLike

File path to check.

required

Returns:

Name Type Description
bool bool

True if the file has the annotation file extension.

with_suffix(fname, ext=None)

Adds or replaces file extension.

Parameters:

Name Type Description Default
fname str

Original file path.

required
ext str

Extension to use. Defaults to annotation extension.

None

Returns:

Type Description
Path

pathlib.Path: Path with new extension.