diff --git a/mu_map/data/__init__.py b/mu_map/data/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..975d883b3551e3ab8a76306fb79d12e88d34c496 --- /dev/null +++ b/mu_map/data/__init__.py @@ -0,0 +1 @@ +from .datasets import * diff --git a/mu_map/data/datasets.py b/mu_map/data/datasets.py new file mode 100644 index 0000000000000000000000000000000000000000..e1aa99d458a5d97c9b7132d98c41550b5cb3ec41 --- /dev/null +++ b/mu_map/data/datasets.py @@ -0,0 +1,21 @@ +import os + +import pandas as pd +import pydicom +from torch.utils.data import Dataset + +class MuMapDataset(Dataset): + + def __init__(self): + super().__init__() + + # read csv file and from that access dicom files + + def __getitem__(self, index): + pass + + def __len__(self): + pass + + +__all__ = [MuMapDataset.__name__] diff --git a/mu_map/data/preprocessing.py b/mu_map/data/preprocessing.py new file mode 100644 index 0000000000000000000000000000000000000000..dc57c6f1de0980238302c460af2d8d9278f8826b --- /dev/null +++ b/mu_map/data/preprocessing.py @@ -0,0 +1,38 @@ +import torch + + +def norm_max(tensor: torch.Tensor): + return (tensor - tensor.min()) / (tensor.max() - tensor.min()) + + +class MaxNorm: + def __call__(self, tensor: torch.Tensor): + return norm_max(tensor) + + +def norm_mean(tensor: torch.Tensor): + return tensor / tensor.mean() + + +class MeanNorm: + def __call__(self, tensor: torch.Tensor): + return norm_mean(tensor) + + +def norm_gaussian(tensor: torch.Tensor): + return (tensor - tensor.mean()) / tensor.std() + + +class GaussianNorm: + def __call__(self, tensor: torch.Tensor): + return norm_gaussian(tensor) + + +__all__ = [ + norm_max.__name__, + norm_mean.__name__, + norm_gaussian.__name__, + MaxNorm.__name__, + MeanNorm.__name__, + GaussianNorm.__name__, +] diff --git a/mu_map/models.py b/mu_map/models.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/mu_map/test.py b/mu_map/test.py new file mode 100644 index 0000000000000000000000000000000000000000..fb197707dafb8ef048a3cad6b2d7de1cdc9b0526 --- /dev/null +++ b/mu_map/test.py @@ -0,0 +1,18 @@ +import torch + +from .data.preprocessing import * + +means = torch.full((10, 10, 10), 5.0) +stds = torch.full((10, 10, 10), 10.0) +x = torch.normal(means, stds) + +print(f"Before: mean={x.mean():.3f} std={x.std():.3f}") + +y = norm_gaussian(x) +print(f" After: mean={y.mean():.3f} std={y.std():.3f}") +y = GaussianNorm()(x) +print(f" After: mean={y.mean():.3f} std={y.std():.3f}") + + + + diff --git a/mu_map/train.py b/mu_map/train.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391