Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

FastMRI dataset onboarding script and detailed examples #444

Merged
merged 64 commits into from
May 19, 2021
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
ee10d2c
better logging
ant0nsc Apr 20, 2021
60ebb7c
increase upload timeout
ant0nsc Apr 21, 2021
f9ea89d
onboarding script
ant0nsc Apr 22, 2021
85af616
project file
ant0nsc Apr 22, 2021
14cb742
Merge remote-tracking branch 'origin/main' into antonsc/fastmri
ant0nsc Apr 22, 2021
b112445
changelog
ant0nsc Apr 22, 2021
a1ba5fb
flake8
ant0nsc Apr 22, 2021
4892cee
doc
ant0nsc Apr 22, 2021
e2e9252
fix auth problems
ant0nsc Apr 23, 2021
b20cdb6
fix AWS problem
ant0nsc Apr 23, 2021
a513d8d
Merge remote-tracking branch 'origin/main' into antonsc/fastmri
ant0nsc Apr 23, 2021
c4dbeb6
style fix
ant0nsc Apr 23, 2021
3a15484
fix .tar.gz problem
ant0nsc Apr 26, 2021
3fcf966
fix multi-node problem on HelloContainerfla
ant0nsc Apr 26, 2021
ecab8f2
mypy
ant0nsc Apr 26, 2021
35dac4c
docu
ant0nsc Apr 26, 2021
f63d460
docu
ant0nsc Apr 26, 2021
d24a7dd
running fastmri on knee_singlecoil
ant0nsc Apr 26, 2021
1a6463e
logging noise
ant0nsc Apr 27, 2021
7e5edd2
downgrade azure-mgmt-resource because it leads to loads of warnings
ant0nsc Apr 27, 2021
8ad9354
bug fix
ant0nsc Apr 27, 2021
bc3c37c
cleanup
ant0nsc Apr 27, 2021
7a5014d
flake
ant0nsc Apr 27, 2021
25f8147
docu
ant0nsc Apr 27, 2021
d51679a
docu
ant0nsc Apr 27, 2021
aba61d7
docu
ant0nsc Apr 28, 2021
24a56c4
docu
ant0nsc Apr 28, 2021
3d6251a
progress bar
ant0nsc May 4, 2021
22342c7
rename func
ant0nsc May 4, 2021
b64ee72
PR doc
ant0nsc May 11, 2021
acb51f9
adding more models
ant0nsc May 11, 2021
10fede1
Merge remote-tracking branch 'origin/main' into antonsc/fastmri
ant0nsc May 11, 2021
8d281a0
docu
ant0nsc May 11, 2021
8826890
docu
ant0nsc May 11, 2021
dfdb900
mypy
ant0nsc May 11, 2021
ef52486
test fix
ant0nsc May 12, 2021
8d452ae
Adding more hooks
ant0nsc May 12, 2021
4741fe3
Merge remote-tracking branch 'origin/main' into antonsc/fastmri
ant0nsc May 12, 2021
18d2c63
merge
ant0nsc May 12, 2021
16d5c9c
adding fixed mountpoints
ant0nsc May 12, 2021
cfb32e6
mypy
ant0nsc May 12, 2021
0e2a28d
mypy
ant0nsc May 12, 2021
4da0544
PR doc
ant0nsc May 12, 2021
b1aeba2
doc
ant0nsc May 12, 2021
f88b253
test fix
ant0nsc May 12, 2021
307366f
test fix
ant0nsc May 12, 2021
799a531
docu
ant0nsc May 12, 2021
ab450c3
fallback
ant0nsc May 12, 2021
7ea6cba
removing "unused params" warning
ant0nsc May 12, 2021
040aebc
docker warning
ant0nsc May 12, 2021
0bfaea7
mypy
ant0nsc May 12, 2021
87726ab
docu
ant0nsc May 12, 2021
c683cb1
test fix
ant0nsc May 12, 2021
03065a9
docu
ant0nsc May 12, 2021
da26cd7
docu
ant0nsc May 12, 2021
932dfa8
accidental changes
ant0nsc May 14, 2021
6ef12ab
PR comments
ant0nsc May 14, 2021
b163757
Update InnerEye/Scripts/prepare_fastmri.py
ant0nsc May 14, 2021
d5e2520
fix stuck HelloContainer problem
ant0nsc May 18, 2021
fe16627
diagnostics
ant0nsc May 18, 2021
2bd0eba
Merge remote-tracking branch 'origin/main' into antonsc/fastmri
ant0nsc May 18, 2021
6ada342
remove accidental exit(1)
ant0nsc May 18, 2021
eb303eb
unique name
ant0nsc May 19, 2021
1fb63dc
Merge branch 'main' into antonsc/fastmri
ant0nsc May 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
running fastmri on knee_singlecoil
  • Loading branch information
ant0nsc committed Apr 26, 2021
commit d24a7dd04fcdbb1cacbc76dfb25681d51bdd841e
41 changes: 37 additions & 4 deletions InnerEye/ML/configs/other/fastmri_varnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
# Suppress all errors here because the imports after code cause loads of warnings. We can't specifically suppress
# individual warnings only.
# flake8: noqa
import os
from pathlib import Path
from typing import Optional

import param
import torch
from pytorch_lightning import LightningDataModule, LightningModule
from torch.utils.tensorboard import SummaryWriter

from InnerEye.Common.common_util import add_folder_to_sys_path_if_needed
from InnerEye.Common.common_util import add_folder_to_sys_path_if_needed, change_working_directory
from InnerEye.ML.lightning_container import LightningContainer

add_folder_to_sys_path_if_needed("fastMRI")
Expand All @@ -39,19 +41,31 @@ def log_image(self, name: str, image: torch.Tensor) -> None:

class FastMri(LightningContainer):
# All fields that are declared here will be automatically available as commandline arguments.
challenge: str = param.String(default="multicoil", doc="Chooses between the singlecoil or multicoil"
"acquisition setup.")
challenge: str = param.String(default="", doc="Chooses between the singlecoil or multicoil"
"acquisition setup. If left empty, determine from dataset name.")
sample_rate: Optional[float] = param.Number(default=None, doc="Fraction of slices of the training data split to "
"use. Default: 1.0")

def __init__(self) -> None:
super().__init__()
self.azure_dataset_id = "fastmrimini_brain"
self.azure_dataset_id = "knee_singlecoil"
self.num_epochs = 1

def create_model(self) -> LightningModule:
return VarNetWithImageLogging()

def get_data_module(self) -> LightningDataModule:
if not self.challenge:
if not self.azure_dataset_id:
raise ValueError("Field self.azure_dataset_id is empty, please manually set self.challenge.")
for challenge in ["multicoil", "singlecoil"]:
if challenge in self.azure_dataset_id:
self.challenge = challenge
break
else:
raise ValueError(f"Unable to determine the value for the challenge field for this "
f"dataset: {self.azure_dataset_id}")

mask = create_mask_for_mask_type(mask_type_str="equispaced",
center_fractions=[0.08],
accelerations=[4])
Expand All @@ -61,8 +75,27 @@ def get_data_module(self) -> LightningDataModule:
test_transform = VarNetDataTransform()

return FastMriDataModule(data_path=self.local_dataset,
test_path=self.local_dataset / "singlecoil_test_v2",
challenge=self.challenge,
sample_rate=self.sample_rate,
train_transform=train_transform,
val_transform=val_transform,
test_transform=test_transform)


class FastMriOnCompressedData(FastMri):
def __init__(self) -> None:
super().__init__()
self.azure_dataset_id = "knee_singlecoil_compressed"

def before_training_on_rank_zero(self) -> None:
def unzip_folder(folder: Path) -> None:
with change_working_directory(folder):
for file in Path.cwd().glob("*.tar"):
print(f"Unzipping {file}")
os.system(f"tar xf {file}")
for file in Path.cwd().glob("*.tar.gz"):
print(f"Unzipping {file}")
os.system(f"tar xzf {file}")

unzip_folder(self.local_dataset)