Skip to content

Commit

Permalink
skel for loading transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Lane committed Oct 21, 2024
1 parent 5946a66 commit 984f2b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
25 changes: 10 additions & 15 deletions fishjaw/model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import pathlib
from typing import Union

import torch
import torch.utils
Expand Down Expand Up @@ -235,26 +234,22 @@ def test_loader(
)


def _load_transform(transform: dict) -> tio.transforms.Transform:
"""
Load a transform from the configuration, which should be provided as a dict of {"name": {"arg1": value1, ...}}
"""
if not isinstance(transform, dict):
raise ValueError(f"Transform {transform} is not a dict")


def _transforms(config: dict) -> tio.transforms.Transform:
"""
Define the transforms to apply to the training data
"""
return tio.Compose(
[
tio.RandomFlip(axes=(0, 1, 2), flip_probability=0.5),
tio.RandomAffine(
p=0.25,
degrees=10,
scales=0.2,
),
# tio.RandomBlur(p=0.3),
# tio.RandomBiasField(0.4, p=0.5),
# tio.RandomNoise(0.1, 0.01, p=0.25),
# tio.RandomGamma((-0.3, 0.3), p=0.25),
# tio.ZNormalization(),
# tio.RescaleIntensity(percentiles=(0.5, 99.5)),
]
[_load_transform(transform_fcn) for transform_fcn in config["transforms"]]
)


Expand Down
3 changes: 0 additions & 3 deletions scripts/explore_hyperparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ def main(*, mode: str, n_steps: int, continue_run: bool):
train_subjects, val_subjects, _ = data.read_dicoms_from_disk(
example_config,
rng,
# Use the same transforms as we would for training
# TODO this should really be in the config
transforms="default",
)

# I think this might be doing something slightly wrong - we're getting the data which means,
Expand Down

0 comments on commit 984f2b0

Please sign in to comment.