-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate a config with smoothing deactivated
- Loading branch information
1 parent
6a6af2a
commit bea8240
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/depiction_targeted_preproc/workflow/exp/prepare_calibration_config_with_no_smoothing.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import cyclopts | ||
import yaml | ||
from pathlib import Path | ||
|
||
from depiction.tools.calibrate.config import ( | ||
CalibrationConfig, | ||
CalibrationRegressShiftConfig, | ||
CalibrationChemicalPeptideNoiseConfig, | ||
CalibrationMCCConfig, | ||
CalibrationConstantGlobalShiftConfig, | ||
) | ||
|
||
app = cyclopts.App() | ||
|
||
|
||
def remove_smoothing(config: CalibrationConfig) -> CalibrationConfig: | ||
match config: | ||
case CalibrationRegressShiftConfig(): | ||
return config.model_copy(update={"spatial_smoothing": None}) | ||
case CalibrationChemicalPeptideNoiseConfig(): | ||
return config | ||
case CalibrationMCCConfig(): | ||
return config.model_copy(update={"coef_smoothing_activated": False}) | ||
case CalibrationConstantGlobalShiftConfig(): | ||
return config | ||
case _: | ||
raise NotImplementedError(f"Smoothing removal for {config.method.calibration_method} not implemented.") | ||
|
||
|
||
@app.default | ||
def prepare(input_config_path: Path, output_config_path: Path) -> None: | ||
config = CalibrationConfig.model_validate(yaml.safe_load(input_config_path.read_text())) | ||
config_new = remove_smoothing(config) | ||
output_config_path.write_text(yaml.safe_dump(config_new.model_dump(mode="json"))) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters