@@ -380,7 +380,8 @@ def write_to_h5_dataset_format(
380380 chunk_memory = "500M" ,
381381 verbose = False ,
382382 auto_cast_uint = True ,
383- return_scaled = False ,
383+ return_scaled = None ,
384+ return_in_uV = False ,
384385):
385386 """
386387 Save the traces of a recording extractor in an h5 dataset.
@@ -414,7 +415,11 @@ def write_to_h5_dataset_format(
414415 If True, output is verbose (when chunks are used)
415416 auto_cast_uint : bool, default: True
416417 If True, unsigned integers are automatically cast to int if the specified dtype is signed
417- return_scaled : bool, default: False
418+ return_scaled : bool | None, default: None
419+ DEPRECATED. Use return_in_uV instead.
420+ If True and the recording has scaling (gain_to_uV and offset_to_uV properties),
421+ traces are dumped to uV
422+ return_in_uV : bool, default: False
418423 If True and the recording has scaling (gain_to_uV and offset_to_uV properties),
419424 traces are dumped to uV
420425 """
@@ -459,7 +464,15 @@ def write_to_h5_dataset_format(
459464 chunk_size = ensure_chunk_size (recording , chunk_size = chunk_size , chunk_memory = chunk_memory , n_jobs = 1 )
460465
461466 if chunk_size is None :
462- traces = recording .get_traces (cast_unsigned = cast_unsigned , return_scaled = return_scaled )
467+ # Handle deprecated return_scaled parameter
468+ if return_scaled is not None :
469+ warnings .warn (
470+ "`return_scaled` is deprecated and will be removed in a future version. Use `return_in_uV` instead." ,
471+ category = DeprecationWarning ,
472+ )
473+ return_in_uV = return_scaled
474+
475+ traces = recording .get_traces (cast_unsigned = cast_unsigned , return_scaled = return_in_uV )
463476 if dtype is not None :
464477 traces = traces .astype (dtype_file , copy = False )
465478 if time_axis == 1 :
@@ -484,7 +497,7 @@ def write_to_h5_dataset_format(
484497 start_frame = i * chunk_size ,
485498 end_frame = min ((i + 1 ) * chunk_size , num_frames ),
486499 cast_unsigned = cast_unsigned ,
487- return_scaled = return_scaled ,
500+ return_scaled = return_in_uV if return_scaled is None else return_scaled ,
488501 )
489502 chunk_frames = traces .shape [0 ]
490503 if dtype is not None :
@@ -599,7 +612,9 @@ def get_random_recording_slices(
599612 return recording_slices
600613
601614
602- def get_random_data_chunks (recording , return_scaled = False , concatenated = True , ** random_slices_kwargs ):
615+ def get_random_data_chunks (
616+ recording , return_scaled = None , return_in_uV = False , concatenated = True , ** random_slices_kwargs
617+ ):
603618 """
604619 Extract random chunks across segments.
605620
@@ -636,7 +651,7 @@ def get_random_data_chunks(recording, return_scaled=False, concatenated=True, **
636651 start_frame = start_frame ,
637652 end_frame = end_frame ,
638653 segment_index = segment_index ,
639- return_scaled = return_scaled ,
654+ return_scaled = return_in_uV if return_scaled is None else return_scaled ,
640655 )
641656 chunk_list .append (traces_chunk )
642657
@@ -713,17 +728,18 @@ def _noise_level_chunk(segment_index, start_frame, end_frame, worker_ctx):
713728 return noise_levels
714729
715730
716- def _noise_level_chunk_init (recording , return_scaled , method ):
731+ def _noise_level_chunk_init (recording , return_in_uV , method ):
717732 worker_ctx = {}
718733 worker_ctx ["recording" ] = recording
719- worker_ctx ["return_scaled" ] = return_scaled
734+ worker_ctx ["return_scaled" ] = return_in_uV
720735 worker_ctx ["method" ] = method
721736 return worker_ctx
722737
723738
724739def get_noise_levels (
725740 recording : "BaseRecording" ,
726- return_scaled : bool = True ,
741+ return_scaled : bool | None = None ,
742+ return_in_uV : bool = True ,
727743 method : Literal ["mad" , "std" ] = "mad" ,
728744 force_recompute : bool = False ,
729745 random_slices_kwargs : dict = {},
@@ -745,7 +761,10 @@ def get_noise_levels(
745761
746762 recording : BaseRecording
747763 The recording extractor to get noise levels
748- return_scaled : bool
764+ return_scaled : bool | None, default: None
765+ DEPRECATED. Use return_in_uV instead.
766+ If True, returned noise levels are scaled to uV
767+ return_in_uV : bool, default: True
749768 If True, returned noise levels are scaled to uV
750769 method : "mad" | "std", default: "mad"
751770 The method to use to estimate noise levels
@@ -763,7 +782,15 @@ def get_noise_levels(
763782 Noise levels for each channel
764783 """
765784
766- if return_scaled :
785+ # Handle deprecated return_scaled parameter
786+ if return_scaled is not None :
787+ warnings .warn (
788+ "`return_scaled` is deprecated and will be removed in a future version. Use `return_in_uV` instead." ,
789+ category = DeprecationWarning ,
790+ )
791+ return_in_uV = return_scaled
792+
793+ if return_in_uV :
767794 key = f"noise_level_{ method } _scaled"
768795 else :
769796 key = f"noise_level_{ method } _raw"
@@ -797,7 +824,7 @@ def append_noise_chunk(res):
797824
798825 func = _noise_level_chunk
799826 init_func = _noise_level_chunk_init
800- init_args = (recording , return_scaled , method )
827+ init_args = (recording , return_in_uV , method )
801828 executor = ChunkRecordingExecutor (
802829 recording ,
803830 func ,
0 commit comments