allensdk.brain_observatory.data_release_utils.metadata_utils.utils module

allensdk.brain_observatory.data_release_utils.metadata_utils.utils.add_file_paths_to_metadata_table(metadata_table: DataFrame, id_generator: FileIDGenerator, file_dir: Path, file_prefix: str | None, index_col: str, data_dir_col: str | None, on_missing_file: str, file_suffix: str = 'nwb', file_stem: str | None = None) DataFrame[source]

Add file_id and file_path columns to session dataframe.

Parameters:
metadata_table: pd.DataFrame

The dataframe to which we are adding file_id and file_path

id_generator: FileIDGenerator

For maintaining a unique mapping between file_path and file_id

file_dir: pathlib.Path

directory where files will be found

file_prefix: str

Prefix of file names

index_col: str

Column in metadata_table used to index files

data_dir_col

Column in metadata_table denoting directory structure of data For example if data is stored under each session_id

<session_id> / file_a <session_id> / file_b …

then give the name of the session_id col here

If None, data is assumed to be stored flat

on_missing_file: str
Specifies how to handle missing files

‘error’ -> raise an exception ‘warning’ -> assign dummy file_id and warn ‘skip’ -> drop that row from the table and warn

file_suffix
file_stem

Explicit file stem. Overrides dynamic naming of files

Returns:
metadata_table:

The same as the input dataframe but with file_id and file_path columns added

Notes

Files are assumed to be named like {file_dir}/{file_prefix}_{metadata_table.index_col}.{file_suffix}