Skip to content

Commit

Permalink
missing changes pr #1180
Browse files Browse the repository at this point in the history
  • Loading branch information
cchriste committed Mar 31, 2021
1 parent 9e00621 commit 0766ad3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Examples/Python/CommonUtils.py
Expand Up @@ -78,7 +78,7 @@ def download_subset(use_case,datasetName,outputDirectory):
if(generate_download_flag(outputDirectory,"shape_models/femur/mean/")):
meanFilesList = sorted([files for files in fileList if re.search("^shape_models(?:/|\\\)femur(?:/|\\\)mean(?:/|\\\).*",files)])
DatasetUtils.downloadDataset(datasetName,destinationPath=outputDirectory,fileList = meanFilesList)

def download_and_unzip_dataset(datasetName, outputDirectory):
# Check if the unzipped data is present and number of files are more than 3 for full use case
if generate_download_flag(outputDirectory,datasetName):
Expand Down
10 changes: 7 additions & 3 deletions Examples/Python/GroomUtils.py
Expand Up @@ -121,7 +121,9 @@ def FindReferenceImage(inDataList):
"""
x = y = z = 0
for i in range(len(inDataList)):
dim = itk.GetArrayFromImage(itk.imread(inDataList[i])).shape
img = Image(inDataList[i])
tmp = img.toArray()
dim = tmp.shape
if dim[0] > x:
x = dim[0]
if dim[1] > y:
Expand All @@ -131,15 +133,17 @@ def FindReferenceImage(inDataList):

COM = np.zeros((x, y, z))
for i in range(len(inDataList)):
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
img = Image(inDataList[i])
tmp = img.toArray()
COM += np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),
((z - tmp.shape[2]) // 2, (z - tmp.shape[2]) - (z - tmp.shape[2]) // 2)))
COM /= len(inDataList)
dist = np.inf
idx = 0
for i in range(len(inDataList)):
tmp = itk.GetArrayFromImage(itk.imread(inDataList[i]))
img = Image(inDataList[i])
tmp = img.toArray()
tmp_dist = np.linalg.norm(
COM - np.pad(tmp, (((x - tmp.shape[0]) // 2, (x - tmp.shape[0]) - (x - tmp.shape[0]) // 2),
((y - tmp.shape[1]) // 2, (y - tmp.shape[1]) - (y - tmp.shape[1]) // 2),
Expand Down

0 comments on commit 0766ad3

Please sign in to comment.