Skip to content

Commit

Permalink
Tweak quality reduction formula
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Dec 15, 2021
1 parent 61ceb84 commit fc8d99e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions miqa/learning/nn_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ def apply_transform(self, subject: torchio.Subject) -> torchio.Subject:

# now determine how much quality was reduced
applied_params = transformed_subject.applied_transforms[-1][1]
times = applied_params['times']['img']
time = applied_params['times']['img']
degrees = np.sum(np.absolute(applied_params['degrees']['img']))
translation = np.sum(np.absolute(applied_params['translation']['img']))
# motion earlier in the acquisition process produces more noticeable artifacts
quality_reduction = clamp(degrees + translation, 0, 10) * (1.0 - times)
quality_reduction = clamp(degrees + translation, 0, 10) * min(time, 1.0 - time)

# update the ground truth information
new_quality = original_quality - quality_reduction
Expand Down Expand Up @@ -305,8 +305,7 @@ def create_train_and_test_data_loaders(df, count_train):
rescale = torchio.RescaleIntensity(out_min_max=(0, 1))
ghosting = CustomGhosting(p=0.3, intensity=(0.2, 0.8))
motion = CustomMotion(p=0.2, degrees=5.0, translation=5.0, num_transforms=1)
# transforms = torchio.Compose([rescale, ghosting, motion])
transforms = torchio.Compose([rescale, motion])
transforms = torchio.Compose([rescale, ghosting, motion])

# create a training data loader
train_ds = torchio.SubjectsDataset(train_files, transform=transforms)
Expand Down

0 comments on commit fc8d99e

Please sign in to comment.