ada.io.file_manager — ADA 1.0.3 documentation

Skip to main content
`Ctrl`+`K`

# ada.io.file_manager

## Classes

`FileManager` | A collection of methods facilitating IO operations. Recommended way to perform IO.

## Functions

`main`() | A script for batch converting actigraphic files into the .ada format. Use with -h or --help for details.

## Module Contents

class FileManager

  A collection of methods facilitating IO operations. Recommended way to perform IO.

  static export_generic(path, data, verbose=True)

    Export given actigraphic data object to generic format (convert if necessary).

    Parameters:

      - path (str) – Path to the output file.

      - data (_ActiData) – Actigraphic data to be exported.

      - verbose (bool, optional) – Whether to print out exporting progress. Defaults to True.

  static load_ActiPSG_from_tags(path_to_acti, path_to_tag, path_to_xml, collapse_stages=True, trim_to_eeg=False, verbose=True)

    Load corresponding PSG tags and actigraphic data, and create synchronized ActiPSG container. It is highly recommended to use raw actigraphic data here, and epoch whole object using chosen Epocher.to_epoch() method, because syncrhonization of PSG and actigraphy can always be off by 1 sample. synchronize_recordings.py first, and then run this function on exported and trimmed actigraphic data if you want to epoch separately.

    Parameters:

      - path_to_acti (str) – Path to file with actigraphic data.

      - path_to_tag (str) – Path to .tag with PSG tags formatted in obci format.

      - path_to_xml (str) – Path to .xml with metadata about PSG formatted in obci format.

      - collapse_stages (bool | Callable, optional) – Whether to collapse hypnogram into sleep/wake classification using built-in heuristic. To use different heuristic pass the function(str) -> int as an argument. Defaults to True.

      - trim_to_eeg (bool, optional) – When True, actigraphy will be trimmed to match start and end of PSG. When False, PSG will be extended using wake epochs to match actigraphy start and end. Defaults to False.

      - verbose (bool, optional) – Whether to print out loading progress. Defaults to True.

    Returns:

      Object containing synchronized actigraphic and PSG data.

    Return type:

      ActiPSG

  static load_file(path, verbose=True)

    Load actigraphic data from given file. Detects format form all known to ada automatically.

    Parameters:

      - path (str) – Path to the file.

      - verbose (bool, optional) – Whether to print out loading progress. Defaults to True.

    Raises:

      ValueError – File extension cannot be handled properly.

    Returns:

      Object containing data from file.

  static preview_metadata(path)

    Preview metadata of a file without loading whole content.

    Parameters:

      path (str) – Path to a file.

    Raises:

      ValueError – If a file is MESA .csv or generic .csv (not supported)

    Returns:

      Dictionary with metadata and list with channel names.

    Return type:

      tuple[dict, list]

  static save_csv(path, acti_data, verbose=True)

    Save actigraphic data to a generic .csv, readable by FileManager and human-friendly formatted.

    Parameters:

      - path (str) – Path to the .csv output file.

      - acti_data (_ActiData) – Object to be exported as .csv.

      - verbose (bool, optional) – Whether to print out loading progress. Defaults to True.

main()

  A script for batch converting actigraphic files into the .ada format. Use with -h or –help for details.