From 809382a2b29253c4e750869277f1f561d962738a Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Fri, 20 Nov 2020 09:53:47 +0100 Subject: [PATCH] normilization api for single channels has changed --- CHANGES.md | 8 ++++++++ sensospot_data/__init__.py | 4 ++-- sensospot_data/normalisation.py | 4 ++-- tests/test_normailsation.py | 8 ++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3af22c2..c1ad670 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,11 @@ +0.3.0 - normalization api +-------------------------- + + - normilization api for single channels has changed and is exposed in package + `normalize_channel(single_channel_data_frame, normalized_time_in_ms)` + + + 0.2.0 - remove custom normalization map ---------------------------------------- diff --git a/sensospot_data/__init__.py b/sensospot_data/__init__.py index 3f4a004..0e30f40 100644 --- a/sensospot_data/__init__.py +++ b/sensospot_data/__init__.py @@ -3,7 +3,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis. """ -__version__ = "0.2.0" +__version__ = "0.3.0" VERSION_TABLE_NAME = f"v{__version__}".replace(".", "_") @@ -15,4 +15,4 @@ from .parser import ( # noqa: F401 process_folder, parse_multiple_files, ) -from .normalisation import normalize_measurement # noqa: F401 +from .normalisation import normalize_channel, normalize_measurement # noqa: F401 diff --git a/sensospot_data/normalisation.py b/sensospot_data/normalisation.py index 1f1b28b..fb40276 100644 --- a/sensospot_data/normalisation.py +++ b/sensospot_data/normalisation.py @@ -130,12 +130,12 @@ def normalize_exposure_time(split_data_frames): """ normalization_map = _infer_normalization_map(split_data_frames) return { - key: _normalize_exposure(frame, normalization_map[key]) + key: normalize_channel(frame, normalization_map[key]) for key, frame in split_data_frames.items() } -def _normalize_exposure(channel_frame, normalized_time): +def normalize_channel(channel_frame, normalized_time): """ add time normalized values to a channel data frames """ channel_frame[COL_NAME_NORMALIZED_EXPOSURE_TIME] = normalized_time diff --git a/tests/test_normailsation.py b/tests/test_normailsation.py index 302f1f6..4bb75b8 100644 --- a/tests/test_normailsation.py +++ b/tests/test_normailsation.py @@ -215,20 +215,20 @@ def test_infer_normalization_map(normalization_data_frame): assert result == {"Cy3": 25, "Cy5": 50} -def test_normalize_exposure(normalization_data_frame): +def test_normalize_channel(normalization_data_frame): from sensospot_data.columns import COLUMN_NORMALIZATION from sensospot_data.normalisation import ( reduce_overflow, - _normalize_exposure, + normalize_channel, ) reduced = reduce_overflow(normalization_data_frame, "Saturation", 1) - result = _normalize_exposure(reduced["Cy5"], 100) + result = normalize_channel(reduced["Cy5"], 50) sorted_results = result.sort_values( by=["Well.Row", "Well.Column", "Pos.Id"] ) - expected_values = [1, 4, 15, 1, 10, 10, 10, 10, 100, 100, 100, 100] + expected_values = [2, 8, 30, 2, 20, 20, 20, 20, 200, 200, 200, 200] for normalized_col in COLUMN_NORMALIZATION.values(): list(sorted_results[normalized_col]) == expected_values