gaitsetpy.dataset.mobifall API documentation

# gaitsetpy.dataset.mobifall

MobiFall Dataset Loader. Maintainer: @aharshit123456

This file contains the MobiFall dataset loader class that inherits from BaseDatasetLoader.

View Source

      1'''
      2MobiFall Dataset Loader.
      3Maintainer: @aharshit123456
      4
      5This file contains the MobiFall dataset loader class that inherits from BaseDatasetLoader.
      6'''
      7
      8import os
      9import pandas as pd
     10import numpy as np
     11from typing import List, Dict, Tuple
     12from ..core.base_classes import BaseDatasetLoader
     13from .utils import download_dataset, extract_dataset, sliding_window
     14
     15
     16class MobiFallLoader(BaseDatasetLoader):
     17    """
     18    MobiFall dataset loader class.
     19
     20    This class handles loading and processing of the MobiFall dataset for gait analysis.
     21    """
     22
     23    def __init__(self):
     24        super().__init__(
     25            name="mobifall",
     26            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection"
     27        )
     28        self.metadata = {
     29            'sensors': ['accelerometer', 'gyroscope'],
     30            'components': ['x', 'y', 'z'],
     31            'sampling_frequency': 100,  # Typical for MobiFall
     32            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
     33        }
     34
     35    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
     36        """
     37        Load MobiFall dataset from the specified directory.
     38
     39        Args:
     40            data_dir: Directory to store/find the dataset
     41            **kwargs: Additional arguments (unused for MobiFall)
     42
     43        Returns:
     44            Tuple of (data_list, names_list)
     45        """
     46        # TODO: Implement MobiFall data loading
     47        # This is a placeholder implementation
     48        print("MobiFall data loading is not yet implemented")
     49        return [], []
     50
     51    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str],
     52                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
     53        """
     54        Create sliding windows from the MobiFall dataset.
     55
     56        Args:
     57            data: List of DataFrames containing MobiFall data
     58            names: List of names corresponding to the data
     59            window_size: Size of the sliding window (default: 192)
     60            step_size: Step size for the sliding window (default: 32)
     61
     62        Returns:
     63            List of dictionaries containing sliding windows for each DataFrame
     64        """
     65        # TODO: Implement MobiFall sliding window creation
     66        # This is a placeholder implementation
     67        print("MobiFall sliding window creation is not yet implemented")
     68        return []
     69
     70    def get_supported_formats(self) -> List[str]:
     71        """
     72        Get list of supported file formats for MobiFall dataset.
     73
     74        Returns:
     75            List of supported file extensions
     76        """
     77        return ['.csv', '.txt']
     78
     79    def get_sensor_info(self) -> Dict[str, List[str]]:
     80        """
     81        Get information about sensors in the dataset.
     82
     83        Returns:
     84            Dictionary containing sensor information
     85        """
     86        return {
     87            'sensors': self.metadata['sensors'],
     88            'components': self.metadata['components'],
     89            'sampling_frequency': self.metadata['sampling_frequency']
     90        }
     91
     92    def get_activity_info(self) -> List[str]:
     93        """
     94        Get information about activities in the dataset.
     95
     96        Returns:
     97            List of activity types
     98        """
     99        return self.metadata['activities']
    100
    101
    102# Legacy function wrapper for backward compatibility
    103def load_mobifall_data():
    104    """
    105    Legacy function for loading MobiFall data.
    106
    107    Returns:
    108        Tuple of (data_list, names_list)
    109    """
    110    loader = MobiFallLoader()
    111    return loader.load_data("")

class MobiFallLoader(gaitsetpy.core.base_classes.BaseDatasetLoader): View Source

     17class MobiFallLoader(BaseDatasetLoader):
     18    """
     19    MobiFall dataset loader class.
     20
     21    This class handles loading and processing of the MobiFall dataset for gait analysis.
     22    """
     23
     24    def __init__(self):
     25        super().__init__(
     26            name="mobifall",
     27            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection"
     28        )
     29        self.metadata = {
     30            'sensors': ['accelerometer', 'gyroscope'],
     31            'components': ['x', 'y', 'z'],
     32            'sampling_frequency': 100,  # Typical for MobiFall
     33            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
     34        }
     35
     36    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
     37        """
     38        Load MobiFall dataset from the specified directory.
     39
     40        Args:
     41            data_dir: Directory to store/find the dataset
     42            **kwargs: Additional arguments (unused for MobiFall)
     43
     44        Returns:
     45            Tuple of (data_list, names_list)
     46        """
     47        # TODO: Implement MobiFall data loading
     48        # This is a placeholder implementation
     49        print("MobiFall data loading is not yet implemented")
     50        return [], []
     51
     52    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str],
     53                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
     54        """
     55        Create sliding windows from the MobiFall dataset.
     56
     57        Args:
     58            data: List of DataFrames containing MobiFall data
     59            names: List of names corresponding to the data
     60            window_size: Size of the sliding window (default: 192)
     61            step_size: Step size for the sliding window (default: 32)
     62
     63        Returns:
     64            List of dictionaries containing sliding windows for each DataFrame
     65        """
     66        # TODO: Implement MobiFall sliding window creation
     67        # This is a placeholder implementation
     68        print("MobiFall sliding window creation is not yet implemented")
     69        return []
     70
     71    def get_supported_formats(self) -> List[str]:
     72        """
     73        Get list of supported file formats for MobiFall dataset.
     74
     75        Returns:
     76            List of supported file extensions
     77        """
     78        return ['.csv', '.txt']
     79
     80    def get_sensor_info(self) -> Dict[str, List[str]]:
     81        """
     82        Get information about sensors in the dataset.
     83
     84        Returns:
     85            Dictionary containing sensor information
     86        """
     87        return {
     88            'sensors': self.metadata['sensors'],
     89            'components': self.metadata['components'],
     90            'sampling_frequency': self.metadata['sampling_frequency']
     91        }
     92
     93    def get_activity_info(self) -> List[str]:
     94        """
     95        Get information about activities in the dataset.
     96
     97        Returns:
     98            List of activity types
     99        """
    100        return self.metadata['activities']

MobiFall dataset loader class.

This class handles loading and processing of the MobiFall dataset for gait analysis.

MobiFallLoader() View Source

    24    def __init__(self):
    25        super().__init__(
    26            name="mobifall",
    27            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection"
    28        )
    29        self.metadata = {
    30            'sensors': ['accelerometer', 'gyroscope'],
    31            'components': ['x', 'y', 'z'],
    32            'sampling_frequency': 100,  # Typical for MobiFall
    33            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
    34        }

Initialize the dataset loader.

Args: name: Name of the dataset description: Description of the dataset

metadata
def load_data( self, data_dir: str, **kwargs) -> Tuple[List[pandas.core.frame.DataFrame], List[str]]: View Source

    36    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
    37        """
    38        Load MobiFall dataset from the specified directory.
    39
    40        Args:
    41            data_dir: Directory to store/find the dataset
    42            **kwargs: Additional arguments (unused for MobiFall)
    43
    44        Returns:
    45            Tuple of (data_list, names_list)
    46        """
    47        # TODO: Implement MobiFall data loading
    48        # This is a placeholder implementation
    49        print("MobiFall data loading is not yet implemented")
    50        return [], []

Load MobiFall dataset from the specified directory.

Args: data_dir: Directory to store/find the dataset **kwargs: Additional arguments (unused for MobiFall)

Returns: Tuple of (data_list, names_list)

def create_sliding_windows( self, data: List[pandas.core.frame.DataFrame], names: List[str], window_size: int = 192, step_size: int = 32) -> List[Dict]: View Source

    52    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str],
    53                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
    54        """
    55        Create sliding windows from the MobiFall dataset.
    56
    57        Args:
    58            data: List of DataFrames containing MobiFall data
    59            names: List of names corresponding to the data
    60            window_size: Size of the sliding window (default: 192)
    61            step_size: Step size for the sliding window (default: 32)
    62
    63        Returns:
    64            List of dictionaries containing sliding windows for each DataFrame
    65        """
    66        # TODO: Implement MobiFall sliding window creation
    67        # This is a placeholder implementation
    68        print("MobiFall sliding window creation is not yet implemented")
    69        return []

Create sliding windows from the MobiFall dataset.

Args: data: List of DataFrames containing MobiFall data names: List of names corresponding to the data window_size: Size of the sliding window (default: 192) step_size: Step size for the sliding window (default: 32)

Returns: List of dictionaries containing sliding windows for each DataFrame

def get_supported_formats(self) -> List[str]: View Source

    71    def get_supported_formats(self) -> List[str]:
    72        """
    73        Get list of supported file formats for MobiFall dataset.
    74
    75        Returns:
    76            List of supported file extensions
    77        """
    78        return ['.csv', '.txt']

Get list of supported file formats for MobiFall dataset.

Returns: List of supported file extensions

def get_sensor_info(self) -> Dict[str, List[str]]: View Source

    80    def get_sensor_info(self) -> Dict[str, List[str]]:
    81        """
    82        Get information about sensors in the dataset.
    83
    84        Returns:
    85            Dictionary containing sensor information
    86        """
    87        return {
    88            'sensors': self.metadata['sensors'],
    89            'components': self.metadata['components'],
    90            'sampling_frequency': self.metadata['sampling_frequency']
    91        }

Get information about sensors in the dataset.

Returns: Dictionary containing sensor information

def get_activity_info(self) -> List[str]: View Source

     93    def get_activity_info(self) -> List[str]:
     94        """
     95        Get information about activities in the dataset.
     96
     97        Returns:
     98            List of activity types
     99        """
    100        return self.metadata['activities']

Get information about activities in the dataset.

Returns: List of activity types

##### Inherited Members

gaitsetpy.core.base_classes.BaseDatasetLoader
  name
  description
  data
  get_info

def load_mobifall_data(): View Source

    104def load_mobifall_data():
    105    """
    106    Legacy function for loading MobiFall data.
    107
    108    Returns:
    109        Tuple of (data_list, names_list)
    110    """
    111    loader = MobiFallLoader()
    112    return loader.load_data("")

Legacy function for loading MobiFall data.

Returns: Tuple of (data_list, names_list)