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
4 changes: 2 additions & 2 deletions Installation/conda_env_setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ set BIN_PATH=/%BIN_PATH::=%
:: This will allow them to be run on environment activation.
for %%F in (activate deactivate) DO (
if not exist "%CONDA_PREFIX%\etc\conda\%%F.d" mkdir "%CONDA_PREFIX%\etc\conda\%%F.d"
copy .\Installation\shapeworks-%%F.bat "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat"
copy /Y .\Installation\shapeworks-%%F.bat "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat"
call python .\Installation\replace_strings.py "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat" shapeworks_placeholder_string "%cd%\bin"

:: Copy unix shell activation scripts, needed by Windows Bash users
copy .\Installation\shapeworks-%%F.sh "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh"
copy /Y .\Installation\shapeworks-%%F.sh "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh"
call python .\Installation\replace_strings.py "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh" shapeworks_placeholder_string "\"%BIN_PATH%\""
)
4 changes: 2 additions & 2 deletions Libs/Particles/ParticleSystemEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool ParticleSystemEvaluation::evaluation_compare(const ParticleSystemEvaluation
bool good = true;
if (compactness1.size() > 0 && compactness2.size() > 0) {
std::cout << "Comparing compactness: " << compactness1[0] << " vs " << compactness2[0] << ": ";
if (!epsEqual(compactness1[0], compactness2[0], 0.07)) {
if (!epsEqual(compactness1[0], compactness2[0], 0.10)) {
std::cout << "different\n";
good = false;
} else {
Expand Down Expand Up @@ -101,7 +101,7 @@ bool ParticleSystemEvaluation::evaluation_compare(const ParticleSystemEvaluation
if (spec1.size() > 0 && spec2.size() > 0) {
std::cout << "Comparing specificity: " << spec1[0] << " vs " << spec2[0] << ": ";
double diff = std::abs(spec1[0] - spec2[0]);
if (diff > 0.25 * spec1[0] || diff > 0.25 * spec2[0]) {
if (diff > 0.45 * spec1[0] || diff > 0.45 * spec2[0]) {
std::cout << "different (" << diff << ")\n";
good = false;
} else {
Expand Down
33 changes: 33 additions & 0 deletions docs/users/Windows_README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,39 @@ models, and visualizing the results.

Welcome to ShapeWorks!

### Windows 11 users: Smart App Control affects Python features

On Windows 11, a security feature called Smart App Control will block the
Python libraries that ShapeWorks installs.

ShapeWorks Studio itself will still run, and you can use its grooming,
optimization, and analysis features normally. However, the following will not
work until Smart App Control is turned off:

- Python use cases (python RunUseCase.py ...)
- Jupyter notebook examples
- DeepSSM and other Python-based features inside Studio

If affected, you will see errors like:

"ImportError: DLL load failed while importing vtkWebCore:
An Application Control policy has blocked this file."

ShapeWorks uses common scientific Python libraries (VTK, PyTorch, etc.) that
are not digitally signed by Microsoft, so Smart App Control blocks them. Most
other scientific Python tools have the same issue.

To turn Smart App Control off:

1. Click the Start button and type "Smart App Control".
2. Click "Smart App Control settings".
3. Select "Off".

Note: Turning Smart App Control off is a one-way change. The only way to turn
it back on later is to reset Windows. The install_shapeworks.bat script will
detect Smart App Control and warn you before installing.


### To complete your installation:

1. Download and install Miniconda for Windows.
Expand Down
32 changes: 32 additions & 0 deletions docs/users/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@

Please make sure that you download the [latest ShapeWorks binary release](https://github.com/SCIInstitute/ShapeWorks/releases/latest), or up-to-date development builds from the master branch for [Windows](https://github.com/SCIInstitute/ShapeWorks/releases/tag/dev-windows) *(remember these are in-progress development builds, not official releases).*

!!! warning "Windows 11: Smart App Control affects Python features"
On Windows 11, a security feature called **Smart App Control** will block
the Python libraries that ShapeWorks installs. **ShapeWorks Studio itself
will still run**, and you can use its grooming, optimization, and analysis
features normally. However, the following will not work until Smart App
Control is turned off:

- Python use cases (`python RunUseCase.py ...`)
- Jupyter notebook examples
- DeepSSM and other Python-based features inside Studio

If affected, you will see errors like:

*"ImportError: DLL load failed while importing vtkWebCore: An Application Control policy has blocked this file."*

This happens because ShapeWorks relies on common scientific Python
libraries (VTK, PyTorch, etc.) that are not digitally signed by Microsoft.
Smart App Control blocks unsigned files, even though they are safe.
Most other scientific Python tools (PyTorch, SciPy, OpenCV, ...) have the
same issue.

**To turn Smart App Control off:**

1. Click the **Start** button and type **Smart App Control**.
2. Click **Smart App Control settings**.
3. Select **Off**.

**Important:** Turning Smart App Control off is a one-way change. The only
way to turn it back on later is to reset Windows. If you are unsure
whether your computer has Smart App Control enabled, the
`install_shapeworks.bat` script will detect it and warn you.


1. Download and install Miniconda for Windows.
[https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe](https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe)
Expand Down
105 changes: 100 additions & 5 deletions install_shapeworks.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
REM remove existing shapeworks env if any
set CONDAENV=shapeworks
IF NOT "%1"=="" SET CONDAENV=%1

REM === Check for Smart App Control (Windows 11) ===
REM Smart App Control will block unsigned DLLs (VTK, PyTorch, etc.) that ShapeWorks
REM installs via pip, causing import failures. Warn the user before proceeding.
set SAC_STATE=
for /f "delims=" %%s in ('powershell -NoProfile -Command "(Get-MpComputerStatus).SmartAppControlState" 2^>nul') do set SAC_STATE=%%s
if /i "%SAC_STATE%"=="On" (
echo.
echo ============================================================
echo WARNING: Smart App Control is ENABLED on this computer.
echo ============================================================
echo.
echo ShapeWorks Studio itself will still run, but the Python
echo features ^(use cases, notebooks, DeepSSM^) will fail because
echo Smart App Control blocks the unsigned Python libraries
echo ^(VTK, PyTorch, etc.^) with errors like:
echo.
echo "An Application Control policy has blocked this file"
echo.
echo To use the Python features, turn Smart App Control OFF:
echo.
echo 1. Click the Start button and type "Smart App Control"
echo 2. Click "Smart App Control settings"
echo 3. Select "Off"
echo.
echo IMPORTANT: Turning Smart App Control off is permanent.
echo To turn it back on, you must reset Windows.
echo.
echo See https://sciinstitute.github.io/ShapeWorks/users/install.html
echo for more information.
echo.
echo Press Ctrl+C to cancel, or any key to continue installing
echo ^(install will succeed, but Python features won't work
echo until SAC is off^).
echo ============================================================
echo.
pause
)

echo "creating new conda environment for ShapeWorks called %CONDAENV%..."

REM Accept Anaconda TOS for required channels (must happen before any conda command that touches default channels)
Expand All @@ -9,7 +48,7 @@ call conda tos accept --override-channels --channel https://repo.anaconda.com/pk
call conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/msys2

REM remove any existing environment with this name
call conda env remove -n %CONDAENV%
call conda env remove -n %CONDAENV% -y

REM update anaconda
call conda config --add channels anaconda
Expand All @@ -25,17 +64,18 @@ call conda activate %CONDAENV%

call python -m pip install -r python_requirements.txt || goto :error

REM install ptorch using light-the-torch
call ltt install torch==2.2.2 || goto :error
REM install pytorch using light-the-torch
REM Use python -m to ensure we use the conda env's light_the_torch
call python -m light_the_torch install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 || goto :error

REM different versions of open3d for different OSes, so we install it manually here
call pip install open3d==0.19.0 || goto :error

call pip install Python/DatasetUtilsPackage.tar.gz || goto :error
call pip install Python/DocumentationUtilsPackage.tar.gz || goto :error
call pip install Python/DataAugmentationUtilsPackage.tar.gz || goto :error
call pip install Python/DatasetUtilsPackage.tar.gz || goto :error
call pip install Python/MONAILabelPackage.tar.gz || goto :error
call pip install Python/DeepSSMUtilsPackage.tar.gz || goto :error
call pip install Python/DocumentationUtilsPackage.tar.gz || goto :error
call pip install Python/ShapeCohortGenPackage.tar.gz || goto :error
call pip install Python/shapeworks.tar.gz || goto :error

Expand All @@ -50,6 +90,61 @@ python -c "import sys; print(sys.prefix)" > "%USERPROFILE%\.shapeworks\python_ho
echo %PATH% > "%USERPROFILE%\.shapeworks\path_6.7.txt"
call conda info

REM === Validating installation ===
echo.
echo === Validating installation ===
set VALIDATION_FAILED=0

REM Check Python version
for /f "delims=" %%v in ('python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYTHON_VERSION=%%v
if "%PYTHON_VERSION%"=="3.12" (
echo [OK] Python version: %PYTHON_VERSION%
) else (
echo [FAIL] Python version: %PYTHON_VERSION% ^(expected 3.12^)
set VALIDATION_FAILED=1
)

REM Check torch
python -c "import torch; print(f'[OK] torch {torch.__version__} (CUDA: {torch.cuda.is_available()})')"
if errorlevel 1 (
echo [FAIL] torch: failed to import
set VALIDATION_FAILED=1
)

REM Check shapeworks
python -c "import shapeworks; print('[OK] shapeworks package imported successfully')"
if errorlevel 1 (
echo [FAIL] shapeworks: failed to import
set VALIDATION_FAILED=1
)

REM Check DeepSSMUtils
python -c "import DeepSSMUtils; print('[OK] DeepSSMUtils package imported successfully')"
if errorlevel 1 (
echo [FAIL] DeepSSMUtils: failed to import
set VALIDATION_FAILED=1
)

REM Check vtk
python -c "import vtk; print(f'[OK] vtk {vtk.vtkVersion.GetVTKVersion()}')"
if errorlevel 1 (
echo [FAIL] vtk: failed to import
set VALIDATION_FAILED=1
)

REM Check itk
python -c "import itk; print(f'[OK] itk {itk.Version.GetITKVersion()}')"
if errorlevel 1 (
echo [FAIL] itk: failed to import
set VALIDATION_FAILED=1
)

echo ================================
if "%VALIDATION_FAILED%"=="1" (
echo.
echo WARNING: Some validation checks failed. Please review the output above.
)

echo "ShapeWorks environment %CONDAENV% is ready to use."
goto :EOF

Expand Down
Loading