Skip to content

Commit 88d77dd

Browse files
authored
Merge pull request #2540 from SCIInstitute/amorris/6.7-fixes
Minor fixes for 6.7
2 parents 8c2e966 + df59514 commit 88d77dd

5 files changed

Lines changed: 169 additions & 9 deletions

File tree

Installation/conda_env_setup.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ set BIN_PATH=/%BIN_PATH::=%
99
:: This will allow them to be run on environment activation.
1010
for %%F in (activate deactivate) DO (
1111
if not exist "%CONDA_PREFIX%\etc\conda\%%F.d" mkdir "%CONDA_PREFIX%\etc\conda\%%F.d"
12-
copy .\Installation\shapeworks-%%F.bat "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat"
12+
copy /Y .\Installation\shapeworks-%%F.bat "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat"
1313
call python .\Installation\replace_strings.py "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.bat" shapeworks_placeholder_string "%cd%\bin"
1414

1515
:: Copy unix shell activation scripts, needed by Windows Bash users
16-
copy .\Installation\shapeworks-%%F.sh "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh"
16+
copy /Y .\Installation\shapeworks-%%F.sh "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh"
1717
call python .\Installation\replace_strings.py "%CONDA_PREFIX%\etc\conda\%%F.d\shapeworks-%%F.sh" shapeworks_placeholder_string "\"%BIN_PATH%\""
1818
)

Libs/Particles/ParticleSystemEvaluation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool ParticleSystemEvaluation::evaluation_compare(const ParticleSystemEvaluation
6969
bool good = true;
7070
if (compactness1.size() > 0 && compactness2.size() > 0) {
7171
std::cout << "Comparing compactness: " << compactness1[0] << " vs " << compactness2[0] << ": ";
72-
if (!epsEqual(compactness1[0], compactness2[0], 0.07)) {
72+
if (!epsEqual(compactness1[0], compactness2[0], 0.10)) {
7373
std::cout << "different\n";
7474
good = false;
7575
} else {
@@ -101,7 +101,7 @@ bool ParticleSystemEvaluation::evaluation_compare(const ParticleSystemEvaluation
101101
if (spec1.size() > 0 && spec2.size() > 0) {
102102
std::cout << "Comparing specificity: " << spec1[0] << " vs " << spec2[0] << ": ";
103103
double diff = std::abs(spec1[0] - spec2[0]);
104-
if (diff > 0.25 * spec1[0] || diff > 0.25 * spec2[0]) {
104+
if (diff > 0.45 * spec1[0] || diff > 0.45 * spec2[0]) {
105105
std::cout << "different (" << diff << ")\n";
106106
good = false;
107107
} else {

docs/users/Windows_README.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,39 @@ models, and visualizing the results.
1717

1818
Welcome to ShapeWorks!
1919

20+
### Windows 11 users: Smart App Control affects Python features
21+
22+
On Windows 11, a security feature called Smart App Control will block the
23+
Python libraries that ShapeWorks installs.
24+
25+
ShapeWorks Studio itself will still run, and you can use its grooming,
26+
optimization, and analysis features normally. However, the following will not
27+
work until Smart App Control is turned off:
28+
29+
- Python use cases (python RunUseCase.py ...)
30+
- Jupyter notebook examples
31+
- DeepSSM and other Python-based features inside Studio
32+
33+
If affected, you will see errors like:
34+
35+
"ImportError: DLL load failed while importing vtkWebCore:
36+
An Application Control policy has blocked this file."
37+
38+
ShapeWorks uses common scientific Python libraries (VTK, PyTorch, etc.) that
39+
are not digitally signed by Microsoft, so Smart App Control blocks them. Most
40+
other scientific Python tools have the same issue.
41+
42+
To turn Smart App Control off:
43+
44+
1. Click the Start button and type "Smart App Control".
45+
2. Click "Smart App Control settings".
46+
3. Select "Off".
47+
48+
Note: Turning Smart App Control off is a one-way change. The only way to turn
49+
it back on later is to reset Windows. The install_shapeworks.bat script will
50+
detect Smart App Control and warn you before installing.
51+
52+
2053
### To complete your installation:
2154

2255
1. Download and install Miniconda for Windows.

docs/users/install.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,38 @@
2727

2828
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).*
2929

30+
!!! warning "Windows 11: Smart App Control affects Python features"
31+
On Windows 11, a security feature called **Smart App Control** will block
32+
the Python libraries that ShapeWorks installs. **ShapeWorks Studio itself
33+
will still run**, and you can use its grooming, optimization, and analysis
34+
features normally. However, the following will not work until Smart App
35+
Control is turned off:
36+
37+
- Python use cases (`python RunUseCase.py ...`)
38+
- Jupyter notebook examples
39+
- DeepSSM and other Python-based features inside Studio
40+
41+
If affected, you will see errors like:
42+
43+
*"ImportError: DLL load failed while importing vtkWebCore: An Application Control policy has blocked this file."*
44+
45+
This happens because ShapeWorks relies on common scientific Python
46+
libraries (VTK, PyTorch, etc.) that are not digitally signed by Microsoft.
47+
Smart App Control blocks unsigned files, even though they are safe.
48+
Most other scientific Python tools (PyTorch, SciPy, OpenCV, ...) have the
49+
same issue.
50+
51+
**To turn Smart App Control off:**
52+
53+
1. Click the **Start** button and type **Smart App Control**.
54+
2. Click **Smart App Control settings**.
55+
3. Select **Off**.
56+
57+
**Important:** Turning Smart App Control off is a one-way change. The only
58+
way to turn it back on later is to reset Windows. If you are unsure
59+
whether your computer has Smart App Control enabled, the
60+
`install_shapeworks.bat` script will detect it and warn you.
61+
3062

3163
1. Download and install Miniconda for Windows.
3264
[https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe](https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe)

install_shapeworks.bat

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,45 @@
11
REM remove existing shapeworks env if any
22
set CONDAENV=shapeworks
33
IF NOT "%1"=="" SET CONDAENV=%1
4+
5+
REM === Check for Smart App Control (Windows 11) ===
6+
REM Smart App Control will block unsigned DLLs (VTK, PyTorch, etc.) that ShapeWorks
7+
REM installs via pip, causing import failures. Warn the user before proceeding.
8+
set SAC_STATE=
9+
for /f "delims=" %%s in ('powershell -NoProfile -Command "(Get-MpComputerStatus).SmartAppControlState" 2^>nul') do set SAC_STATE=%%s
10+
if /i "%SAC_STATE%"=="On" (
11+
echo.
12+
echo ============================================================
13+
echo WARNING: Smart App Control is ENABLED on this computer.
14+
echo ============================================================
15+
echo.
16+
echo ShapeWorks Studio itself will still run, but the Python
17+
echo features ^(use cases, notebooks, DeepSSM^) will fail because
18+
echo Smart App Control blocks the unsigned Python libraries
19+
echo ^(VTK, PyTorch, etc.^) with errors like:
20+
echo.
21+
echo "An Application Control policy has blocked this file"
22+
echo.
23+
echo To use the Python features, turn Smart App Control OFF:
24+
echo.
25+
echo 1. Click the Start button and type "Smart App Control"
26+
echo 2. Click "Smart App Control settings"
27+
echo 3. Select "Off"
28+
echo.
29+
echo IMPORTANT: Turning Smart App Control off is permanent.
30+
echo To turn it back on, you must reset Windows.
31+
echo.
32+
echo See https://sciinstitute.github.io/ShapeWorks/users/install.html
33+
echo for more information.
34+
echo.
35+
echo Press Ctrl+C to cancel, or any key to continue installing
36+
echo ^(install will succeed, but Python features won't work
37+
echo until SAC is off^).
38+
echo ============================================================
39+
echo.
40+
pause
41+
)
42+
443
echo "creating new conda environment for ShapeWorks called %CONDAENV%..."
544

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

1150
REM remove any existing environment with this name
12-
call conda env remove -n %CONDAENV%
51+
call conda env remove -n %CONDAENV% -y
1352

1453
REM update anaconda
1554
call conda config --add channels anaconda
@@ -25,17 +64,18 @@ call conda activate %CONDAENV%
2564

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

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

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

34-
call pip install Python/DatasetUtilsPackage.tar.gz || goto :error
35-
call pip install Python/DocumentationUtilsPackage.tar.gz || goto :error
3674
call pip install Python/DataAugmentationUtilsPackage.tar.gz || goto :error
75+
call pip install Python/DatasetUtilsPackage.tar.gz || goto :error
3776
call pip install Python/MONAILabelPackage.tar.gz || goto :error
3877
call pip install Python/DeepSSMUtilsPackage.tar.gz || goto :error
78+
call pip install Python/DocumentationUtilsPackage.tar.gz || goto :error
3979
call pip install Python/ShapeCohortGenPackage.tar.gz || goto :error
4080
call pip install Python/shapeworks.tar.gz || goto :error
4181

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

93+
REM === Validating installation ===
94+
echo.
95+
echo === Validating installation ===
96+
set VALIDATION_FAILED=0
97+
98+
REM Check Python version
99+
for /f "delims=" %%v in ('python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYTHON_VERSION=%%v
100+
if "%PYTHON_VERSION%"=="3.12" (
101+
echo [OK] Python version: %PYTHON_VERSION%
102+
) else (
103+
echo [FAIL] Python version: %PYTHON_VERSION% ^(expected 3.12^)
104+
set VALIDATION_FAILED=1
105+
)
106+
107+
REM Check torch
108+
python -c "import torch; print(f'[OK] torch {torch.__version__} (CUDA: {torch.cuda.is_available()})')"
109+
if errorlevel 1 (
110+
echo [FAIL] torch: failed to import
111+
set VALIDATION_FAILED=1
112+
)
113+
114+
REM Check shapeworks
115+
python -c "import shapeworks; print('[OK] shapeworks package imported successfully')"
116+
if errorlevel 1 (
117+
echo [FAIL] shapeworks: failed to import
118+
set VALIDATION_FAILED=1
119+
)
120+
121+
REM Check DeepSSMUtils
122+
python -c "import DeepSSMUtils; print('[OK] DeepSSMUtils package imported successfully')"
123+
if errorlevel 1 (
124+
echo [FAIL] DeepSSMUtils: failed to import
125+
set VALIDATION_FAILED=1
126+
)
127+
128+
REM Check vtk
129+
python -c "import vtk; print(f'[OK] vtk {vtk.vtkVersion.GetVTKVersion()}')"
130+
if errorlevel 1 (
131+
echo [FAIL] vtk: failed to import
132+
set VALIDATION_FAILED=1
133+
)
134+
135+
REM Check itk
136+
python -c "import itk; print(f'[OK] itk {itk.Version.GetITKVersion()}')"
137+
if errorlevel 1 (
138+
echo [FAIL] itk: failed to import
139+
set VALIDATION_FAILED=1
140+
)
141+
142+
echo ================================
143+
if "%VALIDATION_FAILED%"=="1" (
144+
echo.
145+
echo WARNING: Some validation checks failed. Please review the output above.
146+
)
147+
53148
echo "ShapeWorks environment %CONDAENV% is ready to use."
54149
goto :EOF
55150

0 commit comments

Comments
 (0)