Skip to content

Commit

Permalink
Per-channel normalization option in segmentation preprocessing.
Browse files Browse the repository at this point in the history
  • Loading branch information
plankter committed Jun 4, 2021
1 parent 97b8009 commit 30df6e6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions backend/histocat/core/segmentation/dto.py
Expand Up @@ -6,6 +6,7 @@
class SegmentationPreprocessingSettingsDto(BaseModel):
"""Segmentation preprocessing settings model."""

channels_normalization: Optional[str]
threshold: Optional[bool]
percentile: Optional[float]
normalize: bool
Expand Down
Expand Up @@ -41,11 +41,16 @@ def process_acquisition(
acquisition_data = parser.get_acquisition_data()

nuclei_channels = acquisition_data.get_image_stack_by_names(params.nuclei_channels)
# nuclei_channels = normalize_by_zscore(nuclei_channels)
nuclei_channels = np.nanmean(nuclei_channels, axis=0)

cytoplasm_channels = acquisition_data.get_image_stack_by_names(params.cytoplasm_channels)
# cytoplasm_channels = normalize_by_zscore(cytoplasm_channels)

if params.preprocessing.channels_normalization == "minmax":
nuclei_channels = normalize_by_minmax(nuclei_channels)
cytoplasm_channels = normalize_by_minmax(cytoplasm_channels)
elif params.preprocessing.channels_normalization == "zscore":
nuclei_channels = normalize_by_zscore(nuclei_channels)
cytoplasm_channels = normalize_by_zscore(cytoplasm_channels)

nuclei_channels = np.nanmean(nuclei_channels, axis=0)
cytoplasm_channels = np.nanmean(cytoplasm_channels, axis=0)

# Combined together and expand to 4D
Expand Down
1 change: 1 addition & 0 deletions frontend/src/modules/segmentation/models.ts
@@ -1,4 +1,5 @@
export interface ISegmentationPreprocessingSettings {
channels_normalization?: string;
threshold?: boolean;
percentile?: number;
normalize: boolean;
Expand Down
Expand Up @@ -23,6 +23,11 @@
<v-text-field label="Dataset Description" hint="Resulting dataset description" v-model="datasetDescription" />
</v-tab-item>
<v-tab-item>
<v-radio-group v-model="channelsNormalization" label="Per-channel normalization" dense>
<v-radio label="None" value="none" />
<v-radio label="Min-Max" value="minmax" />
<v-radio label="Z-score" value="zscore" />
</v-radio-group>
<v-switch v-model="threshold" label="Threshold" inset class="ml-1" dense />
<v-text-field
label="Percentile"
Expand Down Expand Up @@ -173,6 +178,7 @@ export default class SegmentationSettingsView extends Vue {
modelId: number | null = null;
compartment = "whole-cell";
channelsNormalization = "none";
threshold = true;
percentile = 99.9;
normalize = true;
Expand Down Expand Up @@ -214,6 +220,7 @@ export default class SegmentationSettingsView extends Vue {
}
const preprocessingParams = {
channels_normalization: this.channelsNormalization,
threshold: this.threshold,
percentile: this.percentile,
normalize: this.normalize,
Expand Down

0 comments on commit 30df6e6

Please sign in to comment.