API - Group Pipeline
- wearablehrv.group.bar_plot(data, conditions, features, devices)
This function creates an interactive bar chart comparing the mean values of different devices for the given data, conditions, features, and devices. It uses Plotly and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive bar chart.
- wearablehrv.group.blandaltman_analysis(data, criterion, devices, conditions, features, path, save_as_csv=False)
Calculates the Bland-Altman analysis to assess the agreement between measurements from various devices compared to a criterion device, across different conditions and features. This analysis includes calculating bias, limits of agreement, and their 95% Confidence Intervals.
Parameters:
- datadict
Nested dictionary containing the data, organized as {device: {feature: {condition: [values]}}}. It includes measurements for each device, feature, and condition.
- criterionstr
The name of the device used as the standard for comparison.
- deviceslist of str
List of device names whose data will be analyzed.
- conditionslist of str
Experimental conditions under which the data was collected.
- featureslist of str
Measured features of interest.
- pathstr or Path, optional
Directory path where the results CSV file will be saved if save_as_csv is True. Accepts both string paths and Path objects from the pathlib module.
- save_as_csvbool, optional
If True, saves the Bland-Altman analysis results to a CSV file specified by the path parameter. Default is False.
Returns:
- blandaltman_datadict
Nested dictionary with the Bland-Altman analysis results for each device, feature, and condition, including bias, standard deviation (SD), limits of agreement (LoA), and their 95% Confidence Intervals.
Notes:
The Bland-Altman analysis is a statistical method used to compare two quantitative measurement techniques.
In addition to bias and limits of agreement, this function calculates and includes the 95% Confidence Intervals for both bias and LoAs.
If save_as_csv is True and a path is provided, the function outputs the results to a CSV file, facilitating easy access to and further analysis of the data.
- wearablehrv.group.blandaltman_plot(data, criterion, conditions, devices, features, width=10, height_per_plot=5, agreement_bound=1.96, confidenceInterval=95, percentage=False, mean_diff_color='#FF6347', boundary_color='#20B2AA', pointColour='#8B008B', shade=True)
Generates Bland-Altman plots for data comparison between devices and a criterion.
Parameters:
- blandaltman_data: dict
The Bland-Altman data.
- data: dict
The main data containing measurement values from various devices.
- criterion: str
The name of the criterion device against which comparisons are made.
- conditions: list
List of conditions under which measurements were taken.
- devices: list
List of measurement devices including the criterion device.
- features: list
List of features or metrics being measured.
- width: int, optional, default=10
Width of the entire plot.
- height_per_plot: int, optional, default=5
Height of each individual subplot.
- agreement_bound: float, optional, default=1.96
Multiplier for the standard deviation to determine limits of agreement.
- confidenceInterval: float, optional, default=95
Confidence interval percentage for shading (if applied).
- percentage: bool, optional, default=False
If True, plots differences as percentages. Otherwise, plots raw differences.
- mean_diff_color: str, optional, default=’#FF6347’
Color used for the mean difference line.
- boundary_color: str, optional, default=’#20B2AA’
Color used for the upper and lower limits of agreement lines.
- pointColour: str, optional, default=’#8B008B’
Color used for the individual data points.
- shade: bool, optional, default=True
If True, shades the confidence interval around the mean and limits of agreement.
Returns:
- None
The function displays the Bland-Altman plots and doesn’t return any value.
Note:
This function generates Bland-Altman plots for each combination of device (excluding the criterion) and feature, under each condition. The plots include the mean difference (bias) and the upper and lower limits of agreement, and optionally the shaded confidence intervals.
- wearablehrv.group.bonferroni_correction_icc(icc_data, alpha=0.05)
Applies the Bonferroni correction to the p-values in the ICC analysis results.
Parameters:
- icc_datadict
A nested dictionary containing the ICC results for each device, feature, and condition.
- alphafloat, optional, default: 0.05
The significance level for the tests.
Returns:
- corrected_icc_datadict
The ICC data with Bonferroni corrected p-values.
- wearablehrv.group.bonferroni_correction_regression(regression_data, alpha=0.05)
Applies the Bonferroni correction to the p-values in the regression analysis results.
Parameters:
- regression_datadict
A nested dictionary containing the regression results for each device, feature, and condition.
- alphafloat, optional, default: 0.05
The significance level for the tests.
Returns:
- corrected_regression_datadict
The regression data with Bonferroni corrected p-values.
- wearablehrv.group.box_plot(data, conditions, features, devices)
This function creates an interactive box plot comparing different devices for the given data, conditions, features, and devices. It uses Plotly and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive box plot.
- wearablehrv.group.check_normality(data, conditions, devices, features, alpha=0.05)
Analyzes the normality of data using the Shapiro-Wilk test for selected features across devices and conditions.
Parameters
- datadict
Nested dictionary with structure {device: {feature: {condition: [values]}}}.
- conditionslist of str
Experimental conditions.
- deviceslist of str
Devices used for data collection.
- featureslist of str
Features of the data to analyze.
- alphafloat, optional
Significance level for the Shapiro-Wilk test, default is 0.05.
Returns
- normality_resultsdict
Results of the Shapiro-Wilk test, structured as {device: {feature: {condition: {‘p_value’: float, ‘is_normal’: bool}}}}.
- suggestionsdict
Suggestions for transformation if data is not normally distributed, with the same structure as normality_results.
- transformation_summarydict
Summary of conditions requiring transformation for each device and feature, formatted as {device: {feature: [conditions]}}.
This function checks each combination of device, feature, and condition for normality. It suggests transformations for non-normal distributions and summarizes which conditions require transformation.
- wearablehrv.group.density_plot(data, file_names, conditions, features, devices)
This function creates an interactive density plot comparing different devices for the given data, conditions, features, and devices. It uses Seaborn, Matplotlib, and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- file_nameslist
A list of strings containing the file names of the CSV files to be imported.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive density plot.
- wearablehrv.group.heatmap_plot(data, criterion, devices, conditions, features)
This function creates a correlation heatmap between each device and the criterion device for each condition and feature.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- criterionstr
A string representing the device used as a criterion for comparison.
- deviceslist
A list of strings representing the different devices used to collect the data.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
Returns:
None
- wearablehrv.group.hist_plot(data, conditions, features, devices)
This function creates an interactive histogram plot comparing different devices for the given data, conditions, features, and devices. It uses Plotly and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive histogram plot.
- wearablehrv.group.icc_analysis(data, criterion, devices, conditions, features, path, save_as_csv)
Calculates the Intraclass Correlation Coefficient (ICC) for comparing the reliability of measurements among devices against a criterion device, across different conditions and features. The ICC assesses the consistency or reproducibility of quantitative measurements made by different observers measuring the same quantity.
Parameters:
- datadict
A nested dictionary with structure {device: {feature: {condition: [values]}}}. It contains the measurement data for each device across specified conditions and features.
- criterionstr
The name of the device used as a reference or standard for comparison in the analysis.
- deviceslist of str
A list containing the names of the devices whose data is analyzed. This should include the criterion device.
- conditionslist of str
The experimental conditions under which data was collected. Conditions are used to segment and compare data.
- featureslist of str
The specific data features or measurements that are analyzed for reliability.
- pathstr or Path
The path where the result CSV file (if saving is enabled) will be stored. Can be a string or a Path object from the pathlib module.
- save_as_csvbool
Determines whether to save the ICC analysis results to a CSV file. If True, the results are saved to the specified path.
Returns:
- icc_datadict
A nested dictionary with the ICC results organized by device, feature, and condition. Each entry contains the ICC value and its confidence interval, reflecting the measurement consistency.
Notes:
If save_as_csv is True, the function saves the detailed ICC results, including ICC type, value, 95% confidence interval, and p-value, to a CSV file at the specified path, facilitating easy access and further analysis.
- wearablehrv.group.icc_plot(icc_data, conditions, devices, features, font_size=12, cmap='coolwarm')
This function creates an interactive heatmap plot for ICC values of each device compared to the criterion device, for each condition and feature. The heatmap provides both the ICC values and their corresponding 95% confidence intervals.
Parameters:
- icc_datadict
A nested dictionary containing the ICC results (ICC value and 95% confidence interval) for each device, feature, and condition.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- deviceslist
A list of strings representing the different devices used to collect the data. The last device is assumed to be the criterion device.
- featureslist
A list of strings representing the different features of the data.
- font_sizeint, optional, default: 12
The font size for labels, titles, and annotations.
- cmapstr, optional, default: “coolwarm”
The color map to be used for the heatmap. This should be a valid matplotlib or seaborn colormap string.
Returns:
None
Note: The function displays an interactive dropdown widget for feature selection and renders the heatmap based on the selected feature.
- wearablehrv.group.import_data(path, conditions, devices, features)
Imports data from multiple CSV files located in a specific directory and structures the data into a nested dictionary based on devices, features, and conditions.
This function scans a directory for CSV files, reads the data from these files, and organizes it into a nested dictionary. This dictionary is structured to allow easy access to data based on device, feature, and condition. Each file is assumed to contain data for all conditions, devices, and features specified by the parameters.
Parameters
- pathstr
The path to the directory where the CSV files are located. The function expects to find files named in a specific pattern that includes the participant ID.
- conditionslist of str
A list of strings representing the different experimental conditions under which the data was collected.
- deviceslist of str
A list of strings representing the different devices used to collect the data.
- featureslist of str
A list of strings representing the different features recorded in the data.
Returns
- tuple
A tuple containing two elements: - data: A nested dictionary with the structure {device: {feature: {condition: {participant: [values]}}}}, representing the imported data. - file_names: A list of the file names that were imported, providing a record of which files were processed.
Notes
The function automatically identifies CSV files in the provided path and imports data from them. The expected file naming convention and data structure within the files should match the specified devices, conditions, and features.
- wearablehrv.group.log_transform_data(data, devices, transform_features)
Applies a log transformation to the ‘rmssd’ and ‘hf’ features in the data for all devices and conditions.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- deviceslist
A list of strings representing the different devices used to collect the data.
- transform_featureslist
A list of strings representing the specific features to transform (‘rmssd’, ‘hf’).
Returns:
None - the function updates the ‘data’ dictionary in place.
- wearablehrv.group.mape_analysis(data, criterion, devices, conditions, features, path=None, alpha=0.95, save_as_csv=False)
Calculates the Mean Absolute Percentage Error (MAPE) and its confidence intervals for each device compared to the criterion. Optionally saves the results to a CSV file.
Parameters:
- datadict
A nested dictionary containing the data for each device, feature, and condition.
- criterionstr
A string representing the name of the criterion device.
- deviceslist
A list of strings representing the different devices.
- conditionslist
A list of strings representing the different conditions.
- featureslist
A list of strings representing the different features.
- pathstr or Path
The path where the CSV file will be saved. Can be provided as a string or a Path object from the pathlib module. If not specified, the results are not saved to a file. Default is None.
- alphafloat
Confidence level for the intervals.
- save_as_csvbool
Flag to save the results to a CSV file.
Returns:
- mape_datadict
A nested dictionary containing the MAPE and its confidence intervals.
- wearablehrv.group.mape_plot(mape_data, features, conditions, devices)
Plots a grouped bar chart of Mean Absolute Percentage Error (MAPE) for different devices across all conditions for a selected feature.
This function generates an interactive grouped bar chart that allows the user to select a feature from a dropdown menu. The chart displays the MAPE values for each device across all conditions.
Parameters
- mape_datadict
A dictionary containing the MAPE results, structured as {device: {feature: {condition: {“MAPE”: value}}}}. This structure allows for indexing by device, feature, and condition to retrieve the MAPE values.
- featureslist of str
A list of strings representing the features for which MAPE values are available. The user can select from these features to generate the plot.
- conditionslist of str
A list of strings representing the different experimental conditions. These conditions form the x-axis of the bar chart.
- deviceslist of str
A list of strings representing the different devices. MAPE values for each device are plotted as groups of bars within each condition.
Notes
The bar chart includes a legend indicating the devices, and the MAPE values are expressed as percentages.
- wearablehrv.group.matrix_plot(data, file_names, conditions, features, devices)
This function creates an interactive heatmap plot comparing different devices for the given data, conditions, features, and devices. It uses Seaborn, Matplotlib, and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- file_nameslist
A list of strings containing the file names of the CSV files to be imported.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive heatmap plot.
- wearablehrv.group.nan_handling(data, devices, features, conditions)
This function takes a nested dictionary containing the data and replaces [nan] values with an empty list [].
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- deviceslist
A list of strings representing the different devices used to collect the data.
- featureslist
A list of strings representing the different features of the data.
- conditionslist
A list of strings representing the different experimental conditions of the data.
Returns:
- new_datadict
A nested dictionary with [nan] values replaced with [].
- wearablehrv.group.radar_plot(data, criterion, conditions, devices)
This function creates an interactive radar plot comparing a selected device to a criterion device for the given data, conditions, features, and devices. It uses Plotly and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- criterionstr
The criterion device to be compared with the selected device.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive radar plot.
- wearablehrv.group.regression_analysis(data, criterion, conditions, devices, features, path, save_as_csv=False)
Performs linear regression analysis on the given data against a criterion device for specified conditions, devices, and features. It calculates the regression parameters (slope, intercept, R-value, P-value, and standard error) for each device-feature-condition combination compared to the criterion. Optionally, saves the regression results to a CSV file.
Parameters:
- datadict
A nested dictionary containing the data, organized as {device: {feature: {condition: values}}}. The keys represent devices, features, and conditions, respectively, with values being the data points collected under those criteria.
- criterionstr
The name of the device used as a benchmark or standard for comparison in the regression analysis.
- conditionslist of str
The experimental conditions under which the data was collected. Each condition corresponds to a specific set of circumstances or parameters under which the data points were gathered.
- deviceslist of str
The devices from which data was collected. This list should include the criterion device and any other devices whose data is to be analyzed against the criterion.
- featureslist of str
The features or variables of interest within the data. These could represent different metrics or measurements collected from the devices.
- pathstr or Path, optional
The directory path where the output CSV file containing the regression analysis results will be saved. Can be provided as a string or a Path object from the pathlib module. If not specified, the results are not saved to a file.
- save_as_csvbool, optional
A flag indicating whether to save the regression results to a CSV file. If True, the results are saved to the specified path. If False, the results are not saved to a file. Default is False.
- alphafloat, optional
The confidence level for the confidence intervals in the regression analysis. Default value is set to 0.95, representing a 95% confidence level.
Returns:
- regression_datadict
A nested dictionary containing the regression analysis results for each device-feature-condition combination. The structure is {device: {feature: {condition: {‘slope’: value, ‘intercept’: value, ‘r_value’: value, ‘p_value’: value, ‘std_err’: value}}}}, where each parameter represents the slope, intercept, correlation coefficient, P-value, and standard error of the regression, respectively.
Notes:
This function assumes that the data for each device-feature-condition combination is directly comparable and that linear regression is an appropriate analysis method.
The regression analysis is performed for each device against the criterion for every feature and condition specified.
The function outputs detailed regression results, facilitating the assessment of the linear relationship between the data from each device and the criterion across different conditions and features.
- wearablehrv.group.regression_plot(regression_data, data, criterion, conditions, devices, features, width=15, height_per_condition=4, regression_line_style='-', regression_line_color='black', marker_color='gray', font_size=12, show_grid=True, background_color=None, bonferroni_corrected=False)
This function creates scatter plots for the given regression data, data, conditions, features, and devices. It displays the scatter plots along with regression lines, correlation coefficients, significance values (with an option to indicate if they are Bonferroni corrected), and the number of observations.
Parameters:
- regression_datadict
A nested dictionary containing the regression results (slope, intercept, r_value, p_value, and std_err) for each device and criterion pair, feature, and condition.
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- criterionstr
A string representing the device used as a criterion for comparison.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
- featureslist
A list of strings representing the different features of the data.
- widthint, optional, default: 15
The width of the scatter plot in inches.
- height_per_conditionint, optional, default: 4
The height of each subplot (per condition) in inches.
- regression_line_stylestr, optional, default: ‘-’
The line style for the regression line.
- regression_line_colorstr, optional, default: ‘black’
The color of the regression line.
- marker_colorstr, optional, default: ‘gray’
The color of the data point markers.
- font_sizeint, optional, default: 12
The font size for labels, titles, etc.
- show_gridbool, optional, default: True
Whether to display gridlines on the plot.
- background_colorstr, optional
Background color for the plot, if specified.
- bonferroni_correctedbool, optional, default: False
Indicates if the data has Bonferroni corrected p-values. If True, the function will use Bonferroni corrected p-values for significance annotations.
Returns:
None
- wearablehrv.group.save_data(data, path, conditions, devices, features, file_names)
Saves aggregated data from multiple sources to a CSV file based on specified conditions, devices, and features.
This function compiles data into a single DataFrame and saves it to a CSV file. The data is organized by combining specified conditions, devices, and features into unique column names.
Parameters
- datadict
A nested dictionary with structure {device: {feature: {condition: [values]}}}, representing the data to be saved.
- pathstr or Path
The directory path where the CSV file will be saved. Can be provided as a string or a Path object from the pathlib module.
- conditionslist of str
Experimental conditions under which the data was collected.
- deviceslist of str
Devices used to collect the data.
- featureslist of str
Features present in the data.
- file_nameslist of str
File names corresponding to the participants’ data, used to identify the source files.
Returns
- None
The function does not return any value. It saves the aggregated data into a CSV file named ‘group_data.csv’ in the specified directory.
- wearablehrv.group.signal_quality(data, path, conditions, devices, features, criterion, file_names, exclude=False, save_as_csv=True, ibi_threshold=0.2, artefact_threshold=0.2, manual_missing=False, missing_threshold=10)
Analyze the signal quality of the data and generate a quality report. The function processes data from multiple devices and conditions, and uses a thresholding method to exclude participants with poor signal quality or manually flag data as missing based on the number of detected beats.
Parameters:
- datadict
A nested dictionary containing the data to be analyzed. Keys represent each device, feature, and condition.
- pathstr or Path
The directory path where the quality report CSV files should be saved. Can be provided as a string or a Path object from the pathlib module.
- conditionslist
A list of strings indicating the different experimental conditions in the data.
- deviceslist
A list of strings specifying the different devices used for data collection.
- featureslist
A list of strings describing the different data features.
- criterionstr
The device used as a criterion reference for assessing signal quality.
- file_nameslist
A list of strings containing the participant file names.
- excludebool, optional
A flag indicating whether to exclude participants based on signal quality analysis. Defaults to False.
- save_as_csvbool, optional
A flag indicating whether to save the quality report as CSV files. Defaults to True.
- ibi_thresholdfloat, optional
A threshold for comparing a device’s normalized interbeat interval (nibi) with the criterion nibi. Defaults to 0.20.
- artefact_thresholdfloat, optional
A threshold for comparing a device’s artefact value with the device’s nibi value. Defaults to 0.20.
- manual_missingbool, optional
A flag indicating whether to manually flag data as missing based on the number of detected beats. Defaults to False.
- missing_thresholdint, optional
The threshold for the number of detected beats below which data is flagged as missing when manual_missing is True. Defaults to 10.
Returns:
- tuple(dict, list)
The updated data dictionary after potential participant exclusion based on signal quality analysis, and a list of the remaining data features after the removal of ‘artefact’ and ‘nibi_after_cropping’.
- wearablehrv.group.signal_quality_plot1(summary_df, condition_mapping, criterion, device_selection=False, device=None, criterion_exclusion=True, x_label="'Condition Categories")
Generates a stacked bar plot to visualize data quality by condition category. The function can either display data for all devices or focus on a single specified device, and it has the option to exclude data from the criterion device. The data quality metrics (‘Acceptable’, ‘Missing’, ‘Poor’) are aggregated from the summary DataFrame for each condition category and displayed as percentages.
Parameters:
- summary_dfDataFrame
A pandas DataFrame containing the summary of data quality metrics. It should have a MultiIndex with levels ‘Device’ and ‘Condition’, and columns ‘Acceptable’, ‘Missing’, and ‘Poor’.
- condition_mappingdict
A dictionary mapping each condition to its respective category. Keys should correspond to conditions in summary_df’s index, and values should be the desired category names.
- criterionstr
The name of the criterion device. Used to exclude data from this device if criterion_exclusion is True.
- device_selectionbool, optional
If True, the plot will only display data for the device specified in the ‘device’ parameter. Defaults to False.
- devicestr, optional
The name of the device to focus on if device_selection is True. Ignored if device_selection is False.
- criterion_exclusionbool, optional
If True, data from the criterion device will be excluded from the plot. Defaults to True.
- x_labelstr, optional
The label for the x-axis of the plot. Defaults to “‘Condition Categories’”.
Returns:
- None
This function does not return anything. It displays the generated plot directly.
Notes:
The function first checks for the criterion device in the ‘Device’ level of the summary_df’s MultiIndex. If criterion_exclusion is True, data from this device is excluded. If device_selection is True, the function further filters the summary_df to only include data from the specified device. It then maps each condition to its respective category using the provided condition_mapping and groups the data by these categories. The quality metrics are then converted to percentages and plotted as a stacked bar chart. The function also adds text annotations to the plot to display the percentage values and customizes the plot with labels, title, and legend.
- wearablehrv.group.signal_quality_plot2(summary_df, condition_selection=False, condition=None)
Generates a stacked bar plot to visualize data quality by device. This function allows the option to either display data for all conditions or focus on a single specified condition. It aggregates data quality metrics (‘Acceptable’, ‘Missing’, ‘Poor’) for each device and displays them as percentages.
Parameters:
- summary_dfDataFrame
A pandas DataFrame containing the summary of data quality metrics. It should have a MultiIndex with levels ‘Device’ and ‘Condition’, and columns ‘Acceptable’, ‘Missing’, and ‘Poor’.
- conditionslist
A list of strings representing all the conditions included in the summary_df.
- deviceslist
A list of strings representing all the devices included in the summary_df.
- condition_selectionbool, optional
If True, the plot will only display data for the condition specified in the ‘condition’ parameter. Defaults to False.
- conditionstr, optional
The name of the condition to focus on if condition_selection is True. Ignored if condition_selection is False.
Returns:
- None
This function does not return anything. It displays the generated plot directly.
Notes:
The function checks if condition_selection is True. If so, it filters the summary_df to only include data for the specified condition. It then groups the data by ‘Device’ and calculates the sum of ‘Acceptable’, ‘Missing’, and ‘Poor’ metrics for each device. These counts are converted to percentages and plotted as a stacked bar chart. The function also adds text annotations to the plot for clarity and customizes the plot with a title, labels, and a legend. The legend is moved outside of the plot to avoid obscuring any data.
- wearablehrv.group.violin_plot(data, conditions, features, devices)
This function creates an interactive violin plot comparing different devices for the given data, conditions, features, and devices. It uses Plotly and Jupyter widgets for visualization and user interaction.
Parameters:
- datadict
A nested dictionary containing the data, with keys for devices, features, and conditions.
- conditionslist
A list of strings representing the different experimental conditions of the data.
- featureslist
A list of strings representing the different features of the data.
- deviceslist
A list of strings representing the different devices used to collect the data.
Returns:
- None
The function directly creates and displays the interactive violin plot.