|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
import contextlib |
|
|
|
|
|
|
|
|
|
|
|
import pandas as pd |
|
|
|
import pandas as pd |
|
|
|
from sensospot_tools import ( |
|
|
|
from sensospot_tools import ( |
|
|
|
normalize as normalize_xdr_data, |
|
|
|
normalize as normalize_xdr_data, |
|
|
@ -7,10 +9,15 @@ from sensospot_tools import ( |
|
|
|
split, |
|
|
|
split, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# column names |
|
|
|
|
|
|
|
|
|
|
|
EXPOSURE_ID = "Exposure.Id" |
|
|
|
EXPOSURE_ID = "Exposure.Id" |
|
|
|
EXPOSURE_CHANNEL = "Exposure.Channel" |
|
|
|
EXPOSURE_CHANNEL = "Exposure.Channel" |
|
|
|
EXPOSURE_TIME = "Exposure.Time" |
|
|
|
EXPOSURE_TIME = "Exposure.Time" |
|
|
|
EXPOSURE_TIME_NORMALIZED = "Exposure.Time.Normalized" |
|
|
|
EXPOSURE_TIME_NORMALIZED = "Exposure.Time.Normalized" |
|
|
|
|
|
|
|
NET_SIGNAL = "NetSignal" |
|
|
|
|
|
|
|
SPOT_SATURATION = "Spot.Saturation" |
|
|
|
|
|
|
|
TEST_OVERFLOW = "Test.Spot.Overflow" |
|
|
|
|
|
|
|
|
|
|
|
EXPOSURE_COLUMNS = [ |
|
|
|
EXPOSURE_COLUMNS = [ |
|
|
|
EXPOSURE_ID, |
|
|
|
EXPOSURE_ID, |
|
|
@ -19,11 +26,6 @@ EXPOSURE_COLUMNS = [ |
|
|
|
EXPOSURE_TIME_NORMALIZED, |
|
|
|
EXPOSURE_TIME_NORMALIZED, |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
SATURATION_LIMIT = 2 |
|
|
|
|
|
|
|
SPOT_SATURATION = "Spot.Saturation" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_OVERFLOW = "Test.Spot.Overflow" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SPOT_ID_COLUMNS = ["Analysis.Name", "Well.Name", "Pos.Id"] |
|
|
|
SPOT_ID_COLUMNS = ["Analysis.Name", "Well.Name", "Pos.Id"] |
|
|
|
|
|
|
|
|
|
|
|
TIME_DEPENDENT_COLUMNS = [ |
|
|
|
TIME_DEPENDENT_COLUMNS = [ |
|
|
@ -37,6 +39,8 @@ TIME_DEPENDENT_COLUMNS = [ |
|
|
|
"Spot.Sum", |
|
|
|
"Spot.Sum", |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SATURATION_LIMIT = 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_exposure_info(data: pd.DataFrame, analysis="hyb") -> pd.DataFrame: |
|
|
|
def add_exposure_info(data: pd.DataFrame, analysis="hyb") -> pd.DataFrame: |
|
|
|
time_cy3 = 100 if "1" in analysis else 200 |
|
|
|
time_cy3 = 100 if "1" in analysis else 200 |
|
|
@ -61,7 +65,7 @@ def normalize(raw_data: pd.DataFrame, analysis="hyb"): |
|
|
|
_normalize_channel(data) |
|
|
|
_normalize_channel(data) |
|
|
|
for _, data in split(overflow_tested, EXPOSURE_CHANNEL) |
|
|
|
for _, data in split(overflow_tested, EXPOSURE_CHANNEL) |
|
|
|
) |
|
|
|
) |
|
|
|
return pd.concat(normalized_data).reset_index() |
|
|
|
return pd.concat(normalized_data).reset_index(drop=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame: |
|
|
|
def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame: |
|
|
@ -72,10 +76,17 @@ def _normalize_channel(data: pd.DataFrame) -> pd.DataFrame: |
|
|
|
available_columns = [ |
|
|
|
available_columns = [ |
|
|
|
c for c in hdr_data.columns if c in TIME_DEPENDENT_COLUMNS |
|
|
|
c for c in hdr_data.columns if c in TIME_DEPENDENT_COLUMNS |
|
|
|
] |
|
|
|
] |
|
|
|
return normalize_xdr_data( |
|
|
|
normalized = normalize_xdr_data( |
|
|
|
hdr_data, |
|
|
|
hdr_data, |
|
|
|
normalized_time, |
|
|
|
normalized_time, |
|
|
|
EXPOSURE_TIME, |
|
|
|
EXPOSURE_TIME, |
|
|
|
available_columns, |
|
|
|
available_columns, |
|
|
|
"{}.Normalized", |
|
|
|
"{}.Normalized", |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
with contextlib.suppress(KeyError): |
|
|
|
|
|
|
|
normalized[NET_SIGNAL] = ( |
|
|
|
|
|
|
|
normalized["Spot.Mean.Normalized"] |
|
|
|
|
|
|
|
- normalized["Bkg.Median.Normalized"] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return normalized |
|
|
|