MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / create_sim_data

Function create_sim_data

tests/integration/test_auto3dseg_ensemble.py:77–101  ·  view source on GitHub ↗

Create simulated data using create_test_image_3d. Args: dataroot: data directory path that hosts the "nii.gz" image files. sim_datalist: a list of data to create. sim_dim: the image sizes, e.g. a tuple of (64, 64, 64).

(dataroot, sim_datalist, sim_dim, **kwargs)

Source from the content-addressed store, hash-verified

75
76
77def create_sim_data(dataroot, sim_datalist, sim_dim, **kwargs):
78 """
79 Create simulated data using create_test_image_3d.
80
81 Args:
82 dataroot: data directory path that hosts the "nii.gz" image files.
83 sim_datalist: a list of data to create.
84 sim_dim: the image sizes, e.g. a tuple of (64, 64, 64).
85 """
86 if not os.path.isdir(dataroot):
87 os.makedirs(dataroot)
88
89 # Generate a fake dataset
90 for d in sim_datalist["testing"] + sim_datalist["training"]:
91 im, seg = create_test_image_3d(sim_dim[0], sim_dim[1], sim_dim[2], **kwargs)
92 nib_image = nib.Nifti1Image(im, affine=np.eye(4))
93 image_fpath = os.path.join(dataroot, d["image"])
94 check_parent_dir(image_fpath)
95 nib.save(nib_image, image_fpath)
96
97 if "label" in d:
98 nib_image = nib.Nifti1Image(seg, affine=np.eye(4))
99 label_fpath = os.path.join(dataroot, d["label"])
100 check_parent_dir(label_fpath)
101 nib.save(nib_image, label_fpath)
102
103
104@skip_if_quick

Callers 1

setUpMethod · 0.70

Calls 3

create_test_image_3dFunction · 0.90
check_parent_dirFunction · 0.90
saveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…