@@ -41,6 +41,7 @@ def run(
4141 epoch_length : float = 5 ,
4242 activity_metric : Sequence [Literal ["enmo" , "mad" , "ag_count" , "mims" ]] = ["enmo" ],
4343 nonwear_algorithm : Sequence [Literal ["ggir" , "cta" , "detach" ]] = ["ggir" ],
44+ allow_duplicates : bool = False ,
4445 verbosity : int = logging .WARNING ,
4546 output_filetype : Literal [".csv" , ".parquet" ] = ".csv" ,
4647) -> Union [writers .OrchestratorResults , Dict [str , writers .OrchestratorResults ]]:
@@ -70,6 +71,7 @@ def run(
7071 activity_metric: The metric(s) to be used for physical activity categorization.
7172 Multiple metrics can be specified as a sequence.
7273 nonwear_algorithm: The algorithm to be used for nonwear detection.
74+ allow_duplicates: Whether to allow duplicate timestamps in the sensor data.
7375 verbosity: The logging level for the logger.
7476 output_filetype: Specifies the data format for the save files. Only used when
7577 processing directories.
@@ -133,6 +135,7 @@ def run(
133135 activity_metric = activity_metric ,
134136 verbosity = verbosity ,
135137 nonwear_algorithm = nonwear_algorithm ,
138+ allow_duplicates = allow_duplicates ,
136139 )
137140
138141 return _run_directory (
@@ -145,6 +148,7 @@ def run(
145148 verbosity = verbosity ,
146149 output_filetype = output_filetype ,
147150 nonwear_algorithm = nonwear_algorithm ,
151+ allow_duplicates = allow_duplicates ,
148152 )
149153
150154
@@ -161,6 +165,7 @@ def _run_directory(
161165 verbosity : int = logging .WARNING ,
162166 output_filetype : Literal [".csv" , ".parquet" ] = ".csv" ,
163167 activity_metric : Sequence [Literal ["enmo" , "mad" , "ag_count" , "mims" ]] = ["enmo" ],
168+ allow_duplicates : bool = False ,
164169) -> Dict [str , writers .OrchestratorResults ]:
165170 """Runs main processing steps for wristpy on directories.
166171
@@ -186,6 +191,7 @@ def _run_directory(
186191 output_filetype: Specifies the data format for the save files.
187192 activity_metric: The metric(s) to be used for physical activity categorization.
188193 Multiple metrics can be specified as a sequence.
194+ allow_duplicates: Whether to allow duplicate timestamps in the sensor data.
189195
190196 Returns:
191197 All calculated data in a save ready format as a dictionary of
@@ -256,6 +262,7 @@ def _run_directory(
256262 verbosity = verbosity ,
257263 nonwear_algorithm = nonwear_algorithm ,
258264 activity_metric = activity_metric ,
265+ allow_duplicates = allow_duplicates ,
259266 )
260267 except Exception as e :
261268 logger .error ("Did not run file: %s, Error: %s" , file , e )
@@ -275,6 +282,7 @@ def _run_file(
275282 epoch_length : float = 5.0 ,
276283 activity_metric : Sequence [Literal ["enmo" , "mad" , "ag_count" , "mims" ]] = ["enmo" ],
277284 nonwear_algorithm : Sequence [Literal ["ggir" , "cta" , "detach" ]] = ["ggir" ],
285+ allow_duplicates : bool = False ,
278286 verbosity : int = logging .WARNING ,
279287) -> writers .OrchestratorResults :
280288 """Runs main processing steps for wristpy and returns data for analysis.
@@ -303,6 +311,10 @@ def _run_file(
303311 Multiple metrics can be specified as a sequence.
304312 nonwear_algorithm: The algorithm to be used for nonwear detection. A sequence of
305313 algorithms can be provided. If so, a majority vote will be taken.
314+ allow_duplicates: Whether to allow duplicate timestamps in the sensor data.
315+ If set to True, no error will be raised and we will keep only the unique
316+ timestamps and their associated sensor values. The first occurrence of each
317+ timestamp is kept.
306318 verbosity: The logging level for the logger.
307319
308320 Returns:
@@ -346,7 +358,7 @@ def _run_file(
346358 logger .error (msg )
347359 raise ValueError (msg )
348360
349- watch_data = readers .read_watch_data (input )
361+ watch_data = readers .read_watch_data (input , allow_duplicates = allow_duplicates )
350362
351363 if calibrator is None :
352364 logger .debug ("Running without calibration" )
0 commit comments