Normalize data or prepare for linear/log plot.
(self)
| 362 | self.set_low_high_value() |
| 363 | |
| 364 | def preprocess_data(self): |
| 365 | """ |
| 366 | Normalize data or prepare for linear/log plot. |
| 367 | """ |
| 368 | |
| 369 | selected_data = [] |
| 370 | selected_name = [] |
| 371 | quant_norm_applied = [] |
| 372 | |
| 373 | rgb_color_to_keys = self.get_rgb_items_for_plot() |
| 374 | for data_key in rgb_color_to_keys.values(): |
| 375 | if data_key in self.dict_to_plot: |
| 376 | selected_name.append(data_key) |
| 377 | |
| 378 | if self.scaler_data is not None: |
| 379 | if np.count_nonzero(self.scaler_data) == 0: |
| 380 | logger.warning("scaler is zero - scaling was not applied") |
| 381 | elif len(self.scaler_data[self.scaler_data == 0]) > 0: |
| 382 | logger.warning("scaler data has zero values") |
| 383 | |
| 384 | for i, k in enumerate(selected_name): |
| 385 | q_norm_applied = False |
| 386 | if self.quantitative_normalization: |
| 387 | # Quantitative normalization |
| 388 | ( |
| 389 | data_arr, |
| 390 | q_norm_applied, |
| 391 | ) = self.img_model_adv.param_quant_analysis.apply_quantitative_normalization( |
| 392 | data_in=self.dict_to_plot[k], |
| 393 | scaler_dict=self.scaler_norm_dict, |
| 394 | scaler_name_default=self.get_selected_scaler_name(), |
| 395 | data_name=k, |
| 396 | ref_name=self.quantitative_ref_eline, |
| 397 | name_not_scalable=self.name_not_scalable, |
| 398 | ) |
| 399 | else: |
| 400 | # Normalize by the selected scaler in a regular way |
| 401 | data_arr = normalize_data_by_scaler( |
| 402 | data_in=self.dict_to_plot[k], |
| 403 | scaler=self.scaler_data, |
| 404 | data_name=k, |
| 405 | name_not_scalable=self.name_not_scalable, |
| 406 | ) |
| 407 | |
| 408 | selected_data.append(data_arr) |
| 409 | quant_norm_applied.append(q_norm_applied) |
| 410 | |
| 411 | return selected_data, selected_name, rgb_color_to_keys, quant_norm_applied |
| 412 | |
| 413 | def show_image(self): |
| 414 | # Don't plot the image if dictionary is empty (causes a lot of issues) |
no test coverage detected