@@ -692,6 +692,11 @@ def _noise_level_chunk(segment_index, start_frame, end_frame, worker_ctx):
692692 noise_levels = np .median (np .abs (one_chunk - med ), axis = 0 ) / 0.6744897501960817
693693 elif worker_ctx ["method" ] == "std" :
694694 noise_levels = np .std (one_chunk , axis = 0 )
695+ elif worker_ctx ["method" ] == "rms" :
696+ # sqrt(1/n * (x0^2 + ... + xn^2))
697+ squared_voltages = np .square (one_chunk )
698+ summed_squared_voltages = np .sum (squared_voltages , axis = 0 )
699+ noise_levels = np .sqrt (summed_squared_voltages / one_chunk .shape [0 ])
695700
696701 return noise_levels
697702
@@ -708,7 +713,7 @@ def get_noise_levels(
708713 recording : "BaseRecording" ,
709714 return_scaled : bool | None = None ,
710715 return_in_uV : bool = True ,
711- method : Literal ["mad" , "std" ] = "mad" ,
716+ method : Literal ["mad" , "std" , "rms" ] = "mad" ,
712717 force_recompute : bool = False ,
713718 random_slices_kwargs : dict = {},
714719 ** kwargs ,
@@ -733,7 +738,7 @@ def get_noise_levels(
733738 DEPRECATED. Use return_in_uV instead.
734739 return_in_uV : bool, default: True
735740 If True, returned noise levels are scaled to uV
736- method : "mad" | "std", default: "mad"
741+ method : "mad" | "std" | "rms" , default: "mad"
737742 The method to use to estimate noise levels
738743 force_recompute : bool
739744 If True, noise levels are recomputed even if they are already stored in the recording extractor
0 commit comments