Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build-linux-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,30 @@ jobs:
shell: bash -l {0}
run: .github/workflows/gha_conda.sh

- name: Restore Dependencies Cache
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: /github/home/install
key: ${{ runner.os }}-deps-debug-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-deps-

- name: Check space4
run: df -h

- name: Build Dependencies
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: .github/workflows/gha_deps.sh

- name: Save Dependencies Cache
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /github/home/install
key: ${{ runner.os }}-deps-debug-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}

- name: Check space5
run: df -h

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,32 @@ jobs:
shell: bash -l {0}
run: .github/workflows/gha_conda.sh

- name: Restore Dependencies Cache
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: /github/home/install
key: ${{ runner.os }}-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-deps-

- name: try import vtk
shell: bash -l {0}
run: conda activate shapeworks && python -c "import vtk"


- name: Build Dependencies
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: .github/workflows/gha_deps.sh

- name: Save Dependencies Cache
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /github/home/install
key: ${{ runner.os }}-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}

- name: Check space4
run: df -h

Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/build-mac-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,27 @@ jobs:
shell: bash -l {0}
run: .github/workflows/gha_conda.sh

- name: Restore Dependencies Cache
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: /Users/runner/install
key: ${{ runner.os }}-arm64-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-deps-

- name: Build Dependencies
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: .github/workflows/gha_deps.sh

- name: Save Dependencies Cache
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /Users/runner/install
key: ${{ runner.os }}-arm64-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}

- name: cmake
shell: bash -l {0}
run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_LIBTOOL=/usr/bin/libtool -DCMAKE_CXX_FLAGS="-g -Wno-enum-constexpr-conversion" -DCMAKE_PREFIX_PATH=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPython3_ROOT_DIR:FILEPATH=${CONDA_PREFIX} -DUSE_OPENMP=OFF -DBuild_Studio=ON -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DBUILD_DOCUMENTATION=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET ..
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,27 @@ jobs:
shell: bash -l {0}
run: .github/workflows/gha_conda.sh

- name: Restore Dependencies Cache
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: /Users/runner/install
key: ${{ runner.os }}-intel-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-deps-

- name: Build Dependencies
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: .github/workflows/gha_deps.sh

- name: Save Dependencies Cache
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: /Users/runner/install
key: ${{ runner.os }}-intel-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}

- name: cmake
shell: bash -l {0}
run: conda activate shapeworks && mkdir build && cd build && cmake -DCMAKE_LIBTOOL=/usr/bin/libtool -DCMAKE_CXX_FLAGS=-g -DCMAKE_PREFIX_PATH=$HOME/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPython3_ROOT_DIR:FILEPATH=${CONDA_PREFIX} -DUSE_OPENMP=OFF -DBuild_Studio=ON -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/shapeworks-install -DBUILD_DOCUMENTATION=ON -DGA_MEASUREMENT_ID=$GA_MEASUREMENT_ID -DGA_API_SECRET=$GA_API_SECRET ..
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,26 @@ jobs:
shell: bash -l {0}
run: .github/workflows/gha_conda.sh

- name: Restore Dependencies Cache
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: C:\deps
key: ${{ runner.os }}-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}
restore-keys: |
${{ runner.os }}-deps-

- name: Build Dependencies
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
shell: bash -l {0}
run: .github/workflows/gha_deps.sh

- name: Save Dependencies Cache
if: steps.cache-deps-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: C:\deps
key: ${{ runner.os }}-deps-${{ hashFiles('.github/workflows/gha_deps.sh', 'install_shapeworks.sh', 'python_requirements.txt', 'build_dependencies.sh') }}

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand Down Expand Up @@ -167,4 +184,4 @@ jobs:
prerelease: true
title: "Development Build for Windows"
files: |
d:/a/ShapeWorks/ShapeWorks/artifacts/*.exe
d:/a/ShapeWorks/ShapeWorks/artifacts/*.exe
7 changes: 0 additions & 7 deletions Libs/Groom/Groom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ bool Groom::image_pipeline(std::shared_ptr<Subject> subject, size_t domain) {

//---------------------------------------------------------------------------
bool Groom::run_image_pipeline(Image& image, GroomParameters params) {
// ensure axis aligned
image.toAxisAligned();

// isolate
if (params.get_isolate_tool()) {
image.isolate();
Expand Down Expand Up @@ -1141,17 +1138,13 @@ Mesh Groom::get_mesh(int subject, int domain, bool transformed, MeshSource sourc
}
path = subjects[subject]->get_original_filenames()[domain];
domain_type = project_->get_original_domain_types()[domain];
SW_DEBUG("Getting original mesh for subject {}, domain {}: {}", subject, domain, path);
SW_DEBUG("Domain type: {}", static_cast<int>(domain_type));
} else {
if (domain >= subjects[subject]->get_groomed_filenames().size()) {
throw std::out_of_range("domain index out of range");
}
path = subjects[subject]->get_groomed_filenames()[domain];

domain_type = ProjectUtils::determine_domain_type(path);
SW_DEBUG("Getting groomed mesh for subject {}, domain {}: {}", subject, domain, path);
SW_DEBUG("Domain type: {}", static_cast<int>(domain_type));
}

auto constraint_filename = subjects[subject]->get_constraints_filenames();
Expand Down
1 change: 0 additions & 1 deletion Libs/Groom/Groom.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class Groom {

Mesh get_mesh(int subject, int domain, bool transformed = false, MeshSource source = MeshSource::Groomed);


vtkSmartPointer<vtkPoints> get_landmarks(int subject, int domain);

int find_reference_landmarks(std::vector<vtkSmartPointer<vtkPoints>> landmarks);
Expand Down
86 changes: 2 additions & 84 deletions Libs/Image/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Image::ImageType::Pointer Image::read(const std::string& pathname) {
img = orienter->GetOutput();
}

img = ImageUtils::make_axis_aligned(img);

return img;
}

Expand Down Expand Up @@ -431,90 +433,6 @@ Image& Image::resize(Dims dims, Image::InterpolationType interp) {
return resample(IdentityTransform::New(), origin(), dims, spacing, coordsys(), interp);
}


Image& Image::toAxisAligned(InterpolationType interp) {
// Check if image is already axis-aligned
auto direction = itk_image_->GetDirection();
bool is_oblique = false;
for (unsigned int i = 0; i < 3; i++) {
for (unsigned int j = 0; j < 3; j++) {
double expected = (i == j) ? 1.0 : 0.0;
if (std::abs(direction(i, j) - expected) > 1e-6) {
is_oblique = true;
break;
}
}
}

// If already axis-aligned, return immediately
if (!is_oblique) {
return *this;
}

// The key insight: we need to create a transform that represents
// the DIFFERENCE between the oblique and axis-aligned coordinate systems

using TransformType = itk::AffineTransform<double, 3>;
auto transform = TransformType::New();

// The direction matrix rotates from index space to physical space
// To go from new axis-aligned indices to old oblique physical space,
// we need: newPhysical = identity * newIndex
// oldIndex = direction^-1 * oldPhysical
// So: oldIndex = direction^-1 * identity * newIndex = direction^-1 * newIndex

TransformType::MatrixType matrix;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
matrix(i, j) = direction(i, j);
}
}
transform->SetMatrix(matrix);

// Get bounding box
auto size = itk_image_->GetLargestPossibleRegion().GetSize();
auto spacing = itk_image_->GetSpacing();
auto origin = itk_image_->GetOrigin();

Point3 minPt, maxPt;
for (int i = 0; i < 3; i++) {
minPt[i] = std::numeric_limits<double>::max();
maxPt[i] = std::numeric_limits<double>::lowest();
}

for (int corner = 0; corner < 8; corner++) {
Coord index;
index[0] = (corner & 1) ? size[0] - 1 : 0;
index[1] = (corner & 2) ? size[1] - 1 : 0;
index[2] = (corner & 4) ? size[2] - 1 : 0;

Point3 point;
itk_image_->TransformIndexToPhysicalPoint(index, point);

for (int dim = 0; dim < 3; dim++) {
minPt[dim] = std::min(minPt[dim], point[dim]);
maxPt[dim] = std::max(maxPt[dim], point[dim]);
}
}

ImageType::DirectionType identityDir;
identityDir.SetIdentity();

ImageType::SizeType outputSize;
for (int i = 0; i < 3; i++) {
outputSize[i] = static_cast<size_t>(std::ceil((maxPt[i] - minPt[i]) / spacing[i])) + 1;
}

Vector3 spacingVec;
Dims dims;
for (int i = 0; i < 3; i++) {
spacingVec[i] = spacing[i];
dims[i] = outputSize[i];
}

return resample(transform, minPt, dims, spacingVec, identityDir, interp);
}

bool Image::compare(const Image& other, bool verifyall, double tolerance, double precision) const {
if (tolerance > 1 || tolerance < 0) {
throw std::invalid_argument("tolerance value must be between 0 and 1 (inclusive)");
Expand Down
3 changes: 0 additions & 3 deletions Libs/Image/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ class Image {
/// resamples image using isotropic physical spacing
Image& resample(double isoSpacing = 1.0, InterpolationType interp = Linear);

/// resamples image to be axis-aligned (i.e., identity direction matrix) if needed
Image& toAxisAligned(InterpolationType interp = NearestNeighbor);

/// changes logical image size, computing new physical spacing based on this size (i.e., physical image size remains
/// the same)
Image& resize(Dims logicalDims, InterpolationType interp = Linear);
Expand Down
Loading
Loading