gaitsetpy.dataset.mobifall

MobiFall Dataset Loader. Maintainer: @aharshit123456

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

  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, max_workers: int = 8):
 24        """
 25        Initialize MobiFall loader with concurrent download support.
 26        
 27        Args:
 28            max_workers: Maximum number of concurrent download threads (default: 8)
 29        """
 30        super().__init__(
 31            name="mobifall",
 32            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection",
 33            max_workers=max_workers
 34        )
 35        self.metadata = {
 36            'sensors': ['accelerometer', 'gyroscope'],
 37            'components': ['x', 'y', 'z'],
 38            'sampling_frequency': 100,  # Typical for MobiFall
 39            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
 40        }
 41    
 42    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
 43        """
 44        Load MobiFall dataset from the specified directory.
 45        
 46        Args:
 47            data_dir: Directory to store/find the dataset
 48            **kwargs: Additional arguments (unused for MobiFall)
 49            
 50        Returns:
 51            Tuple of (data_list, names_list)
 52        """
 53        # TODO: Implement MobiFall data loading
 54        # This is a placeholder implementation
 55        print("MobiFall data loading is not yet implemented")
 56        return [], []
 57    
 58    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 
 59                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
 60        """
 61        Create sliding windows from the MobiFall dataset.
 62        
 63        Args:
 64            data: List of DataFrames containing MobiFall data
 65            names: List of names corresponding to the data
 66            window_size: Size of the sliding window (default: 192)
 67            step_size: Step size for the sliding window (default: 32)
 68            
 69        Returns:
 70            List of dictionaries containing sliding windows for each DataFrame
 71        """
 72        # TODO: Implement MobiFall sliding window creation
 73        # This is a placeholder implementation
 74        print("MobiFall sliding window creation is not yet implemented")
 75        return []
 76    
 77    def get_supported_formats(self) -> List[str]:
 78        """
 79        Get list of supported file formats for MobiFall dataset.
 80        
 81        Returns:
 82            List of supported file extensions
 83        """
 84        return ['.csv', '.txt']
 85    
 86    def get_sensor_info(self) -> Dict[str, List[str]]:
 87        """
 88        Get information about sensors in the dataset.
 89        
 90        Returns:
 91            Dictionary containing sensor information
 92        """
 93        return {
 94            'sensors': self.metadata['sensors'],
 95            'components': self.metadata['components'],
 96            'sampling_frequency': self.metadata['sampling_frequency']
 97        }
 98    
 99    def get_activity_info(self) -> List[str]:
100        """
101        Get information about activities in the dataset.
102        
103        Returns:
104            List of activity types
105        """
106        return self.metadata['activities']
107
108
109# Legacy function wrapper for backward compatibility
110def load_mobifall_data():
111    """
112    Legacy function for loading MobiFall data.
113    
114    Returns:
115        Tuple of (data_list, names_list)
116    """
117    loader = MobiFallLoader()
118    return loader.load_data("")
class MobiFallLoader(gaitsetpy.core.base_classes.BaseDatasetLoader):
 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, max_workers: int = 8):
 25        """
 26        Initialize MobiFall loader with concurrent download support.
 27        
 28        Args:
 29            max_workers: Maximum number of concurrent download threads (default: 8)
 30        """
 31        super().__init__(
 32            name="mobifall",
 33            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection",
 34            max_workers=max_workers
 35        )
 36        self.metadata = {
 37            'sensors': ['accelerometer', 'gyroscope'],
 38            'components': ['x', 'y', 'z'],
 39            'sampling_frequency': 100,  # Typical for MobiFall
 40            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
 41        }
 42    
 43    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
 44        """
 45        Load MobiFall dataset from the specified directory.
 46        
 47        Args:
 48            data_dir: Directory to store/find the dataset
 49            **kwargs: Additional arguments (unused for MobiFall)
 50            
 51        Returns:
 52            Tuple of (data_list, names_list)
 53        """
 54        # TODO: Implement MobiFall data loading
 55        # This is a placeholder implementation
 56        print("MobiFall data loading is not yet implemented")
 57        return [], []
 58    
 59    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 
 60                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
 61        """
 62        Create sliding windows from the MobiFall dataset.
 63        
 64        Args:
 65            data: List of DataFrames containing MobiFall data
 66            names: List of names corresponding to the data
 67            window_size: Size of the sliding window (default: 192)
 68            step_size: Step size for the sliding window (default: 32)
 69            
 70        Returns:
 71            List of dictionaries containing sliding windows for each DataFrame
 72        """
 73        # TODO: Implement MobiFall sliding window creation
 74        # This is a placeholder implementation
 75        print("MobiFall sliding window creation is not yet implemented")
 76        return []
 77    
 78    def get_supported_formats(self) -> List[str]:
 79        """
 80        Get list of supported file formats for MobiFall dataset.
 81        
 82        Returns:
 83            List of supported file extensions
 84        """
 85        return ['.csv', '.txt']
 86    
 87    def get_sensor_info(self) -> Dict[str, List[str]]:
 88        """
 89        Get information about sensors in the dataset.
 90        
 91        Returns:
 92            Dictionary containing sensor information
 93        """
 94        return {
 95            'sensors': self.metadata['sensors'],
 96            'components': self.metadata['components'],
 97            'sampling_frequency': self.metadata['sampling_frequency']
 98        }
 99    
100    def get_activity_info(self) -> List[str]:
101        """
102        Get information about activities in the dataset.
103        
104        Returns:
105            List of activity types
106        """
107        return self.metadata['activities']

MobiFall dataset loader class.

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

MobiFallLoader(max_workers: int = 8)
24    def __init__(self, max_workers: int = 8):
25        """
26        Initialize MobiFall loader with concurrent download support.
27        
28        Args:
29            max_workers: Maximum number of concurrent download threads (default: 8)
30        """
31        super().__init__(
32            name="mobifall",
33            description="MobiFall Dataset - Contains accelerometer and gyroscope data for fall detection",
34            max_workers=max_workers
35        )
36        self.metadata = {
37            'sensors': ['accelerometer', 'gyroscope'],
38            'components': ['x', 'y', 'z'],
39            'sampling_frequency': 100,  # Typical for MobiFall
40            'activities': ['ADL', 'FALL']  # Activities of Daily Living and Falls
41        }

Initialize MobiFall loader with concurrent download support.

Args: max_workers: Maximum number of concurrent download threads (default: 8)

metadata
def load_data( self, data_dir: str, **kwargs) -> Tuple[List[pandas.core.frame.DataFrame], List[str]]:
43    def load_data(self, data_dir: str, **kwargs) -> Tuple[List[pd.DataFrame], List[str]]:
44        """
45        Load MobiFall dataset from the specified directory.
46        
47        Args:
48            data_dir: Directory to store/find the dataset
49            **kwargs: Additional arguments (unused for MobiFall)
50            
51        Returns:
52            Tuple of (data_list, names_list)
53        """
54        # TODO: Implement MobiFall data loading
55        # This is a placeholder implementation
56        print("MobiFall data loading is not yet implemented")
57        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]:
59    def create_sliding_windows(self, data: List[pd.DataFrame], names: List[str], 
60                             window_size: int = 192, step_size: int = 32) -> List[Dict]:
61        """
62        Create sliding windows from the MobiFall dataset.
63        
64        Args:
65            data: List of DataFrames containing MobiFall data
66            names: List of names corresponding to the data
67            window_size: Size of the sliding window (default: 192)
68            step_size: Step size for the sliding window (default: 32)
69            
70        Returns:
71            List of dictionaries containing sliding windows for each DataFrame
72        """
73        # TODO: Implement MobiFall sliding window creation
74        # This is a placeholder implementation
75        print("MobiFall sliding window creation is not yet implemented")
76        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]:
78    def get_supported_formats(self) -> List[str]:
79        """
80        Get list of supported file formats for MobiFall dataset.
81        
82        Returns:
83            List of supported file extensions
84        """
85        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]]:
87    def get_sensor_info(self) -> Dict[str, List[str]]:
88        """
89        Get information about sensors in the dataset.
90        
91        Returns:
92            Dictionary containing sensor information
93        """
94        return {
95            'sensors': self.metadata['sensors'],
96            'components': self.metadata['components'],
97            'sampling_frequency': self.metadata['sampling_frequency']
98        }

Get information about sensors in the dataset.

Returns: Dictionary containing sensor information

def get_activity_info(self) -> List[str]:
100    def get_activity_info(self) -> List[str]:
101        """
102        Get information about activities in the dataset.
103        
104        Returns:
105            List of activity types
106        """
107        return self.metadata['activities']

Get information about activities in the dataset.

Returns: List of activity types

def load_mobifall_data():
111def load_mobifall_data():
112    """
113    Legacy function for loading MobiFall data.
114    
115    Returns:
116        Tuple of (data_list, names_list)
117    """
118    loader = MobiFallLoader()
119    return loader.load_data("")

Legacy function for loading MobiFall data.

Returns: Tuple of (data_list, names_list)