-
Notifications
You must be signed in to change notification settings - Fork 241
Refactor artifacts detection + add sturation detection #4297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor artifacts detection + add sturation detection #4297
Conversation
|
@samuelgarcia do not forget, in this PR, to change DetectThresholdCrossing(recording, ...) to DetectThresholdCrossing(envelope, ...) in the detec_period_artefacts_by_envelope |
|
Hi @oliche @JoeZiminski I think we do not need to scaled traces at each chunk we could only could the unscaled threhold in the init and then we could avoid the costly convertion to float32 or float64. Also I put the unit in uV to be more SI friendly. |
|
@alejoe91 @chrishalcrow ready to review on my side |
| self, recording, periods=artifacts, mode=mode, noise_levels=noise_levels, seed=seed, **noise_levels_kwargs | ||
| ) | ||
| # note self._kwargs["periods"] is done by SilencedPeriodsRecording and so the computaion is done once | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add detect_artifact_method detect_artifact_kwargs
| * 'saturation' using detect_artifact_periods_by_envelope() | ||
| * 'envelope' using detect_saturation_periods() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * 'saturation' using detect_artifact_periods_by_envelope() | |
| * 'envelope' using detect_saturation_periods() | |
| * 'saturation' using detect_saturation_periods() | |
| * 'envelope' using detect_artifact_periods_by_envelope() |
| # from spikeinterface.core.core_tools import define_function_handling_dict_from_class | ||
| # from spikeinterface.preprocessing.silence_periods import SilencedPeriodsRecording |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # from spikeinterface.core.core_tools import define_function_handling_dict_from_class | |
| # from spikeinterface.preprocessing.silence_periods import SilencedPeriodsRecording |
| proportion : | ||
| mute_window_samples : | ||
| job_kwargs : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oups
|
Hello, trying this out on real data with saturation. I get this output artifact_periods=array([(0, 637721, 638769), (0, 638955, 639206), (0, 923219, 923602),
(0, 923605, 923606), (0, 923607, 923835)],Are these periods inclusive? And if they are, should the last pair be merged? |
|
|
||
| def detect_saturation_periods( | ||
| recording, | ||
| saturation_threshold_uV, # 1200 uV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it assumed that saturation_threshold_uV is symmetric around 0uV? E.g. you'll get saturation at $\pm 1200$uV? Is this always the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's how saturation works, at least for int16. Maybe we can make a symmetric arguments?
|
Hey @samuelgarcia thanks for this! will check this out tomorrow. I accidentally did not push two tidy-up commits to #4301, do you mind if I push to your branch to add some changes? I think it is mostly superficial stuff like docstrings etc. |
Yes, the last pair should be merged. |
yes of course. push anything you want |
@JoeZiminski @oliche
This refactor the artifact detection and blanking
detect_artifact_periods()time to be used in preprocess dict (@chrishalcrow this is for you)
Could also be done in this PR:
To be done in 2 futures PR: