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

Commit 5c5687b

Browse files
authored
Extend documentation for fastMRI (#468)
1 parent 51274c8 commit 5c5687b

File tree

3 files changed

+62
-24
lines changed

3 files changed

+62
-24
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,24 @@ For each Pull Request, the affected code parts should be briefly described and a
99
Once a release is done, the "Upcoming" section becomes the release changelog, and a new empty "Upcoming" should be
1010
created.
1111

12+
1213
## Upcoming
1314

1415
### Added
1516

17+
### Changed
18+
19+
### Fixed
20+
21+
### Removed
22+
23+
### Deprecated
24+
25+
26+
## 0.3 (2021-06-01)
27+
28+
### Added
29+
1630
- ([#454](https://github.com/microsoft/InnerEye-DeepLearning/pull/454)) Checking that labels are mutually exclusive.
1731
- ([#447](https://github.com/microsoft/InnerEye-DeepLearning/pull/447/)) Added a sanity check to ensure there are no
1832
missing channels, nor missing files. If missing channels in the csv file or filenames associated with channels are
@@ -140,8 +154,9 @@ console for easier diagnostics.
140154
- ([#450](https://github.com/microsoft/InnerEye-DeepLearning/pull/450)) Delete unused `classification_report.ipynb`.
141155
- ([#455](https://github.com/microsoft/InnerEye-DeepLearning/pull/455)) Removed the AzureRunner conda environment.
142156
The full InnerEye conda environment is needed to submit a training job to AzureML.
143-
- ([#458](https://github.com/microsoft/InnerEye-DeepLearning/pull/458)) Getting rid of all the unused code for
157+
- ([#458](https://github.com/microsoft/InnerEye-DeepLearning/pull/458)) Getting rid of all the unused code for
144158
RandAugment & Co. The user has now instead complete freedom to specify the set of augmentations to use.
159+
- ([#468](https://github.com/microsoft/InnerEye-DeepLearning/pull/468)) Removed the `KneeSinglecoil` example model
145160

146161
### Deprecated
147162

InnerEye/ML/configs/other/fastmri_varnet.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,6 @@ def get_data_module(self) -> LightningDataModule:
133133
test_path="multicoil_test_v2")
134134

135135

136-
class KneeSinglecoil(FastMri):
137-
"""
138-
A model configuration to train a VarNet model on the knee_singlecoil dataset, with 4x acceleration.
139-
"""
140-
141-
def __init__(self) -> None:
142-
super().__init__()
143-
self.azure_dataset_id = "knee_singlecoil"
144-
# If the Azure nodes run out of disk space when downloading the dataset, re-submit with the
145-
# --use_dataset_mount=True flag. The dataset will be mounted to the fixed path given here.
146-
self.dataset_mountpoint = "/tmp/knee_singlecoil"
147-
148-
def get_data_module(self) -> LightningDataModule:
149-
return get_fastmri_data_module(azure_dataset_id=self.azure_dataset_id,
150-
local_dataset=self.local_dataset,
151-
sample_rate=self.sample_rate,
152-
test_path="singlecoil_test_v2")
153-
154-
155136
class BrainMulticoil(FastMri):
156137
"""
157138
A model configuration to train a VarNet model on the brain_multicoil dataset, with 4x acceleration.

docs/fastmri.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extract all the AWS access tokens from the `curl` commands.
4545

4646
Then run the script to download the dataset as follows, providing the path the the file with the curl commands
4747
and the connection string as commandline arguments, enclosed in quotes:
48-
`python InnerEye/Scripts/prepare_fastmri.py --curl curl.txt --connection_string "<your_connection_string"` --location westeurope
48+
`python InnerEye/Scripts/prepare_fastmri.py --curl curl.txt --connection_string "<your_connection_string>"` --location westeurope
4949

5050
This script will
5151
- Authenticate against Azure either using the Service Principal credentials that you set up in Step 3 of the
@@ -83,8 +83,8 @@ If set up correctly, this is the Azure storage account that holds all datasets u
8383
Hence, after the downloading completes, you are ready to use the InnerEye toolbox to submit an AzureML job that uses
8484
the FastMRI data.
8585

86-
There are 3 example models already coded up in the InnerEye toolbox, defined in
87-
[fastmri_varnet.py](../InnerEye/ML/configs/other/fastmri_varnet.py): `KneeSinglecoil`, `KneeMulticoil`, and
86+
There are 2 example models already coded up in the InnerEye toolbox, defined in
87+
[fastmri_varnet.py](../InnerEye/ML/configs/other/fastmri_varnet.py): `KneeMulticoil` and
8888
`BrainMulticoil`. As with all InnerEye models, you can start a training run by specifying the name of the class
8989
that defines the model, like this:
9090
```shell script
@@ -152,4 +152,46 @@ python InnerEye/ML/runner.py --model BrainMulticoil --azureml=True --use_dataset
152152
This job should pick up the existing cache file, and output a message like "Copying a pre-computed dataset cache
153153
file ..."
154154

155-
The same trick can of course be applied to the other models as well (`KneeSinglecoil`, `KneeMulticoil`).
155+
The same trick can of course be applied to other models as well (`KneeMulticoil`).
156+
157+
158+
# Running on a GPU machine
159+
160+
You can of course run the InnerEye fastMRI models on a reasonably large machine with a GPU for development and
161+
debugging purposes. Before running, we recommend to download the datasets using a tool
162+
like [azcopy](http://aka.ms/azcopy) into a folder, for example the `datasets` folder at the repository root.
163+
164+
To use `azcopy`, you will need the access key to the storage account that holds your data - it's the same storage
165+
account that was used when creating the Data Factory that downloaded the data.
166+
- To get that, navigate to the [Azure Portal](https://portal.azure.com), and search for the storage account
167+
that you created to hold your datasets (Step 4 in [AzureML setup](setting_up_aml.md)).
168+
- On the left hand navigation, there is a section "Access Keys". Select that and copy out one of the two keys (_not_
169+
the connection strings). The key is a base64 encoded string, it should not contain any special characters apart from
170+
`+`, `/`, `.` and `=`
171+
172+
Then run this script in the repository root folder:
173+
```shell script
174+
mkdir datasets
175+
azcopy --source-key <storage_account_key> --source https://<your_storage_acount>.blob.core.windows.net/datasets/brain_multicoil --destination datasets/brain_multicoil --recursive
176+
```
177+
Replace `brain_multicoil` with any of the other datasets names if needed.
178+
179+
If you follow these suggested folder structures, there is no further change necessary to the models. You can then
180+
run, for example, the `BrainMulticoil` model by dropping the `--azureml=True` flag like this:
181+
```shell script
182+
python InnerEye/ML/runner.py --model BrainMulticoil
183+
```
184+
The code will recognize that an Azure dataset named `brain_multicoil` is already present in the `datasets` folder,
185+
and skip the download.
186+
187+
If you choose to download the dataset to a different folder, for example `/foo/brain_multicoil`, you will need to
188+
make a small adjustment to the model in [fastmri_varnet.py](../InnerEye/ML/configs/other/fastmri_varnet.py),
189+
and add the `local_dataset` argument like this:
190+
```python
191+
class BrainMulticoil(FastMri):
192+
def __init__(self) -> None:
193+
super().__init__()
194+
self.azure_dataset_id = "brain_multicoil"
195+
self.local_dataset = Path("/foo/brain_multicoil")
196+
self.dataset_mountpoint = "/tmp/brain_multicoil"
197+
```

0 commit comments

Comments
 (0)