-
Notifications
You must be signed in to change notification settings - Fork 3
Save/load config settings #108
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: butter_filter
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Utility functions for miniscope-io.""" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i have blanket objects to the existence of it is true that sometimes things don't have an obvious place, so a single, short |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Configuration utilities for miniscope-io.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from mio.models.process import DenoiseConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def update_config_from_json(config: DenoiseConfig, json_path: Path) -> DenoiseConfig: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Update DenoiseConfig from a processing_log.json file.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with open(json_path) as f: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log_data = json.load(f) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+12
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally all i/o operations are separated from processing actions (so, e.g., we wouldn't need to write to a temporary |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Get most recent processing run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proc_config = log_data["processing_runs"][-1]["processing_config"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update noise patch config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.noise_patch.enable = proc_config["noise_patch"]["enabled"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.noise_patch.enable: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.noise_patch.method = proc_config["noise_patch"]["method"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if proc_config["noise_patch"]["gradient_config"]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.noise_patch.gradient_config.threshold = proc_config["noise_patch"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "gradient_config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]["threshold"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if proc_config["noise_patch"]["black_area_config"]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.noise_patch.black_area_config.consecutive_threshold = proc_config["noise_patch"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "black_area_config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]["consecutive_threshold"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.noise_patch.black_area_config.value_threshold = proc_config["noise_patch"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "black_area_config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]["value_threshold"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update frequency masking config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.frequency_masking.enable = proc_config["frequency_masking"]["enabled"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.frequency_masking.enable: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.frequency_masking.cast_float32 = proc_config["frequency_masking"]["cast_float32"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.frequency_masking.spatial_LPF_cutoff_radius = proc_config["frequency_masking"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "cutoff_radius" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.frequency_masking.vertical_BEF_cutoff = proc_config["frequency_masking"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "vertical_BEF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.frequency_masking.horizontal_BEF_cutoff = proc_config["frequency_masking"][ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "horizontal_BEF" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update butterworth config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.butter_filter.enable = proc_config["butterworth"]["enabled"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if config.butter_filter.enable: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.butter_filter.order = proc_config["butterworth"]["order"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.butter_filter.cutoff_frequency = proc_config["butterworth"]["cutoff_frequency"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| config.butter_filter.sampling_rate = proc_config["butterworth"]["sampling_rate"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+52
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same problem as above, lack of generality, need for maintenance if model changes.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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 don't think we should do this for a few reasons, not to belabor the point but we should not need to log what our config was after the fact, we should already know that because we already supplied it when we invoked it! it might be nice to offer, but i would really want to just make a structured model for outputs and have this be a part of that. ad-hoc layouts and formats are not gr8 in general.
but anyway, you'd want this to be like:
no reason to change the keys like this when we're saving the config, might as well just dump the whole thing which has 100% of the information that the config has by definition, and is in a format that can be roundtripped if needed. doing it like this would mean that every time we changed the model, we would need to remember to update this.