MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / get_data

Function get_data

monai/transforms/utils_create_transform_ims.py:203–230  ·  view source on GitHub ↗

Get the example data to be used. Use MarsAtlas as it only contains 1 image for quick download and that image is parcellated.

(keys)

Source from the content-addressed store, hash-verified

201
202
203def get_data(keys):
204 """Get the example data to be used.
205
206 Use MarsAtlas as it only contains 1 image for quick download and
207 that image is parcellated.
208 """
209 cache_dir = MONAIEnvVars.data_dir() or tempfile.mkdtemp()
210 fname = "MarsAtlas-MNI-Colin27.zip"
211 url = "https://www.dropbox.com/s/ndz8qtqblkciole/" + fname + "?dl=1"
212 out_path = os.path.join(cache_dir, "MarsAtlas-MNI-Colin27")
213 zip_path = os.path.join(cache_dir, fname)
214
215 download_and_extract(url, zip_path, out_path)
216
217 image, label = sorted(glob(os.path.join(out_path, "*.nii")))
218
219 transforms = Compose(
220 [
221 LoadImaged(keys),
222 EnsureChannelFirstd(keys),
223 ScaleIntensityd(CommonKeys.IMAGE),
224 Rotate90d(keys, spatial_axes=(0, 2)),
225 ]
226 )
227 data = transforms({CommonKeys.IMAGE: image, CommonKeys.LABEL: label})
228 max_size = max(data[keys[0]].shape)
229 padder = SpatialPadd(keys, (max_size, max_size, max_size))
230 return padder(data)
231
232
233def update_docstring(code_path, transform_name):

Callers 1

Calls 9

download_and_extractFunction · 0.90
ComposeClass · 0.90
LoadImagedClass · 0.90
EnsureChannelFirstdClass · 0.90
ScaleIntensitydClass · 0.90
Rotate90dClass · 0.90
SpatialPaddClass · 0.90
maxFunction · 0.85
data_dirMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…