diff --git a/Examples/Python/Data/ellipsoid-v0.zip b/Examples/Python/Data/ellipsoid-v0.zip deleted file mode 100644 index e9fece5583..0000000000 --- a/Examples/Python/Data/ellipsoid-v0.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9d7fd164333ab6abfc7145b630e926c935d67ff6066a3158f1bccb80caafa638 -size 6155750 diff --git a/Examples/Python/Data/ellipsoid_1mode.zip b/Examples/Python/Data/ellipsoid_1mode.zip new file mode 100644 index 0000000000..1050954d3a --- /dev/null +++ b/Examples/Python/Data/ellipsoid_1mode.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a575d13d8a58e406acc25e0bdf3abb45159af4459e0b350be8592a8326436618 +size 101663244 diff --git a/Examples/Python/Data/ellipsoid_fd-v0.zip b/Examples/Python/Data/ellipsoid_fd-v0.zip deleted file mode 100644 index dfa6455541..0000000000 --- a/Examples/Python/Data/ellipsoid_fd-v0.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:77431f90890e0bf4c15df378468c1b03c4c349821fe01fd8c1a3dba9cf112977 -size 5458186 diff --git a/Examples/Python/ellipsoid.py b/Examples/Python/ellipsoid.py index 74aa7b5a8c..d637b902c5 100644 --- a/Examples/Python/ellipsoid.py +++ b/Examples/Python/ellipsoid.py @@ -28,7 +28,7 @@ def Run_Pipeline(args): if int(args.interactive) != 0: input("Press Enter to continue") # Get data - datasetName = "ellipsoid-v1" + datasetName = "ellipsoid_1mode" outputDirectory = "Output/ellipsoid/" if not os.path.exists(outputDirectory): os.makedirs(outputDirectory) diff --git a/Examples/Python/ellipsoid_cut.py b/Examples/Python/ellipsoid_cut.py index 6e3898df6c..24e3671220 100644 --- a/Examples/Python/ellipsoid_cut.py +++ b/Examples/Python/ellipsoid_cut.py @@ -26,7 +26,7 @@ def Run_Pipeline(args): if int(args.interactive) != 0: input("Press Enter to continue") # Get data - datasetName = "ellipsoid_aligned-v1" + datasetName = "ellipsoid_1mode_aligned" outputDirectory = "Output/ellipsoid_cut/" if not os.path.exists(outputDirectory): os.makedirs(outputDirectory) diff --git a/Examples/Python/ellipsoid_fd.py b/Examples/Python/ellipsoid_fd.py index f3070915dd..e8acf30985 100644 --- a/Examples/Python/ellipsoid_fd.py +++ b/Examples/Python/ellipsoid_fd.py @@ -36,14 +36,14 @@ def Run_Pipeline(args): if int(args.interactive) != 0: input("Press Enter to continue") - datasetName = "ellipsoid_fd-v0" + datasetName = "ellipsoid_1mode" outputDirectory = "Output/ellipsoid_fd/" if not os.path.exists(outputDirectory): os.makedirs(outputDirectory) CommonUtils.download_and_unzip_dataset(datasetName, outputDirectory) - fileListDT = sorted(glob.glob(outputDirectory + datasetName + "/distance_transforms/*.nrrd")) - fileListNew = sorted(glob.glob(outputDirectory + datasetName + "/new_distance_transforms/*.nrrd")) + fileListDT = sorted(glob.glob(outputDirectory + datasetName + "/groomed/distance_transforms/*.nrrd")) + fileListNew = sorted(glob.glob(outputDirectory + datasetName + "/fd_segmentations/*.nrrd")) """ ## GROOM : Data Pre-processing @@ -86,7 +86,7 @@ def Run_Pipeline(args): Evaluate the meanshape of the existing shape model and use that to initialize the particles on the new shapes """ - shapemodelDir = outputDirectory + datasetName + "/shape_models/pretrained/128/" + shapemodelDir = outputDirectory + datasetName + "/shape_models/ellipsoid/128/" print(os.listdir(shapemodelDir)) findMeanShape(shapemodelDir) meanShapePath = shapemodelDir + '/meanshape_local.particles' diff --git a/Examples/Python/ellipsoid_mesh.py b/Examples/Python/ellipsoid_mesh.py index e2ce1520e5..1f51825145 100644 --- a/Examples/Python/ellipsoid_mesh.py +++ b/Examples/Python/ellipsoid_mesh.py @@ -24,7 +24,7 @@ def Run_Pipeline(args): if int(args.interactive) != 0: input("Press Enter to continue") - datasetName = "ellipsoid-v0" + datasetName = "ellipsoid_1mode_aligned" outputDirectory = "Output/ellipsoid_mesh/" if not os.path.exists(outputDirectory): os.makedirs(outputDirectory) diff --git a/Examples/Python/notebooks/tutorials/getting-started-with-exploring-segmentations.ipynb b/Examples/Python/notebooks/tutorials/getting-started-with-exploring-segmentations.ipynb index 2156a95743..241a92e845 100644 --- a/Examples/Python/notebooks/tutorials/getting-started-with-exploring-segmentations.ipynb +++ b/Examples/Python/notebooks/tutorials/getting-started-with-exploring-segmentations.ipynb @@ -298,7 +298,7 @@ "After you login, click `Collections` on the left panel and then `use-case-data-v2`. Select the dataset you would like to download by clicking on the checkbox on the left of the dataset name. See the video below.\n", "After you download the dataset zip file, make sure you unzip/extract the contents in the appropriate location.\n", "\n", - "**This notebook assumes that you have downloaded `ellipsoid-v1` and you have placed the unzipped folder `ellipsoid-v1` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", + "**This notebook assumes that you have downloaded `ellipsoid_1mode` and you have placed the unzipped folder `ellipsoid_1mode` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", "\n", "\n", "

" @@ -311,7 +311,7 @@ "outputs": [], "source": [ "# dataset name is the folder name for your dataset\n", - "datasetName = 'ellipsoid-v1'\n", + "datasetName = 'ellipsoid_1mode'\n", "\n", "# path to the dataset where we can find shape data \n", "# here we assume shape data are given as binary segmentations\n", diff --git a/Examples/Python/notebooks/tutorials/getting-started-with-grooming-segmentations.ipynb b/Examples/Python/notebooks/tutorials/getting-started-with-grooming-segmentations.ipynb index cc31ae0261..d177bc5377 100644 --- a/Examples/Python/notebooks/tutorials/getting-started-with-grooming-segmentations.ipynb +++ b/Examples/Python/notebooks/tutorials/getting-started-with-grooming-segmentations.ipynb @@ -641,7 +641,7 @@ "After you login, click `Collections` on the left panel and then `use-case-data-v2`. Select the dataset you would like to download by clicking on the checkbox on the left of the dataset name. See the video below.\n", "After you download the dataset zip file, make sure you unzip/extract the contents in the appropriate location.\n", "\n", - "**This notebook assumes that you have downloaded `ellipsoid-v1` and you have placed the unzipped folder `ellipsoid-v1` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", + "**This notebook assumes that you have downloaded `ellipsoid_1mode` and you have placed the unzipped folder `ellipsoid_1mode` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", "\n", "\n", "

" @@ -656,7 +656,7 @@ "import glob # for paths and file-directory search\n", "from pathlib import Path # for generating robust paths irrespective of the platform:Win/Linux/Mac\n", "# dataset name is the folder name for your dataset\n", - "datasetName = 'ellipsoid-v1'\n", + "datasetName = 'ellipsoid_1mode'\n", "\n", "# file extension for the shape data\n", "shapeExtention = '.nrrd'\n", diff --git a/Examples/Python/notebooks/tutorials/getting-started-with-meshes.ipynb b/Examples/Python/notebooks/tutorials/getting-started-with-meshes.ipynb index 3471eb87b4..236e11399e 100644 --- a/Examples/Python/notebooks/tutorials/getting-started-with-meshes.ipynb +++ b/Examples/Python/notebooks/tutorials/getting-started-with-meshes.ipynb @@ -128,7 +128,7 @@ "\n", "After you login, click `Collections` on the left panel and then `use-case-data-v2`. Select the dataset you would like to download by clicking on the checkbox on the left of the dataset name. See the video below.\n", "\n", - "**This notebook assumes that you have downloaded `ellipsoid-v1` and you have placed the unzipped folder`ellipsoid-v1`in `Examples/Python/Data`.** Feel free to use your own dataset. \n", + "**This notebook assumes that you have downloaded `ellipsoid_1mode` and you have placed the unzipped folder`ellipsoid_1mode`in `Examples/Python/Data`.** Feel free to use your own dataset. \n", "\n", "\n", "

\n", @@ -144,7 +144,7 @@ "import os # for paths and mkdir\n", "\n", "# dataset name is the folder name for your dataset\n", - "datasetName = 'ellipsoid-v1'\n", + "datasetName = 'ellipsoid_1mode'\n", "\n", "# path to the dataset where we can find shape data \n", "# here we assume shape data are given as surface meshes\n", diff --git a/Examples/Python/notebooks/tutorials/getting-started-with-segmentations.ipynb b/Examples/Python/notebooks/tutorials/getting-started-with-segmentations.ipynb index b172ee3632..aca01e8f0e 100644 --- a/Examples/Python/notebooks/tutorials/getting-started-with-segmentations.ipynb +++ b/Examples/Python/notebooks/tutorials/getting-started-with-segmentations.ipynb @@ -130,7 +130,7 @@ "After you login, click `Collections` on the left panel and then `use-case-data-v2`. Select the dataset you would like to download by clicking on the checkbox on the left of the dataset name. See the video below.\n", "After you download the dataset zip file, make sure you unzip/extract the contents in the appropriate location.\n", "\n", - "**This notebook assumes that you have downloaded `ellipsoid-v1` and you have placed the unzipped folder `ellipsoid-v1` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", + "**This notebook assumes that you have downloaded `ellipsoid_1mode` and you have placed the unzipped folder `ellipsoid_1mode` in `Examples/Python/Data`.** Feel free to use your own dataset. \n", "\n", "\n", "

\n" @@ -145,7 +145,7 @@ "import os # for paths and mkdir\n", "\n", "# dataset name is the folder name for your dataset\n", - "datasetName = 'ellipsoid-v1'\n", + "datasetName = 'ellipsoid_1mode'\n", "\n", "# path to the dataset where we can find shape data \n", "# here we assume shape data are given as binary segmentations\n", diff --git a/Examples/Python/notebooks/tutorials/getting-started-with-shape-cohort-generation.ipynb b/Examples/Python/notebooks/tutorials/getting-started-with-shape-cohort-generation.ipynb index 118fc40ffc..611bab4c0d 100644 --- a/Examples/Python/notebooks/tutorials/getting-started-with-shape-cohort-generation.ipynb +++ b/Examples/Python/notebooks/tutorials/getting-started-with-shape-cohort-generation.ipynb @@ -540,7 +540,20 @@ " Datatype : `bool`
\n", " Defaut value : `True`
\n", "
\n", - "- `randomize_rotation`: randomizes the orientation of the ellispoids if set to `True`
\n", + "- `randomize_rotation`: randomizes the orientation of the ellipsoid if set to `True`
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + " \n", + "- `randomize_x_radius`: randomizes the radius of the ellipsoid along x-axis if set to `True` or else the value is fixed as 20 for all ellipsoids
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + "- `randomize_y_radius`: randomizes the radius of the ellipsoid along y-axis if set to `True` or else the value is fixed as 10 for all ellipsoids
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + "- `randomize_z_radius`: randomizes the radius of the ellipsoid along z-axis if set to `True` or else the value is fixed as 10 for all ellipsoids
\n", " Datatype : `bool`
\n", " Defaut value : `True`\n", "
" @@ -610,6 +623,7 @@ " Datatype : `bool`
\n", " Defaut value : `True`\n", "
\n", + " \n", "- `spacing`: set the spacing of the segmentation image
\n", " Datatype: `list`
\n", " Default value: `[1,1,1]`
\n", diff --git a/Python/ShapeCohortGenPackage/ShapeCohortGen/CohortGenerator.py b/Python/ShapeCohortGenPackage/ShapeCohortGen/CohortGenerator.py index fb01da966b..9526f6a70a 100644 --- a/Python/ShapeCohortGenPackage/ShapeCohortGen/CohortGenerator.py +++ b/Python/ShapeCohortGenPackage/ShapeCohortGen/CohortGenerator.py @@ -22,8 +22,8 @@ def generate_images(self, blur_factor=1, foreground_mean=180, foreground_var=30, class EllipsoidCohortGenerator(CohortGenerator): def __init__(self,out_dir): super().__init__(out_dir) - def generate(self, num_samples=3, randomize_center=True, randomize_rotation=True): - self.meshes = Ellipsoids.generate(num_samples, self.out_dir, randomize_center, randomize_rotation) + def generate(self, num_samples=3, randomize_center=True, randomize_rotation=True, randomize_x_radius=True, randomize_y_radius=True, randomize_z_radius=True): + self.meshes = Ellipsoids.generate(num_samples, self.out_dir, randomize_center, randomize_rotation, randomize_x_radius, randomize_y_radius, randomize_z_radius) return self.meshes class SupershapesCohortGenerator(CohortGenerator): diff --git a/Python/ShapeCohortGenPackage/ShapeCohortGen/Ellipsoids.py b/Python/ShapeCohortGenPackage/ShapeCohortGen/Ellipsoids.py index 53734d2c21..ddb89bc73d 100644 --- a/Python/ShapeCohortGenPackage/ShapeCohortGen/Ellipsoids.py +++ b/Python/ShapeCohortGenPackage/ShapeCohortGen/Ellipsoids.py @@ -35,18 +35,26 @@ def addEllipsoid(center, radii, rotation, resolution=24): return translateFilter -def generate_ellipsoids(filename, meshDir, randomize_center, randomize_rotation): +def generate_ellipsoids(filename, meshDir, randomize_center, randomize_rotation, randomize_x_radius, randomize_y_radius, randomize_z_radius): vtkFileName = meshDir+"ellipsoid_"+filename+".vtk" plyFileName = meshDir+"ellipsoid_"+filename+".ply" if randomize_center: center_loc = list(np.random.randint(low = 0,high=50,size=3)) else: center_loc = [0,0,0] - x_radius = np.random.randint(low =15,high=25,size =1) - y_radius = np.random.randint(low =5,high=15,size =1) - z_radius = np.random.randint(low =5,high=15,size =1) - - radii = [x_radius[0],y_radius[0],z_radius[0]] + if randomize_x_radius: + x_radius = np.random.randint(low =15,high=25,size =1)[0] + else: + x_radius = 20 + if randomize_y_radius: + y_radius = np.random.randint(low =5,high=15,size =1)[0] + else: + y_radius = 10 + if randomize_z_radius: + z_radius = np.random.randint(low =5,high=15,size =1)[0] + else: + z_radius = 12 + radii = [x_radius,y_radius,z_radius] if randomize_rotation: rotation = np.random.randint(low=0,high=180,size=1)[0] else: @@ -64,10 +72,10 @@ def generate_ellipsoids(filename, meshDir, randomize_center, randomize_rotation) vtk_writer.Update() -def generate(num_samples,out_dir,randomize_center, randomize_rotation): +def generate(num_samples,out_dir,randomize_center, randomize_rotation, randomize_x_radius, randomize_y_radius, randomize_z_radius): meshDir = out_dir + "meshes/" make_dir(meshDir) for i in range(num_samples): filename = str(i).zfill(2) - generate_ellipsoids(filename, meshDir, randomize_center, randomize_rotation) + generate_ellipsoids(filename, meshDir, randomize_center, randomize_rotation, randomize_x_radius, randomize_y_radius, randomize_z_radius) return get_files(meshDir) diff --git a/docs/notebooks/getting-started-with-shape-cohort-generation.ipynb b/docs/notebooks/getting-started-with-shape-cohort-generation.ipynb index 118fc40ffc..611bab4c0d 100644 --- a/docs/notebooks/getting-started-with-shape-cohort-generation.ipynb +++ b/docs/notebooks/getting-started-with-shape-cohort-generation.ipynb @@ -540,7 +540,20 @@ " Datatype : `bool`
\n", " Defaut value : `True`
\n", "
\n", - "- `randomize_rotation`: randomizes the orientation of the ellispoids if set to `True`
\n", + "- `randomize_rotation`: randomizes the orientation of the ellipsoid if set to `True`
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + " \n", + "- `randomize_x_radius`: randomizes the radius of the ellipsoid along x-axis if set to `True` or else the value is fixed as 20 for all ellipsoids
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + "- `randomize_y_radius`: randomizes the radius of the ellipsoid along y-axis if set to `True` or else the value is fixed as 10 for all ellipsoids
\n", + " Datatype : `bool`
\n", + " Defaut value : `True`\n", + "
\n", + "- `randomize_z_radius`: randomizes the radius of the ellipsoid along z-axis if set to `True` or else the value is fixed as 10 for all ellipsoids
\n", " Datatype : `bool`
\n", " Defaut value : `True`\n", "
" @@ -610,6 +623,7 @@ " Datatype : `bool`
\n", " Defaut value : `True`\n", "
\n", + " \n", "- `spacing`: set the spacing of the segmentation image
\n", " Datatype: `list`
\n", " Default value: `[1,1,1]`
\n",