Skip to content

Commit ef09f39

Browse files
committed
Move shutil import to imports cell to fix PEP8
Signed-off-by: Vidya Sagar <vidyasagarreddy.venna@gmail.com>
1 parent 6210f28 commit ef09f39

File tree

1 file changed

+7
-113
lines changed

1 file changed

+7
-113
lines changed

reconstruction/MRI_reconstruction/tutorials/01_kspace_basics_fastmri_knee.ipynb

Lines changed: 7 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -84,80 +84,16 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": 2,
87+
"execution_count": null,
8888
"metadata": {
8989
"colab": {
9090
"base_uri": "https://localhost:8080/"
9191
},
9292
"id": "GurF5gp1EUEA",
9393
"outputId": "3df392a3-2936-494b-ec16-f96038c5b9ca"
9494
},
95-
"outputs": [
96-
{
97-
"output_type": "stream",
98-
"name": "stdout",
99-
"text": [
100-
"MONAI version: 1.6.dev2607\n",
101-
"Numpy version: 2.0.2\n",
102-
"Pytorch version: 2.9.0+cpu\n",
103-
"MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
104-
"MONAI rev id: 02a5644c9062d8c81f1ab94808d4f8cfa7f28a3f\n",
105-
"MONAI __file__: /usr/local/lib/python3.12/dist-packages/monai/__init__.py\n",
106-
"\n",
107-
"Optional dependencies:\n",
108-
"Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.\n",
109-
"ITK version: NOT INSTALLED or UNKNOWN VERSION.\n",
110-
"Nibabel version: 5.3.3\n",
111-
"scikit-image version: 0.25.2\n",
112-
"scipy version: 1.16.3\n",
113-
"Pillow version: 11.3.0\n",
114-
"Tensorboard version: 2.19.0\n",
115-
"gdown version: 5.2.1\n",
116-
"TorchVision version: 0.24.0+cpu\n",
117-
"tqdm version: 4.67.3\n",
118-
"lmdb version: NOT INSTALLED or UNKNOWN VERSION.\n",
119-
"psutil version: 5.9.5\n",
120-
"pandas version: 2.2.2\n",
121-
"einops version: 0.8.2\n",
122-
"transformers version: 5.0.0\n",
123-
"mlflow version: NOT INSTALLED or UNKNOWN VERSION.\n",
124-
"pynrrd version: NOT INSTALLED or UNKNOWN VERSION.\n",
125-
"clearml version: NOT INSTALLED or UNKNOWN VERSION.\n",
126-
"\n",
127-
"For details about installing the optional dependencies, please visit:\n",
128-
" https://monai.readthedocs.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
129-
"\n"
130-
]
131-
}
132-
],
133-
"source": [
134-
"import os\n",
135-
"\n",
136-
"import h5py\n",
137-
"import matplotlib.pyplot as plt\n",
138-
"import numpy as np\n",
139-
"import torch\n",
140-
"\n",
141-
"from monai.apps.reconstruction.fastmri_reader import FastMRIReader\n",
142-
"from monai.apps.reconstruction.transforms.dictionary import (\n",
143-
" EquispacedKspaceMaskd,\n",
144-
" RandomKspaceMaskd,\n",
145-
" ReferenceBasedNormalizeIntensityd,\n",
146-
")\n",
147-
"from monai.config import print_config\n",
148-
"from monai.transforms import (\n",
149-
" CenterSpatialCropd,\n",
150-
" Compose,\n",
151-
" EnsureChannelFirstd,\n",
152-
" EnsureTyped,\n",
153-
" Lambdad,\n",
154-
" LoadImaged,\n",
155-
" ThresholdIntensityd,\n",
156-
")\n",
157-
"from monai.utils.type_conversion import convert_data_type\n",
158-
"\n",
159-
"print_config()"
160-
]
95+
"outputs": [],
96+
"source": "import os\nimport shutil\n\nimport h5py\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport torch\n\nfrom monai.apps.reconstruction.fastmri_reader import FastMRIReader\nfrom monai.apps.reconstruction.transforms.dictionary import (\n EquispacedKspaceMaskd,\n RandomKspaceMaskd,\n ReferenceBasedNormalizeIntensityd,\n)\nfrom monai.config import print_config\nfrom monai.transforms import (\n CenterSpatialCropd,\n Compose,\n EnsureChannelFirstd,\n EnsureTyped,\n Lambdad,\n LoadImaged,\n ThresholdIntensityd,\n)\nfrom monai.utils.type_conversion import convert_data_type\n\nprint_config()"
16197
},
16298
{
16399
"cell_type": "markdown",
@@ -188,58 +124,16 @@
188124
},
189125
{
190126
"cell_type": "code",
191-
"execution_count": 3,
127+
"execution_count": null,
192128
"metadata": {
193129
"colab": {
194130
"base_uri": "https://localhost:8080/"
195131
},
196132
"id": "TQOy8nA0EUEA",
197133
"outputId": "98b4e840-035f-4e47-ed35-777a21c3ed2d"
198134
},
199-
"outputs": [
200-
{
201-
"output_type": "stream",
202-
"name": "stdout",
203-
"text": [
204-
"Mounted at /content/drive\n",
205-
"Copied file1000000.h5 to /content/fastmri_data/knee_singlecoil_val\n",
206-
"Using sample file: /content/fastmri_data/knee_singlecoil_val/file1000000.h5\n",
207-
"Total .h5 files found: 1\n"
208-
]
209-
}
210-
],
211-
"source": [
212-
"# Update this path to where your fastMRI knee single-coil data is stored.\n",
213-
"# You only need ONE .h5 file from the knee_singlecoil_val set.\n",
214-
"\n",
215-
"# --- Google Colab: mount Drive and copy data ---\n",
216-
"import shutil\n",
217-
"\n",
218-
"from google.colab import drive\n",
219-
"\n",
220-
"drive.mount(\"/content/drive\")\n",
221-
"\n",
222-
"drive_folder = \"/content/drive/MyDrive/fastmri_data\"\n",
223-
"data_path = \"/content/fastmri_data/knee_singlecoil_val\"\n",
224-
"os.makedirs(data_path, exist_ok=True)\n",
225-
"\n",
226-
"files = [f for f in os.listdir(drive_folder) if f.endswith(\".h5\")]\n",
227-
"if files:\n",
228-
" shutil.copy(os.path.join(drive_folder, files[0]), data_path)\n",
229-
" print(f\"Copied {files[0]} to {data_path}\")\n",
230-
"else:\n",
231-
" raise FileNotFoundError(\n",
232-
" f\"No .h5 files found in {drive_folder}\\n\" \"Please upload at least one .h5 file from knee_singlecoil_val.\"\n",
233-
" )\n",
234-
"\n",
235-
"# --- Local users: comment out the Colab block above and set your path ---\n",
236-
"# data_path = os.path.join(\"YOUR_DIR_HERE\", \"knee_singlecoil_val\")\n",
237-
"\n",
238-
"sample_files = sorted([f for f in os.listdir(data_path) if f.endswith(\".h5\")])\n",
239-
"sample_file = os.path.join(data_path, sample_files[0])\n",
240-
"print(f\"Using sample file: {sample_file}\")\n",
241-
"print(f\"Total .h5 files found: {len(sample_files)}\")"
242-
]
135+
"outputs": [],
136+
"source": "# Update this path to where your fastMRI knee single-coil data is stored.\n# You only need ONE .h5 file from the knee_singlecoil_val set.\n\n# --- Google Colab: mount Drive and copy data ---\nfrom google.colab import drive\n\ndrive.mount(\"/content/drive\")\n\ndrive_folder = \"/content/drive/MyDrive/fastmri_data\"\ndata_path = \"/content/fastmri_data/knee_singlecoil_val\"\nos.makedirs(data_path, exist_ok=True)\n\nfiles = [f for f in os.listdir(drive_folder) if f.endswith(\".h5\")]\nif files:\n shutil.copy(os.path.join(drive_folder, files[0]), data_path)\n print(f\"Copied {files[0]} to {data_path}\")\nelse:\n raise FileNotFoundError(\n f\"No .h5 files found in {drive_folder}\\n\"\n \"Please upload at least one .h5 file from knee_singlecoil_val.\"\n )\n\n# --- Local users: comment out the Colab block above and set your path ---\n# data_path = os.path.join(\"YOUR_DIR_HERE\", \"knee_singlecoil_val\")\n\nsample_files = sorted([f for f in os.listdir(data_path) if f.endswith(\".h5\")])\nsample_file = os.path.join(data_path, sample_files[0])\nprint(f\"Using sample file: {sample_file}\")\nprint(f\"Total .h5 files found: {len(sample_files)}\")"
243137
},
244138
{
245139
"cell_type": "markdown",
@@ -1038,4 +932,4 @@
1038932
},
1039933
"nbformat": 4,
1040934
"nbformat_minor": 0
1041-
}
935+
}

0 commit comments

Comments
 (0)