io#

utils.io.get_coord_list(raw: mne_io.BaseRaw) tuple[list, list] | tuple[None, None][source]#

Return the coordinate list and names from mne RawArray

Parameters:

raw (mne_io.BaseRaw)

Return type:

coord_list[list, list] | coord_names[None, None]

utils.io.get_paths_example_data()[source]#

This function should provide RUN_NAME, PATH_RUN, PATH_BIDS, PATH_OUT and datatype for the example dataset used in most examples.

utils.io.load_channels(channels: pd.DataFrame | _PathLike) pd.DataFrame[source]#

Read channels from path or specify via BIDS arguments. Necessary parameters are then ch_names (list), ch_types (list), bads (list), used_types (list), target_keywords (list) and reference Union[list, str].

utils.io.loadmat(filename) dict[source]#

this function should be called instead of direct spio.loadmat as it cures the problem of not properly recovering python dictionaries from mat files. It calls the function check keys to cure all entries which are still mat-objects

utils.io.read_BIDS_data(PATH_RUN: _PathLike | BIDSPath, line_noise: int = 50) tuple[mne_io.Raw, ndarray, float, int, list | None, list | None][source]#

Given a run path and bids data path, read the respective data

Parameters:
Returns:

  • raw_arr (mne.io.RawArray)

  • raw_arr_data (np.ndarray)

  • sfreq (float)

  • line_noise (int)

  • coord_list (list | None)

  • coord_names (list | None)

utils.io.read_grid(PATH_GRIDS: str | PathLike | None, grid_str: str) pd.DataFrame[source]#

Read grid file from path or PYNM_DIR

Parameters:
  • PATH_GRIDS (_PathLike | None) – path to grid file, by default None

  • grid_str (str) – grid name

Returns:

pd.DataFrame including mni x,y,z coordinates for each grid point

Return type:

pd.DataFrame

utils.io.read_mne_data(PATH_RUN: _PathLike | BIDSPath, line_noise: int = 50)[source]#

Read data in the mne.io.read_raw supported format.

Parameters:
Returns:

  • raw (mne.io.Raw)

  • sfreq (float)

  • ch_names (list[str])

  • ch_type (list[str])

  • bads (list[str])

utils.io.write_csv(df, path_out)[source]#

Function to save Pandas dataframes to disk as CSV using PyArrow (almost 10x faster than Pandas) Difference with pandas.df.to_csv() is that it does not write an index column by default