### Install BioPsyKit with Extras Source: https://biopsykit.readthedocs.io/en/latest/README.html Clone the repository and install BioPsyKit with additional dependencies for MNE and Jupyter notebooks using poetry. ```bash git clone https://github.com/mad-lab-fau/BioPsyKit.git cd BioPsyKit poetry install -E mne -E jupyter ``` -------------------------------- ### Setup Jupyter Kernel with Poetry Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Install the project and register a new IPython kernel named 'biopsykit' using poetry. ```bash # poetry install including root! poetry install poetry run poe register_ipykernel ``` -------------------------------- ### get_questionnaire_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example questionnaire. ```APIDOC ## get_questionnaire_example() ### Description Retrieves an example questionnaire. ### Module biopsykit.example_data ``` -------------------------------- ### Install BioPsyKit without Extras Source: https://biopsykit.readthedocs.io/en/latest/README.html Clone the repository and install BioPsyKit with its core dependencies using poetry. ```bash git clone https://github.com/mad-lab-fau/BioPsyKit.git cd BioPsyKit poetry install ``` -------------------------------- ### Install BioPsyKit from Local Repository Source: https://biopsykit.readthedocs.io/en/latest/README.html Installs BioPsyKit from a local copy of the repository. This is useful for development or when working with a specific version cloned from GitHub. ```bash git clone https://github.com/mad-lab-fau/BioPsyKit.git cd BioPsyKit pip install . ``` -------------------------------- ### Load example data with biopsykit Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Import and load example data, such as sleep IMU data, using helper functions from biopsykit.example_data. ```python from biopsykit.example_data import get_sleep_imu_example data, fs = get_sleep_imu_example() ``` -------------------------------- ### get_time_log_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example time log. ```APIDOC ## get_time_log_example() ### Description Retrieves an example time log. ### Module biopsykit.example_data ``` -------------------------------- ### get_saliva_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example saliva data file. ```APIDOC ## get_saliva_example() ### Description Retrieves an example saliva data file. ### Module biopsykit.example_data ``` -------------------------------- ### get_stats_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example statistical data. ```APIDOC ## get_stats_example() ### Description Retrieves an example statistical data. ### Module biopsykit.example_data ``` -------------------------------- ### get_sleep_analyzer_summary_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example summary from the Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_summary_example() ### Description Retrieves an example summary from the Sleep Analyzer. ### Module biopsykit.example_data ``` -------------------------------- ### biopsykit.example_data.get_saliva_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return saliva example data. ```APIDOC ## biopsykit.example_data.get_saliva_example ### Description Return saliva example data. ### Parameters - **sample_times** (_list_ _of_ _int_ _,__optional_) – sample times of saliva samples in minutes ### Returns - dataframe with example raw saliva data ### Return type `SalivaRawDataFrame` ``` -------------------------------- ### get_ecg_path_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Provides an example file path for ECG data. ```APIDOC ## get_ecg_path_example() ### Description Provides an example file path for ECG data. ### Module biopsykit.example_data ``` -------------------------------- ### Install BioPsyKit Dependencies with Poetry Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Use Poetry to install all development dependencies for BioPsyKit. This command creates a virtual environment and installs necessary packages. ```bash poetry install ``` -------------------------------- ### Install BioPsyKit via Pip Source: https://biopsykit.readthedocs.io/en/latest/README.html Installs the BioPsyKit library using pip. This is the standard method for installing Python packages. ```bash pip install biopsykit ``` -------------------------------- ### FibionDataset.start_time_unix Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.fibion.html Get the start time of the recording in UTC time. ```APIDOC ## property FibionDataset.start_time_unix ### Description Start time of the recording in UTC time. ### Return Type pandas._libs.tslibs.timestamps.Timestamp | None ``` -------------------------------- ### Install poethepoet with Poetry Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Install poethepoet as a development dependency within your project's poetry environment. ```bash poetry add --dev poethepoet ``` -------------------------------- ### biopsykit.example_data.get_questionnaire_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return questionnaire example data. ```APIDOC ## biopsykit.example_data.get_questionnaire_example ### Description Return questionnaire example data. ### Returns - **data** – dataframe with questionnaire example data ### Return type `DataFrame` ``` -------------------------------- ### get_eeg_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example EEG (Electroencephalogram) data file. ```APIDOC ## get_eeg_example() ### Description Retrieves an example EEG (Electroencephalogram) data file. ### Module biopsykit.example_data ``` -------------------------------- ### Example Data Retrieval Functions Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.html The `biopsykit.example_data` module provides functions to retrieve example datasets for different physiological signals and questionnaire data. These functions are useful for testing, demonstration, and understanding the library's capabilities. ```APIDOC ## Module: biopsykit.example_data This module contains functions to load example data for various physiological signals and related information. ### Functions - **`get_condition_list_example()`** - Description: Retrieves an example list of conditions. - **`get_ecg_example()`** - Description: Retrieves an example ECG (Electrocardiogram) dataset. - **`get_ecg_example_02()`** - Description: Retrieves a second example ECG dataset. - **`get_ecg_path_example()`** - Description: Retrieves the file path to an example ECG dataset. - **`get_ecg_processing_results_path_example()`** - Description: Retrieves the file path to example ECG processing results. - **`get_eeg_example()`** - Description: Retrieves an example EEG (Electroencephalogram) dataset. - **`get_hr_ensemble_sample()`** - Description: Retrieves a sample HR (Heart Rate) ensemble. - **`get_hr_result_sample()`** - Description: Retrieves a sample HR result. - **`get_hr_subject_data_dict_example()`** - Description: Retrieves an example HR subject data as a dictionary. - **`get_hr_subject_data_dict_tuple_example()`** - Description: Retrieves an example HR subject data as a dictionary tuple. - **`get_mist_hr_example()`** - Description: Retrieves an example MIST HR dataset. - **`get_questionnaire_example()`** - Description: Retrieves an example questionnaire dataset. - **`get_questionnaire_example_wrong_range()`** - Description: Retrieves an example questionnaire dataset with a wrong range. - **`get_saliva_example()`** - Description: Retrieves an example saliva sample dataset. - **`get_saliva_example_plate_format()`** - Description: Retrieves an example saliva sample dataset in plate format. - **`get_saliva_mean_se_example()`** - Description: Retrieves an example of mean SE for saliva samples. - **`get_sleep_analyzer_raw_example()`** - Description: Retrieves an example raw dataset from the Sleep Analyzer. - **`get_sleep_analyzer_raw_file()`** - Description: Retrieves the file path to an example raw Sleep Analyzer dataset. - **`get_sleep_analyzer_raw_file_unformatted()`** - Description: Retrieves the file path to an unformatted example raw Sleep Analyzer dataset. - **`get_sleep_analyzer_summary_example()`** - Description: Retrieves an example summary dataset from the Sleep Analyzer. - **`get_sleep_imu_example()`** - Description: Retrieves an example IMU (Inertial Measurement Unit) dataset for sleep analysis. - **`get_stats_example()`** - Description: Retrieves an example statistics dataset. - **`get_time_log_example()`** - Description: Retrieves an example time log dataset. ``` -------------------------------- ### Install poethepoet globally Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Install poethepoet into your default Python environment to use it outside of a poetry shell. ```bash pip install poethepoet ``` -------------------------------- ### get_time_log_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example time log data. ```APIDOC ## get_time_log_example() ### Description Return time log example data. ### Returns - **data** – dataframe with example time log information. The time log match the data from the two ECG data example functions `get_ecg_example()` and `get_ecg_example_02()` ### Return type `DataFrame` ``` -------------------------------- ### get_ecg_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example ECG (Electrocardiogram) data file. ```APIDOC ## get_ecg_example() ### Description Retrieves an example ECG (Electrocardiogram) data file. ### Module biopsykit.example_data ``` -------------------------------- ### Configure and Fit Machine Learning Pipeline Source: https://biopsykit.readthedocs.io/en/latest/README.html This example demonstrates setting up and fitting a machine learning pipeline using BioPsyKit's SklearnPipelinePermuter, including various preprocessing steps, feature selection, and classifiers with hyperparameter tuning. ```python # Utils from sklearn.datasets import load_breast_cancer # Preprocessing & Feature Selection from sklearn.feature_selection import SelectKBest from sklearn.preprocessing import MinMaxScaler, StandardScaler # Classification from sklearn.neighbors import KNeighborsClassifier from sklearn.tree import DecisionTreeClassifier # Cross-Validation from sklearn.model_selection import KFold from biopsykit.classification.model_selection import SklearnPipelinePermuter # load example dataset breast_cancer = load_breast_cancer() X = breast_cancer.data y = breast_cancer.target # specify estimator combinations model_dict = { "scaler": { "StandardScaler": StandardScaler(), "MinMaxScaler": MinMaxScaler() }, "reduce_dim": { "SelectKBest": SelectKBest(), }, "clf": { "KNeighborsClassifier": KNeighborsClassifier(), "DecisionTreeClassifier": DecisionTreeClassifier(), } } # specify hyperparameter for grid search params_dict = { "StandardScaler": None, "MinMaxScaler": None, "SelectKBest": {"k": [2, 4, "all"]}, "KNeighborsClassifier": {"n_neighbors": [2, 4], "weights": ["uniform", "distance"]}, "DecisionTreeClassifier": {"criterion": ['gini', 'entropy'], "max_depth": [2, 4]}, } pipeline_permuter = SklearnPipelinePermuter(model_dict, params_dict) pipeline_permuter.fit(X, y, outer_cv=KFold(5), inner_cv=KFold(5)) # print summary of all relevant metrics for the best pipeline for each evaluated pipeline combination print(pipeline_permuter.metric_summary()) ``` -------------------------------- ### get_ecg_example_02() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves a second example ECG data file. ```APIDOC ## get_ecg_example_02() ### Description Retrieves a second example ECG data file. ### Module biopsykit.example_data ``` -------------------------------- ### get_mist_hr_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example of MIST heart rate data. ```APIDOC ## get_mist_hr_example() ### Description Retrieves an example of MIST heart rate data. ### Module biopsykit.example_data ``` -------------------------------- ### biopsykit.example_data Functions Source: https://biopsykit.readthedocs.io/en/latest/api/modules.html Functions for retrieving example datasets. ```APIDOC ## get_condition_list_example() ### Description Retrieves an example condition list. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_ecg_example() ### Description Retrieves an example ECG dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_ecg_example_02() ### Description Retrieves a second example ECG dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_ecg_path_example() ### Description Retrieves the file path for an example ECG dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_ecg_processing_results_path_example() ### Description Retrieves the file path for example ECG processing results. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_eeg_example() ### Description Retrieves an example EEG dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_hr_ensemble_sample() ### Description Retrieves a sample of heart rate ensemble data. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_hr_result_sample() ### Description Retrieves a sample of heart rate result data. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_hr_subject_data_dict_example() ### Description Retrieves an example heart rate subject data dictionary. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_hr_subject_data_dict_tuple_example() ### Description Retrieves an example heart rate subject data tuple. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_mist_hr_example() ### Description Retrieves an example heart rate dataset for the MIST protocol. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_questionnaire_example() ### Description Retrieves an example questionnaire dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_questionnaire_example_wrong_range() ### Description Retrieves an example questionnaire dataset with a wrong range. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_saliva_example() ### Description Retrieves an example saliva dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_saliva_example_plate_format() ### Description Retrieves an example saliva dataset in plate format. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_saliva_mean_se_example() ### Description Retrieves an example of saliva mean and standard error data. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_sleep_analyzer_raw_example() ### Description Retrieves an example raw dataset from the sleep analyzer. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_sleep_analyzer_raw_file() ### Description Retrieves a raw file from the sleep analyzer. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_sleep_analyzer_raw_file_unformatted() ### Description Retrieves an unformatted raw file from the sleep analyzer. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_sleep_analyzer_summary_example() ### Description Retrieves an example summary dataset from the sleep analyzer. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_sleep_imu_example() ### Description Retrieves an example IMU dataset from sleep analysis. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_stats_example() ### Description Retrieves an example dataset for statistical analysis. ### Parameters None explicitly documented. ### Response None explicitly documented. ## get_time_log_example() ### Description Retrieves an example time log dataset. ### Parameters None explicitly documented. ### Response None explicitly documented. ``` -------------------------------- ### Install BioPsyKit with Jupyter Extras Source: https://biopsykit.readthedocs.io/en/latest/README.html Installs BioPsyKit along with extra dependencies required for use with Jupyter Lab. This command ensures all necessary packages for interactive notebook environments are included. ```bash pip install "biopsykit[jupyter]" ``` -------------------------------- ### get_stats_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example data suitable for statistical analysis. ```APIDOC ## get_stats_example() ### Description Return example data for statistical analysis. ### Returns - **data** – dataframe with example data that can be used for statistical analysis ### Return type `DataFrame` ``` -------------------------------- ### get_condition_list_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Provides an example list of conditions, useful for testing or demonstration. ```APIDOC ## get_condition_list_example() ### Description Provides an example list of conditions, useful for testing or demonstration. ### Module biopsykit.example_data ``` -------------------------------- ### get_ecg_processing_results_path_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Provides an example file path for ECG processing results. ```APIDOC ## get_ecg_processing_results_path_example() ### Description Provides an example file path for ECG processing results. ### Module biopsykit.example_data ``` -------------------------------- ### get_sleep_analyzer_raw_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example of raw data from the Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_raw_example() ### Description Retrieves an example of raw data from the Sleep Analyzer. ### Module biopsykit.example_data ``` -------------------------------- ### biopsykit.example_data.get_ecg_path_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return folder path to ECG example data. ```APIDOC ## biopsykit.example_data.get_ecg_path_example ### Description Return folder path to ECG example data. ### Returns - path to folder with ECG raw files ### Return type `Path` or str ``` -------------------------------- ### get_sleep_analyzer_summary_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example summary data from the Withings Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_summary_example() ### Description Return Withings Sleep Analyzer example summary data. ### Returns - dataframe with example sleep endpoints computed from Withings Sleep Analyzer Summary data ### Return type `SleepEndpointDataFrame` ``` -------------------------------- ### Update Dependencies with Poetry Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Commands to update project dependencies after changes to `pyproject.toml`. `poetry install --no-root` installs only new packages, while `poetry update` checks for newer versions of existing packages. ```bash poetry install --no-root ``` ```bash poetry update ``` -------------------------------- ### start_time_datetime Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Property for the start time in datetime format. ```APIDOC start_time_datetime (biopsykit.io.psg.PSGDataset property) ``` -------------------------------- ### get_hr_subject_data_dict_tuple_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Provides an example tuple of heart rate subject data. ```APIDOC ## get_hr_subject_data_dict_tuple_example() ### Description Provides an example tuple of heart rate subject data. ### Module biopsykit.example_data ``` -------------------------------- ### biopsykit.example_data.get_condition_list_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return example data for subject condition assignment. ```APIDOC ## biopsykit.example_data.get_condition_list_example ### Description Return example data for subject condition assignment. ### Returns - `SubjectConditionDataFrame` – dataframe with example subject condition assignment ``` -------------------------------- ### get_hr_subject_data_dict_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Provides an example dictionary of heart rate subject data. ```APIDOC ## get_hr_subject_data_dict_example() ### Description Provides an example dictionary of heart rate subject data. ### Module biopsykit.example_data ``` -------------------------------- ### get_sleep_analyzer_raw_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example raw data from the Withings Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_raw_example(_split_into_nights =True_) ### Description Return Withings Sleep Analyzer example raw data. ### Parameters - **split_into_nights** (_bool_ _,__optional_) – `True` to split data into single dataframes per recording night, and return a dict of dataframes, `False` to keep all data in one dataframe. Default: `True` ### Returns - dataframe with raw sleep analyzer data or a dict of such if `split_into_nights` is `True` ### Return type `DataFrame` or dict ``` -------------------------------- ### biopsykit.example_data.get_eeg_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return raw EEG example data collected from a Muse EEG headband. ```APIDOC ## biopsykit.example_data.get_eeg_example ### Description Return raw EEG example data collected from a Muse EEG headband. ### Returns - **data** (`DataFrame`) – dataframe with raw EEG data - **sampling_rate** (_float_) – sampling rate of recorded data ### Return type `MuseDataset` ``` -------------------------------- ### biopsykit.example_data.get_saliva_example_plate_format Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return example saliva data from “plate” format. ```APIDOC ## biopsykit.example_data.get_saliva_example_plate_format ### Description Return example saliva data from “plate” format. ### Parameters - **sample_id_col** (_None_) – - **data_col** (_None_) – - **id_col_names** (_None_) – - **regex_str** (_None_) – - **sample_times** (_None_) – - **condition_list** (_None_) – ``` -------------------------------- ### biopsykit.example_data.get_mist_hr_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return heart rate time-series example data collected during MIST from one subject. ```APIDOC ## biopsykit.example_data.get_mist_hr_example ### Description Return heart rate time-series example data collected during MIST from one subject. ### Returns - dictionary with heart rate time-series data from one subject during multiple phases ### Return type `HeartRatePhaseDict` ``` -------------------------------- ### start_time_unix Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Property for the start time in Unix timestamp format. ```APIDOC start_time_unix (biopsykit.io.biopac.BiopacDataset property) ``` ```APIDOC start_time_unix (biopsykit.io.fibion.FibionDataset property) ``` ```APIDOC start_time_unix (biopsykit.io.psg.PSGDataset property) ``` -------------------------------- ### get_saliva_mean_se_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example of mean and standard error for saliva data. ```APIDOC ## get_saliva_mean_se_example() ### Description Retrieves an example of mean and standard error for saliva data. ### Module biopsykit.example_data ``` -------------------------------- ### get_sleep_imu_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example raw IMU data collected from a wrist-worn IMU sensor during the night. ```APIDOC ## get_sleep_imu_example() ### Description Return raw IMU example data collected from a wrist-worn IMU sensor during night. ### Returns - **data** (`DataFrame`) – dataframe with raw IMU data - **sampling_rate** (_float_) – sampling rate of recorded data ### Return type tuple[pandas.core.frame.DataFrame, float] ``` -------------------------------- ### get_sleep_imu_example() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example of IMU (Inertial Measurement Unit) data related to sleep. ```APIDOC ## get_sleep_imu_example() ### Description Retrieves an example of IMU (Inertial Measurement Unit) data related to sleep. ### Module biopsykit.example_data ``` -------------------------------- ### Apply Statistical Analysis Pipeline and Plot Results Source: https://biopsykit.readthedocs.io/en/latest/README.html This example shows how to configure a statistical analysis pipeline with normality checks and paired t-tests, apply it to data, and then plot the results with statistical significance brackets. ```python import matplotlib.pyplot as plt from biopsykit.stats import StatsPipeline from biopsykit.plotting import multi_feature_boxplot from biopsykit.example_data import get_stats_example data = get_stats_example() # configure statistical analysis pipeline which consists of checking for normal distribution and performing paired t-tests (within-variable: time) on each questionnaire subscale separately (grouping data by subscale). pipeline = StatsPipeline( steps=[("prep", "normality"), ("test", "pairwise_ttests")], params={"dv": "PANAS", "groupby": "subscale", "subject": "subject", "within": "time"} ) # apply statistics pipeline on data pipeline.apply(data) # plot data and add statistical significance brackets from statistical analysis pipeline fig, axs = plt.subplots(ncols=3) features = ["NegativeAffect", "PositiveAffect", "Total"] # generate statistical significance brackets box_pairs, pvalues = pipeline.sig_brackets( "test", stats_effect_type="within", plot_type="single", x="time", features=features, subplots=True ) # plot data multi_feature_boxplot( data=data, x="time", y="PANAS", features=features, group="subscale", order=["pre", "post"], stats_kwargs={"box_pairs": box_pairs, "pvalues": pvalues}, ax=axs ) ``` -------------------------------- ### biopsykit.example_data.get_ecg_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return raw ECG example data from one subject. ```APIDOC ## biopsykit.example_data.get_ecg_example ### Description Return raw ECG example data from one subject. ### Returns - `DataFrame` – dataframe with raw ECG data - **sampling_rate** (_float_) – sampling rate of recorded data ### Return type tuple[pandas.core.frame.DataFrame, float] ``` -------------------------------- ### biopsykit.example_data.get_hr_subject_data_dict_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return heart rate example data in the form of a `HeartRateSubjectDataDict`. ```APIDOC ## biopsykit.example_data.get_hr_subject_data_dict_example ### Description Return heart rate example data in the form of a `HeartRateSubjectDataDict`. ### Returns - dictionary with heart rate time-series data from multiple subjects, each containing data from different phases. ### Return type `HeartRateSubjectDataDict` ``` -------------------------------- ### biopsykit.example_data.get_ecg_example_02 Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return second raw ECG example data from another subject. ```APIDOC ## biopsykit.example_data.get_ecg_example_02 ### Description Return second raw ECG example data from another subject. ### Returns - `DataFrame` – dataframe with raw ECG data - **sampling_rate** (_float_) – sampling rate of recorded data ### Return type tuple[pandas.core.frame.DataFrame, float] ``` -------------------------------- ### get_sleep_analyzer_raw_file Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves an example file of raw data from the Withings Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_raw_file(_data_source_ , _split_into_nights =True_) ### Description Return Withings Sleep Analyzer raw data example file. ### Parameters - **data_source** (_str_) – Withings Sleep Analyzer data source name. Must be one of [‘heart_rate’, ‘respiration_rate’, ‘sleep_state’, ‘snoring’]. - **split_into_nights** (_bool_ _,__optional_) – whether to split the dataframe into the different recording nights (and return a dictionary of dataframes) or not. Default: `True` ### Returns - dataframe (or dict of dataframes, if `split_into_nights` is `True`) with Sleep Analyzer data ### Return type `DataFrame` or dict of such ``` -------------------------------- ### biopsykit.example_data.get_hr_subject_data_dict_tuple_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return HR example data as a `HeartRateSubjectDataDict`, but with tuples as keys instead of strings. ```APIDOC ## biopsykit.example_data.get_hr_subject_data_dict_tuple_example ### Description Return HR example data as a `HeartRateSubjectDataDict`, but with tuples as keys instead of strings. ### Returns - dictionary with heart rate time-series, each containing data from different phases. ### Return type `HeartRateSubjectDataDict` ``` -------------------------------- ### get_saliva_mean_se_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves example data containing mean and standard error for different saliva types. ```APIDOC ## get_saliva_mean_se_example() ### Description Return dictionary with mean and standard error from example data for different saliva types. ### Returns - dictionary with `SalivaMeanSeDataFrame` from different saliva types ### Return type dict ``` -------------------------------- ### get_sleep_analyzer_raw_file_unformatted Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Retrieves an unformatted example file of raw data from the Withings Sleep Analyzer. ```APIDOC ## get_sleep_analyzer_raw_file_unformatted(_data_source_) ### Description Return _unformatted_ Withings Sleep Analyzer raw data example file. ### Parameters - **data_source** (_str_) – Withings Sleep Analyzer data source name. Must be one of [‘heart_rate’, ‘respiration_rate’, ‘sleep_state’, ‘snoring’]. ### Returns - Dataframe with unformatted example raw data ### Return type `DataFrame` ``` -------------------------------- ### Configure PyCharm Python Console Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Add these lines to PyCharm's 'Starting Script' to enable autoreload for the Python console. ```python %load_ext autoreload %autoreload 2 ``` -------------------------------- ### load_atimelogger_file Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.html Loads a time log file exported from the aTimeLogger app into a DataFrame. The DataFrame will have one row with start and end times of phases as columns. ```APIDOC ## load_atimelogger_file ### Description Load time log file exported from the aTimeLogger app. The resulting dataframe will have one row and start and end times of the single phases as columns. ### Parameters * **file_path** (`Path` or str) – path to time log file. Must a csv file * **timezone** (str or `datetime.tzinfo`, optional) – timezone of the time logs, either as string or as tzinfo object. Default: ‘Europe/Berlin’ * **handle_multiple** (_str_) ### Returns time log dataframe ### Return type `DataFrame` ### See also `convert_time_log_datetime()` convert timelog dataframe into dictionary aTimeLogger app ``` -------------------------------- ### biopsykit.example_data.get_hr_result_sample Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return heart rate results example data. The heart rate results example data consists of the mean normalized heart rate for different subjects, different study phases, and study subphases. ```APIDOC ## biopsykit.example_data.get_hr_result_sample ### Description Return heart rate results example data. The heart rate results example data consists of the mean normalized heart rate for different subjects, different study phases, and study subphases. ### Returns - dataframe with heart rate results example data ### Return type `DataFrame` ``` -------------------------------- ### biopsykit.example_data.get_questionnaire_example_wrong_range Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return questionnaire example data with score in the wrong range. In this example the items of the “PSS” questionnaire are coded in the wrong range ([1, 5] instead of [0, 4]) originally defined in the paper. This example data is used to demonstrate BioPsyKit’s feature of asserting that questionnaire score items are provided in the correct score range according to the original definition of the questionnaire. ```APIDOC ## biopsykit.example_data.get_questionnaire_example_wrong_range ### Description Return questionnaire example data with score in the wrong range. In this example the items of the “PSS” questionnaire are coded in the wrong range ([1, 5] instead of [0, 4]) originally defined in the paper. This example data is used to demonstrate BioPsyKit’s feature of asserting that questionnaire score items are provided in the correct score range according to the original definition of the questionnaire. ### Returns - **data** – dataframe with questionnaire example data where the items of the PSS questionnaire are coded in the wrong range ### Return type `DataFrame` ``` -------------------------------- ### start_baseline_sec Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Attribute for the start of the baseline in seconds. ```APIDOC start_baseline_sec (biopsykit.protocols.cft.CftFeatureExtraction attribute) ``` -------------------------------- ### FibionDataset.timezone Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.fibion.html Get the timezone the dataset was recorded in. ```APIDOC ## property FibionDataset.timezone ### Description Timezone the dataset was recorded in. ### Return Type str ``` -------------------------------- ### biopsykit.example_data.get_hr_ensemble_sample Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return heart rate ensemble example data. The example data consists of time-series heart rate of multiple subjects for different study phases, each synchronized and resampled to 1 Hz, and normalized to baseline heart rate. ```APIDOC ## biopsykit.example_data.get_hr_ensemble_sample ### Description Return heart rate ensemble example data. The example data consists of time-series heart rate of multiple subjects for different study phases, each synchronized and resampled to 1 Hz, and normalized to baseline heart rate. ### Returns - dictionary with pandas dataframes containing heart rate ensemble data ### Return type dict ``` -------------------------------- ### Initialize and Fit SklearnPipelinePermuter Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.model_selection.sklearn_pipeline_permuter.html Demonstrates how to initialize the SklearnPipelinePermuter with model, parameter, and hyperparameter search dictionaries, and then fit it to data using cross-validation. This is useful for evaluating a wide range of pipeline configurations. ```python from sklearn import datasets from sklearn.preprocessing import StandardScaler, MinMaxScaler from sklearn.feature_selection import SelectKBest, RFE from sklearn.neighbors import KNeighborsClassifier from sklearn.svm import SVC from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import AdaBoostClassifier from sklearn.model_selection import KFold from biopsykit.classification.model_selection import SklearnPipelinePermuter breast_cancer = datasets.load_breast_cancer() X = breast_cancer.data y = breast_cancer.target model_dict = { "scaler": { "StandardScaler": StandardScaler(), "MinMaxScaler": MinMaxScaler(), }, "reduce_dim": { "SelectKBest": SelectKBest(), "RFE": RFE(SVC(kernel="linear", C=1)) }, "clf" : { "KNeighborsClassifier": KNeighborsClassifier(), "DecisionTreeClassifier": DecisionTreeClassifier(), "SVC": SVC(), "AdaBoostClassifier": AdaBoostClassifier(), } } param_dict = { "StandardScaler": None, "MinMaxScaler": None, "SelectKBest": { "k": [2, 4, 6, 8, "all"] }, "RFE": { "n_features_to_select": [2, 4, 6, 8, None] }, "KNeighborsClassifier": { "n_neighbors": [2, 4, 6, 8], "weights": ["uniform", "distance"] }, "DecisionTreeClassifier": {"criterion": ['gini', 'entropy'], "max_depth": [2, 4, 6, 8, 10] }, "AdaBoostClassifier": { "base_estimator": [DecisionTreeClassifier(max_depth=1), DecisionTreeClassifier(max_depth=2)], "n_estimators": np.arange(20, 210, 10), "learning_rate": np.arange(0.6, 1.1, 0.1) }, "SVC": [ { "kernel": ["linear"], "C": np.logspace(start=-3, stop=3, num=7) }, { "kernel": ["rbf"], "C": np.logspace(start=-3, stop=3, num=7), "gamma": np.logspace(start=-3, stop=3, num=7) } ] } # AdaBoost hyperparameters should be optimized using randomized-search, all others using grid-search hyper_search_dict = { "AdaBoostClassifier": {"search_method": "random", "n_iter": 30} } pipeline_permuter = SklearnPipelinePermuter(model_dict, param_dict, hyper_search_dict) pipeline_permuter.fit(X, y, outer_cv=KFold(), inner_cv=KFold()) ``` -------------------------------- ### start_factor Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Attribute for the start factor in ECG segmentation. ```APIDOC start_factor (biopsykit.signals.ecg.segmentation.HeartbeatSegmentationNeurokit attribute) ``` -------------------------------- ### biopsykit.example_data.get_ecg_processing_results_path_example Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.example_data.html Return folder path to ECG processing results. ```APIDOC ## biopsykit.example_data.get_ecg_processing_results_path_example ### Description Return folder path to ECG processing results. ### Returns - path to folder with ECG processing results ### Return type `Path` or str ``` -------------------------------- ### get_questionnaire_example_wrong_range() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Retrieves an example questionnaire with values outside the expected range. ```APIDOC ## get_questionnaire_example_wrong_range() ### Description Retrieves an example questionnaire with values outside the expected range. ### Module biopsykit.example_data ``` -------------------------------- ### from_folder Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Loads a Fibion dataset from a folder. Class method of FibionDataset. ```APIDOC ## from_folder() ### Description Loads a Fibion dataset from a specified folder. ### Class Method biopsykit.io.fibion.FibionDataset.from_folder ``` -------------------------------- ### SklearnPipelinePermuter.from_pickle() Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.model_selection.sklearn_pipeline_permuter.html Loads a SklearnPipelinePermuter instance from a pickle file. ```APIDOC ## SklearnPipelinePermuter.from_pickle() ### Description Loads a previously saved SklearnPipelinePermuter instance from a pickle file. ### Method `from_pickle(pickle_path: str)` ### Parameters #### Path Parameters - **pickle_path** (str) - Required - The path to the pickle file. ``` -------------------------------- ### from_file Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Loads a protocol from a file. Class method of BaseProtocol. ```APIDOC ## from_file() ### Description Loads a protocol configuration from a file. ### Class Method biopsykit.protocols.base.BaseProtocol.from_file biopsykit.protocols.BaseProtocol.from_file ``` -------------------------------- ### bool_array_to_start_end_array() Source: https://biopsykit.readthedocs.io/en/latest/genindex.html Converts a boolean array to an array of start and end indices. ```APIDOC ## bool_array_to_start_end_array() ### Description Converts a boolean array into an array representing the start and end indices of `True` segments. ### Module biopsykit.utils.array_handling ### Parameters None explicitly documented. ``` -------------------------------- ### FibionDataset.from_folder Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.fibion.html Create a new Dataset from a valid .edf file. ```APIDOC ## class FibionDataset.from_folder ### Description Create a new Dataset from a valid .edf file. ### Parameters * **path** (`pathlib.Path` or str) - Path to the file * **tz** (str, optional) - Timezone str of the recording. This can be used to localize the start and end time. Note, this should not be the timezone of your current PC, but the timezone relevant for the specific recording. Defaults to 'Europe/Berlin'. ``` -------------------------------- ### Execute multiple poethepoet tasks Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Run a group of tasks, like 'default' (which includes format, lint, and test), with a single command. ```bash poe default ``` -------------------------------- ### predictions_as_df Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.analysis.html Gets predictions from a specified pipeline and merges them with the index of the input dataframe. ```APIDOC ## predictions_as_df ### Description Get predictions from a specified pipeline and merge them with the index of the input dataframe. ### Parameters * **pipeline_permuter** (`SklearnPipelinePermuter`) – `SklearnPipelinePermuter` instance * **data** (`DataFrame`) – input data * **pipeline** (_tuple_) – pipeline to get predictions from * **label_mapping** (_dict_ _,__optional_) – mapping of labels to rename the labels in the output dataframe or `None` to keep original labels. Default: `None` * **index_col** (_str_ _,__optional_) – name of the column to use as index in the output dataframe or `None` to use the original index. Default: `None` ``` -------------------------------- ### from_pickle Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.model_selection.sklearn_pipeline_permuter.html Imports a SklearnPipelinePermuter instance from a pickle file. ```APIDOC ## from_pickle(file_path) ### Description Import a `SklearnPipelinePermuter` instance from a pickle file. ### Parameters - **file_path** (`Path` or str) - Required - file path to import ### Returns `SklearnPipelinePermuter` instance ### Return type `SklearnPipelinePermuter` ``` -------------------------------- ### predict_proba_from_estimator Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.analysis.html Gets predictions as probabilities from a specified pipeline and merges them with the index of the input dataframe. ```APIDOC ## predict_proba_from_estimator ### Description Get predictions as probabilities from a specified pipeline and merge them with the index of the input dataframe. ### Parameters * **pipeline_permuter** (`SklearnPipelinePermuter`) – `SklearnPipelinePermuter` instance * **data** (`DataFrame`) – input data * **pipeline** (_tuple_) – pipeline to get predictions from * **label_col** (_str_ _,__optional_) – name of the label column in the input dataframe. Default: ` ``` -------------------------------- ### metric_summary_to_latex Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.analysis.html Returns a LaTeX table with the performance metrics of pipeline combinations. This is a legacy method for backwards compatibility. ```APIDOC ## metric_summary_to_latex ### Description Return a latex table with the performance metrics of the pipeline combinations. ### Parameters * **permuter_or_df** (`SklearnPipelinePermuter` or `DataFrame`) – `SklearnPipelinePermuter` instance or dataframe with performance metrics. * **metrics** (_list_ _of_ _str_ _,__optional_) – list of metrics to include in the table or `None` to use all available metrics in the dataframe. Default: `None` * **pipeline_steps** (_list_ _of_ _str_ _,__optional_) – list of pipeline steps to include in the table index or `None` to show all available pipeline steps as table index. Default: `None` * **si_table_format** (_str_ _,__optional_) – table format for the `siunitx` package or `None` to use the default format. Default: `None` * **highlight_best** (_bool_ _or_ _str_ _,__optional_) – Whether to highlight the pipeline with the best value in each column or not. * If `highlight_best` is a boolean, the best pipeline is highlighted in each column. * If `highlight_best` is a string, the best pipeline is highlighted in the column with the name * ****kwargs** – additional keyword arguments passed to `to_latex()` ### Returns str: LaTeX table as a string. ``` -------------------------------- ### Load Multiple NilsPod Datasets from Folder Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.nilspod.html Load all NilsPod datasets from a specified folder, convert them to dataframes, and combine them into a dictionary. This is useful for sessions recorded across different study phases. You can specify phase names and select specific datastreams. ```python >>> from biopsykit.io.nilspod import load_folder_nilspod >>> folder_path = "./nilspod" >>> # load all datasets from the selected folder with all datastreams >>> dataset_dict, fs = load_folder_nilspod(folder_path) >>> # load only ECG data of all datasets from the selected folder >>> dataset_dict, fs = load_folder_nilspod(folder_path, datastreams=['ecg']) >>> # load all datasets from the selected folder with correspondng phase names >>> dataset_dict, fs = load_folder_nilspod(folder_path, phase_names=['VP01','VP02','VP03']) ``` -------------------------------- ### BiopacDataset properties Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.biopac.html Accesses properties of the BiopacDataset object, including start time, timezone, and event markers. ```APIDOC ## BiopacDataset Properties ### Description Accesses properties of the BiopacDataset object. ### Properties - **start_time_unix** (`pandas._libs.tslibs.timestamps.Timestamp` or None): Start time of the recording in UTC time. - **timezone** (str): Timezone the dataset was recorded in. - **event_markers** (list of `bioread.reader.EventMarker`): Event markers set in the AcqKnowledge software during the recording. ### Access Example ```python from biopsykit.io import BiopacDataset # Assuming 'dataset' is a loaded BiopacDataset object start_time = dataset.start_time_unix timezone = dataset.timezone events = dataset.event_markers ``` ``` -------------------------------- ### SklearnPipelinePermuter.best_estimator_summary() Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.model_selection.sklearn_pipeline_permuter.html Provides a summary of the best estimator found. ```APIDOC ## SklearnPipelinePermuter.best_estimator_summary() ### Description Provides a summary of the best estimator found, including its parameters and performance metrics. ### Method `best_estimator_summary()` ### Returns - A pandas DataFrame summarizing the best estimator. ``` -------------------------------- ### BiopacDataset.from_acq_file Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.biopac.html Creates a BiopacDataset instance from a .acq file. This is the recommended way to load Biopac data. ```APIDOC ## BiopacDataset.from_acq_file ### Description Create a new Dataset from a valid .acq file. ### Method classmethod ### Parameters #### Path Parameters - **path** (pathlib.Path or str) - Required - Path to the file #### Query Parameters - **channel_mapping** (dict) - Optional - Dictionary containing the mapping of the channel names in the .acq to the channel names used in the Dataset. - **tz** (str) - Optional - Timezone str of the recording. This can be used to localize the start and end time. Note, this should not be the timezone of your current PC, but the timezone relevant for the specific recording. Defaults to 'Europe/Berlin'. ### Request Example ```python from biopsykit.io import BiopacDataset dataset = BiopacDataset.from_acq_file("path/to/your/recording.acq") ``` ### Response #### Success Response (BiopacDataset) - Returns an instance of BiopacDataset containing the loaded data. ``` -------------------------------- ### SklearnPipelinePermuter.metric_summary() Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.classification.model_selection.sklearn_pipeline_permuter.html Generates a summary of the performance metrics for each pipeline combination. ```APIDOC ## SklearnPipelinePermuter.metric_summary() ### Description Generates a summary of the performance metrics for each pipeline combination. ### Method `metric_summary()` ### Returns - A pandas DataFrame summarizing the performance metrics. ``` -------------------------------- ### biopsykit.metadata.gender_counts Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.metadata.html Get statistics about gender distribution from a dataset. Allows specifying the gender column and optionally splitting the distribution by condition. ```APIDOC ## biopsykit.metadata.gender_counts ### Description Get statistics about gender distribution from a dataset. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **data** (DataFrame) – dataframe with subjects * **gender_col** (str, optional) – column name containing gender information or `None` to use default name (“gender”). * **split_condition** (bool, optional) – `True` to split gender distribution by condition (assumes that an “condition” index level is present in `data`), `False` otherwise. Default: `False` ### Request Example None ### Response #### Success Response (200) * **dataframe** (DataFrame) – dataframe with absolute and relative gender distribution #### Response Example None ``` -------------------------------- ### Add New Dependencies with Poetry Source: https://biopsykit.readthedocs.io/en/latest/source/contributing/CONTRIBUTING.html Commands to add new packages to the project's dependencies using Poetry. Use `--dev` for development-specific dependencies. ```bash poetry add ``` ```bash poetry add --dev ``` -------------------------------- ### convert_time_log_dict Source: https://biopsykit.readthedocs.io/en/latest/api/biopsykit.io.html Converts a time log (DataFrame or Series) into a dictionary where keys are phase names and values are tuples of start and end times. ```APIDOC ## convert_time_log_dict ### Description Convert time log into dictionary. The resulting dictionary will have the phase names as keys and a tuple with start and end times as values. ### Parameters * **timelog** (`DataFrame` or `Series`) – dataframe or series containing timelog information * **time_format** (_"str"__or_ _"time"__,__optional_) – “str” to convert entries in dictionary to string, “time” to keep them as `time` objects. Default: “time” ### Returns dictionary with start and end times of each phase ### Return type dict ### See also `biopsykit.utils.data_processing.split_data()` split data based on time intervals ``` -------------------------------- ### Cite Algorithm Implementation Source: https://biopsykit.readthedocs.io/en/latest/README.html When using a specific algorithm implemented in BioPsyKit, cite both the original paper of the algorithm and the BioPsyKit package. ```plaintext We used the algorithm proposed by Author et al. [paper-citation], implemented by the BioPsykit package [biopsykit-citation]. ```